Skip to content

Commit fc27e94

Browse files
committed
refactor: rename files to match convention
I found snake-case easier to read, and given that the project doesn't use OOP a lot, having all PascalCase names doesn't reflect the paradigmat and feels unnatural.
1 parent f7dfdcf commit fc27e94

File tree

104 files changed

+437
-361
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+437
-361
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ type IssueFilter = IssueMatch | IssuePredicate | (IssueMatch | IssuePredicate)[]
139139

140140
| Name | Type | Default value | Description |
141141
| --------- | ------------- | ------------- | ----------- |
142-
| `include` | `IssueFilter` | `undefined` | If `object`, defines issue properties that should be [matched](./src/issue/IssueMatch.ts). If `function`, acts as a predicate where `issue` is an argument. |
142+
| `include` | `IssueFilter` | `undefined` | If `object`, defines issue properties that should be [matched](src/issue/issue-match.ts). If `function`, acts as a predicate where `issue` is an argument. |
143143
| `exclude` | `IssueFilter` | `undefined` | Same as `include` but issues that match this predicate will be excluded. |
144144

145145
<details>

src/ForkTsCheckerWebpackPluginConfiguration.ts

-34
This file was deleted.

src/files-change.ts

+26-14
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
import type * as webpack from 'webpack';
22

