Skip to content

Commit 39ebae6

Browse files
committed
refactor: rename files to match convention (#693)
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 paradigm and feels unnatural.
1 parent f7dfdcf commit 39ebae6

File tree

107 files changed

+499
-412
lines changed

Some content is hidden

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

107 files changed

+499
-412
lines changed

README.md

Lines changed: 1 addition & 1 deletion
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>

release.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ module.exports = {
3232
[
3333
'@semantic-release/exec',
3434
{
35-
prepareCmd:
36-
"sed -i 's/{{VERSION}}/${nextRelease.version}/g' lib/ForkTsCheckerWebpackPlugin.js",
35+
prepareCmd: "sed -i 's/{{VERSION}}/${nextRelease.version}/g' lib/plugin.js",
3736
},
3837
],
3938
],

src/ForkTsCheckerWebpackPluginConfiguration.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/files-change.ts

Lines changed: 28 additions & 16 deletions
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[] = [];
34-
35-
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-
);
35+
const changedFilesSet = new Set<string>();
36+
const deletedFilesSet = new Set<string>();
37+
38+
for (const { changedFiles = [], deletedFiles = [] } of changes) {
39+
for (const changedFile of changedFiles) {
40+
changedFilesSet.add(changedFile);
41+
deletedFilesSet.delete(changedFile);
42+
}
43+
for (const deletedFile of 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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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 {
Lines changed: 9 additions & 11 deletions
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
}
@@ -23,16 +21,16 @@ function createFormatterConfiguration(
2321
}
2422

2523
if (type === 'codeframe') {
26-
const configuration =
24+
const config =
2725
options && typeof options === 'object'
2826
? (options as CodeframeFormatterOptions).options || {}
2927
: {};
30-
return createCodeFrameFormatter(configuration);
28+
return createCodeFrameFormatter(config);
3129
}
3230

3331
throw new Error(
3432
`Unknown "${type}" formatter. Available types are: "basic", "codeframe" or a custom function.`
3533
);
3634
}
3735

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

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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 6 additions & 6 deletions
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';

0 commit comments

Comments
 (0)