3-
import subtract from './utils/array/substract';
4-
import unique from './utils/array/unique';
5-
63
interface FilesChange {
74
changedFiles?: string[];
85
deletedFiles?: string[];
@@ -14,6 +11,12 @@ function getFilesChange(compiler: webpack.Compiler): FilesChange {
1411
return compilerFilesChangeMap.get(compiler) || { changedFiles: [], deletedFiles: [] };
1512
}
1613

14+
function consumeFilesChange(compiler: webpack.Compiler): FilesChange {
15+
const change = getFilesChange(compiler);
16+
clearFilesChange(compiler);
17+
return change;
18+
}
19+
1720
function updateFilesChange(compiler: webpack.Compiler, change: FilesChange): void {
1821
compilerFilesChangeMap.set(compiler, aggregateFilesChanges([getFilesChange(compiler), change]));
1922
}
@@ -29,22 +32,31 @@ function clearFilesChange(compiler: webpack.Compiler): void {
2932
* @returns Files change that represents all subsequent changes as a one event
3033
*/
3134
function aggregateFilesChanges(changes: FilesChange[]): FilesChange {
32-
let changedFiles: string[] = [];
33-
let deletedFiles: string[] = [];
35+
const changedFilesSet = new Set<string>();
36+
const deletedFilesSet = new Set<string>();
3437

3538
for (const change of changes) {
36-
changedFiles = unique(
37-
subtract(changedFiles, change.deletedFiles).concat(change.changedFiles || [])
38-
);
39-
deletedFiles = unique(
40-
subtract(deletedFiles, change.changedFiles).concat(change.deletedFiles || [])
41-
);
39+
for (const changedFile of change.changedFiles || []) {
40+
changedFilesSet.add(changedFile);
41+
deletedFilesSet.delete(changedFile);
42+
}
43+
for (const deletedFile of change.deletedFiles || []) {
44+
changedFilesSet.delete(deletedFile);
45+
deletedFilesSet.add(deletedFile);
46+
}
4247
}
4348

4449
return {
45-
changedFiles,
46-
deletedFiles,
50+
changedFiles: Array.from(changedFilesSet),
51+
deletedFiles: Array.from(deletedFilesSet),
4752
};
4853
}
4954

50-
export { FilesChange, getFilesChange, updateFilesChange, clearFilesChange, aggregateFilesChanges };
55+
export {
56+
FilesChange,
57+
getFilesChange,
58+
consumeFilesChange,
59+
updateFilesChange,
60+
clearFilesChange,
61+
aggregateFilesChanges,
62+
};

src/formatter/BasicFormatter.ts renamed to src/formatter/basic-formatter.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import chalk from 'chalk';
22

3-
import type { Formatter } from './Formatter';
3+
import type { Formatter } from './formatter';
44

55
function createBasicFormatter(): Formatter {
66
return function basicFormatter(issue) {

src/formatter/CodeFrameFormatter.ts renamed to src/formatter/code-frame-formatter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import os from 'os';
33
import { codeFrameColumns } from '@babel/code-frame';
44
import fs from 'fs-extra';
55

6-
import { createBasicFormatter } from './BasicFormatter';
7-
import type { Formatter } from './Formatter';
6+
import { createBasicFormatter } from './basic-formatter';
7+
import type { Formatter } from './formatter';
88
import { BabelCodeFrameOptions } from './types/babel__code-frame';
99

1010
function createCodeFrameFormatter(options?: BabelCodeFrameOptions): Formatter {

src/formatter/FormatterConfiguration.ts renamed to src/formatter/formatter-config.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
import { createBasicFormatter } from './BasicFormatter';
2-
import { createCodeFrameFormatter } from './CodeFrameFormatter';
3-
import type { Formatter } from './Formatter';
4-
import type { CodeframeFormatterOptions, FormatterOptions } from './FormatterOptions';
1+
import { createBasicFormatter } from './basic-formatter';
2+
import { createCodeFrameFormatter } from './code-frame-formatter';
3+
import type { Formatter } from './formatter';
4+
import type { CodeframeFormatterOptions, FormatterOptions } from './formatter-options';
55

6-
type FormatterConfiguration = Formatter;
6+
type FormatterConfig = Formatter;
77

8-
function createFormatterConfiguration(
9-
options: FormatterOptions | undefined
10-
): FormatterConfiguration {
8+
function createFormatterConfig(options: FormatterOptions | undefined): FormatterConfig {
119
if (typeof options === 'function') {
1210
return options;
1311
}
@@ -35,4 +33,4 @@ function createFormatterConfiguration(
3533
);
3634
}
3735

38-
export { FormatterConfiguration, createFormatterConfiguration };
36+
export { FormatterConfig, createFormatterConfig };

src/formatter/FormatterOptions.ts renamed to src/formatter/formatter-options.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Formatter } from './Formatter';
1+
import type { Formatter } from './formatter';
22
import type { BabelCodeFrameOptions } from './types/babel__code-frame';
33

44
type FormatterType = 'basic' | 'codeframe';
File renamed without changes.

src/formatter/index.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export * from './Formatter';
2-
export * from './BasicFormatter';
3-
export * from './CodeFrameFormatter';
4-
export * from './WebpackFormatter';
5-
export * from './FormatterOptions';
6-
export * from './FormatterConfiguration';
1+
export * from './formatter';
2+
export * from './basic-formatter';
3+
export * from './code-frame-formatter';
4+
export * from './webpack-formatter';
5+
export * from './formatter-options';
6+
export * from './formatter-config';

src/formatter/WebpackFormatter.ts renamed to src/formatter/webpack-formatter.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import os from 'os';
33
import chalk from 'chalk';
44

55
import { formatIssueLocation } from '../issue';
6-
import { relativeToContext } from '../utils/path/relativeToContext';
6+
import { relativeToContext } from '../utils/path/relative-to-context';
77

8-
import type { Formatter } from './Formatter';
8+
import type { Formatter } from './formatter';
99

1010
function createWebpackFormatter(formatter: Formatter): Formatter {
1111
// mimics webpack error formatter

src/hooks/interceptDoneToGetWebpackDevServerTap.ts renamed to src/hooks/intercept-done-to-get-dev-server-tap.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type webpack from 'webpack';
22

3-
import type { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
4-
import type { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
53
import { getInfrastructureLogger } from '../infrastructure-logger';
4+
import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config';
5+
import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
66

7-
function interceptDoneToGetWebpackDevServerTap(
7+
function interceptDoneToGetDevServerTap(
88
compiler: webpack.Compiler,
9-
configuration: ForkTsCheckerWebpackPluginConfiguration,
9+
configuration: ForkTsCheckerWebpackPluginConfig,
1010
state: ForkTsCheckerWebpackPluginState
1111
) {
1212
const { debug } = getInfrastructureLogger(compiler);
@@ -27,4 +27,4 @@ function interceptDoneToGetWebpackDevServerTap(
2727
});
2828
}
2929

30-
export { interceptDoneToGetWebpackDevServerTap };
30+
export { interceptDoneToGetDevServerTap };

src/hooks/tapAfterCompileToAddDependencies.ts renamed to src/hooks/tap-after-compile-to-add-dependencies.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import type webpack from 'webpack';
22

3-
import type { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
4-
import type { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
53
import { getInfrastructureLogger } from '../infrastructure-logger';
4+
import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config';
5+
import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
66

77
function tapAfterCompileToAddDependencies(
88
compiler: webpack.Compiler,
9-
configuration: ForkTsCheckerWebpackPluginConfiguration,
9+
configuration: ForkTsCheckerWebpackPluginConfig,
1010
state: ForkTsCheckerWebpackPluginState
1111
) {
1212
const { debug } = getInfrastructureLogger(compiler);

src/hooks/tapAfterCompileToGetIssues.ts renamed to src/hooks/tap-after-compile-to-get-issues.ts

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import type webpack from 'webpack';
22

3-
import type { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
4-
import type { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
53
import { getInfrastructureLogger } from '../infrastructure-logger';
64
import type { Issue } from '../issue';
7-
import { IssueWebpackError } from '../issue/IssueWebpackError';
8-
9-
import { getForkTsCheckerWebpackPluginHooks } from './pluginHooks';
5+
import { IssueWebpackError } from '../issue/issue-webpack-error';
6+
import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config';
7+
import { getPluginHooks } from '../plugin-hooks';
8+
import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
109

1110
function tapAfterCompileToGetIssues(
1211
compiler: webpack.Compiler,
13-
configuration: ForkTsCheckerWebpackPluginConfiguration,
12+
configuration: ForkTsCheckerWebpackPluginConfig,
1413
state: ForkTsCheckerWebpackPluginState
1514
) {
16-
const hooks = getForkTsCheckerWebpackPluginHooks(compiler);
15+
const hooks = getPluginHooks(compiler);
1716
const { debug } = getInfrastructureLogger(compiler);
1817

1918
compiler.hooks.afterCompile.tapPromise('ForkTsCheckerWebpackPlugin', async (compilation) => {

src/hooks/tapAfterEnvironmentToPatchWatching.ts renamed to src/hooks/tap-after-environment-to-patch-watching.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type webpack from 'webpack';
22

3-
import type { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
43
import { getInfrastructureLogger } from '../infrastructure-logger';
5-
import { InclusiveNodeWatchFileSystem } from '../watch/InclusiveNodeWatchFileSystem';
6-
import type { WatchFileSystem } from '../watch/WatchFileSystem';
4+
import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
5+
import { InclusiveNodeWatchFileSystem } from '../watch/inclusive-node-watch-file-system';
6+
import type { WatchFileSystem } from '../watch/watch-file-system';
77

88
function tapAfterEnvironmentToPatchWatching(
99
compiler: webpack.Compiler,

src/hooks/tapDoneToAsyncGetIssues.ts renamed to src/hooks/tap-done-to-async-get-issues.ts

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,22 @@
11
import chalk from 'chalk';
22
import type webpack from 'webpack';
33

4-
import type { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
5-
import type { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
6-
import { createWebpackFormatter } from '../formatter/WebpackFormatter';
4+
import { createWebpackFormatter } from '../formatter/webpack-formatter';
75
import { getInfrastructureLogger } from '../infrastructure-logger';
86
import type { Issue } from '../issue';
9-
import { IssueWebpackError } from '../issue/IssueWebpackError';
10-
import isPending from '../utils/async/isPending';
11-
import wait from '../utils/async/wait';
12-
13-
import { getForkTsCheckerWebpackPluginHooks } from './pluginHooks';
7+
import { IssueWebpackError } from '../issue/issue-webpack-error';
8+
import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config';
9+
import { getPluginHooks } from '../plugin-hooks';
10+
import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
11+
import { isPending } from '../utils/async/is-pending';
12+
import { wait } from '../utils/async/wait';
1413

1514
function tapDoneToAsyncGetIssues(
1615
compiler: webpack.Compiler,
17-
configuration: ForkTsCheckerWebpackPluginConfiguration,
16+
configuration: ForkTsCheckerWebpackPluginConfig,
1817
state: ForkTsCheckerWebpackPluginState
1918
) {
20-
const hooks = getForkTsCheckerWebpackPluginHooks(compiler);
19+
const hooks = getPluginHooks(compiler);
2120
const { log, debug } = getInfrastructureLogger(compiler);
2221

2322
compiler.hooks.done.tap('ForkTsCheckerWebpackPlugin', async (stats) => {

src/hooks/tapErrorToLogMessage.ts renamed to src/hooks/tap-error-to-log-message.ts

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
import chalk from 'chalk';
22
import type webpack from 'webpack';
33

4-
import type { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
5-
import { RpcExitError } from '../utils/rpc';
6-
7-
import { getForkTsCheckerWebpackPluginHooks } from './pluginHooks';
4+
import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config';
5+
import { getPluginHooks } from '../plugin-hooks';
6+
import { RpcExitError } from '../rpc';
87

98
function tapErrorToLogMessage(
109
compiler: webpack.Compiler,
11-
configuration: ForkTsCheckerWebpackPluginConfiguration
10+
configuration: ForkTsCheckerWebpackPluginConfig
1211
) {
13-
const hooks = getForkTsCheckerWebpackPluginHooks(compiler);
12+
const hooks = getPluginHooks(compiler);
1413

1514
hooks.error.tap('ForkTsCheckerWebpackPlugin', (error) => {
1615
configuration.logger.issues.error(String(error));

src/hooks/tapStartToRunWorkers.ts renamed to src/hooks/tap-start-to-run-workers.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
import type * as webpack from 'webpack';
22

33
import type { FilesChange } from '../files-change';
4-
import { getFilesChange } from '../files-change';
5-
import type { ForkTsCheckerWebpackPluginConfiguration } from '../ForkTsCheckerWebpackPluginConfiguration';
6-
import type { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
4+
import { consumeFilesChange } from '../files-change';
75
import { getInfrastructureLogger } from '../infrastructure-logger';
6+
import type { ForkTsCheckerWebpackPluginConfig } from '../plugin-config';
7+
import { getPluginHooks } from '../plugin-hooks';
8+
import { dependenciesPool, issuesPool } from '../plugin-pools';
9+
import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
10+
import type { RpcWorker } from '../rpc';
811
import type { GetDependenciesWorker } from '../typescript/worker/get-dependencies-worker';
912
import type { GetIssuesWorker } from '../typescript/worker/get-issues-worker';
10-
import type { RpcWorker } from '../utils/rpc';
1113

12-
import { interceptDoneToGetWebpackDevServerTap } from './interceptDoneToGetWebpackDevServerTap';
13-
import { getForkTsCheckerWebpackPluginHooks } from './pluginHooks';
14-
import { dependenciesPool, issuesPool } from './pluginPools';
15-
import { tapAfterCompileToGetIssues } from './tapAfterCompileToGetIssues';
16-
import { tapDoneToAsyncGetIssues } from './tapDoneToAsyncGetIssues';
14+
import { interceptDoneToGetDevServerTap } from './intercept-done-to-get-dev-server-tap';
15+
import { tapAfterCompileToGetIssues } from './tap-after-compile-to-get-issues';
16+
import { tapDoneToAsyncGetIssues } from './tap-done-to-async-get-issues';
1717

1818
function tapStartToRunWorkers(
1919
compiler: webpack.Compiler,
2020
getIssuesWorker: RpcWorker<GetIssuesWorker>,
2121
getDependenciesWorker: RpcWorker<GetDependenciesWorker>,
22-
config: ForkTsCheckerWebpackPluginConfiguration,
22+
config: ForkTsCheckerWebpackPluginConfig,
2323
state: ForkTsCheckerWebpackPluginState
2424
) {
25-
const hooks = getForkTsCheckerWebpackPluginHooks(compiler);
25+
const hooks = getPluginHooks(compiler);
2626
const { log, debug } = getInfrastructureLogger(compiler);
2727

2828
compiler.hooks.run.tap('ForkTsCheckerWebpackPlugin', () => {
@@ -44,7 +44,7 @@ function tapStartToRunWorkers(
4444
debug('Initializing plugin for watch run (async).');
4545

4646
tapDoneToAsyncGetIssues(compiler, config, state);
47-
interceptDoneToGetWebpackDevServerTap(compiler, config, state);
47+
interceptDoneToGetDevServerTap(compiler, config, state);
4848
} else {
4949
debug('Initializing plugin for watch run (not async).');
5050

@@ -64,7 +64,7 @@ function tapStartToRunWorkers(
6464
let change: FilesChange = {};
6565

6666
if (state.watching) {
67-
change = getFilesChange(compiler);
67+
change = consumeFilesChange(compiler);
6868
log(
6969
[
7070
'Calling reporter service for incremental check.',

src/hooks/tapStopToTerminateWorkers.ts renamed to src/hooks/tap-stop-to-terminate-workers.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import type webpack from 'webpack';
22

3-
import type { ForkTsCheckerWebpackPluginState } from '../ForkTsCheckerWebpackPluginState';
43
import { getInfrastructureLogger } from '../infrastructure-logger';
5-
import type { RpcWorker } from '../utils/rpc';
4+
import type { ForkTsCheckerWebpackPluginState } from '../plugin-state';
5+
import type { RpcWorker } from '../rpc';
66

77
function tapStopToTerminateWorkers(
88
compiler: webpack.Compiler,

src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
import { ForkTsCheckerWebpackPlugin } from './ForkTsCheckerWebpackPlugin';
1+
import { ForkTsCheckerWebpackPlugin } from './plugin';
22

33
export = ForkTsCheckerWebpackPlugin;

src/infrastructure-logger.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type webpack from 'webpack';
22

3-
interface InfrastructureLogger {
3+
export interface InfrastructureLogger {
44
log(...args: unknown[]): void;
55
debug(...args: unknown[]): void;
66
error(...args: unknown[]): void;

0 commit comments

Comments
 (0)