Skip to content

Commit 00c75dc

Browse files
chore: eslint migration (#636)
1 parent c46400a commit 00c75dc

39 files changed

+11762
-8151
lines changed

.cspell.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
"minifier",
3636
"filebase",
3737
"toplevel",
38-
"commitlint"
38+
"commitlint",
39+
"tapable"
3940
],
40-
4141
"ignorePaths": [
4242
"CHANGELOG.md",
4343
"package.json",

.eslintignore

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

.eslintrc.js

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

.github/workflows/nodejs.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,14 @@ jobs:
9999
architecture: ${{ steps.calculate_architecture.outputs.result }}
100100
cache: "npm"
101101

102+
- name: Install dependencies (old)
103+
run: |
104+
npm install -D typescript@4 --force
105+
if: matrix.node-version == '10.x' || matrix.node-version == '12.x' || matrix.node-version == '14.x' || matrix.node-version == '16.x' || matrix.node-version == '18.x'
106+
102107
- name: Install dependencies
103108
run: npm ci
109+
if: matrix.node-version != '10.x' && matrix.node-version != '12.x' && matrix.node-version != '14.x' && matrix.node-version != '16.x' && matrix.node-version != '18.x'
104110

105111
- name: Install webpack ${{ matrix.webpack-version }}
106112
if: matrix.webpack-version != 'latest'

README.md

Lines changed: 30 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Using supported `devtool` values enable source map generation.
8282
Type:
8383

8484
```ts
85-
type test = string | RegExp | Array<string | RegExp>;
85+
type test = string | RegExp | (string | RegExp)[];
8686
```
8787

8888
Default: `/\.m?js(\?.*)?$/i`
@@ -109,7 +109,7 @@ module.exports = {
109109
Type:
110110

111111
```ts
112-
type include = string | RegExp | Array<string | RegExp>;
112+
type include = string | RegExp | (string | RegExp)[];
113113
```
114114

115115
Default: `undefined`
@@ -136,7 +136,7 @@ module.exports = {
136136
Type:
137137

138138
```ts
139-
type exclude = string | RegExp | Array<string | RegExp>;
139+
type exclude = string | RegExp | (string | RegExp)[];
140140
```
141141

142142
Default: `undefined`
@@ -224,9 +224,7 @@ Type:
224224

225225
```ts
226226
type minify = (
227-
input: {
228-
[file: string]: string;
229-
},
227+
input: Record<string, string>,
230228
sourceMap: import("@jridgewell/trace-mapping").SourceMapInput | undefined,
231229
minifyOptions: {
232230
module?: boolean | undefined;
@@ -245,7 +243,7 @@ type minify = (
245243
pos: number;
246244
line: number;
247245
col: number;
248-
}
246+
},
249247
) => boolean)
250248
| {
251249
condition?:
@@ -261,7 +259,7 @@ type minify = (
261259
pos: number;
262260
line: number;
263261
col: number;
264-
}
262+
},
265263
) => boolean)
266264
| undefined;
267265
filename?: string | ((fileData: any) => string) | undefined;
@@ -271,7 +269,7 @@ type minify = (
271269
| ((commentsFile: string) => string)
272270
| undefined;
273271
}
274-
| undefined
272+
| undefined,
275273
) => Promise<{
276274
code: string;
277275
map?: import("@jridgewell/trace-mapping").SourceMapInput | undefined;
@@ -316,7 +314,6 @@ minify.getMinimizerVersion = () => {
316314
let packageJson;
317315

318316
try {
319-
// eslint-disable-next-line global-require, import/no-extraneous-dependencies
320317
packageJson = require("uglify-module/package.json");
321318
} catch (error) {
322319
// Ignore
@@ -345,7 +342,7 @@ module.exports = {
345342
Type:
346343

347344
```ts
348-
type terserOptions = {
345+
interface terserOptions {
349346
compress?: boolean | CompressOptions;
350347
ecma?: ECMA;
351348
enclose?: boolean | string;
@@ -362,7 +359,7 @@ type terserOptions = {
362359
safari10?: boolean;
363360
sourceMap?: boolean | SourceMapOptions;
364361
toplevel?: boolean;
365-
};
362+
}
366363
```
367364

368365
Default: [default](https://github.com/terser/terser#minify-options)
@@ -416,7 +413,7 @@ type extractComments =
416413
pos: number;
417414
line: number;
418415
col: number;
419-
}
416+
},
420417
) => boolean)
421418
| {
422419
condition?:
@@ -432,7 +429,7 @@ type extractComments =
432429
pos: number;
433430
line: number;
434431
col: number;
435-
}
432+
},
436433
) => boolean)
437434
| undefined;
438435
filename?: string | ((fileData: any) => string) | undefined;
@@ -550,13 +547,11 @@ module.exports = {
550547
new TerserPlugin({
551548
extractComments: {
552549
condition: /^\**!|@preserve|@license|@cc_on/i,
553-
filename: (fileData) => {
550+
filename: (fileData) =>
554551
// The "fileData" argument contains object with "filename", "basename", "query" and "hash"
555-
return `${fileData.filename}.LICENSE.txt${fileData.query}`;
556-
},
557-
banner: (licenseFile) => {
558-
return `License information can be found in ${licenseFile}`;
559-
},
552+
`${fileData.filename}.LICENSE.txt${fileData.query}`,
553+
banner: (licenseFile) =>
554+
`License information can be found in ${licenseFile}`,
560555
},
561556
}),
562557
],
@@ -582,7 +577,7 @@ type condition =
582577
pos: number;
583578
line: number;
584579
col: number;
585-
}
580+
},
586581
) => boolean)
587582
| undefined;
588583
```
@@ -599,13 +594,11 @@ module.exports = {
599594
new TerserPlugin({
600595
extractComments: {
601596
condition: "some",
602-
filename: (fileData) => {
597+
filename: (fileData) =>
603598
// The "fileData" argument contains object with "filename", "basename", "query" and "hash"
604-
return `${fileData.filename}.LICENSE.txt${fileData.query}`;
605-
},
606-
banner: (licenseFile) => {
607-
return `License information can be found in ${licenseFile}`;
608-
},
599+
`${fileData.filename}.LICENSE.txt${fileData.query}`,
600+
banner: (licenseFile) =>
601+
`License information can be found in ${licenseFile}`,
609602
},
610603
}),
611604
],
@@ -644,9 +637,8 @@ module.exports = {
644637
extractComments: {
645638
condition: /^\**!|@preserve|@license|@cc_on/i,
646639
filename: "extracted-comments.js",
647-
banner: (licenseFile) => {
648-
return `License information can be found in ${licenseFile}`;
649-
},
640+
banner: (licenseFile) =>
641+
`License information can be found in ${licenseFile}`,
650642
},
651643
}),
652644
],
@@ -680,13 +672,11 @@ module.exports = {
680672
new TerserPlugin({
681673
extractComments: {
682674
condition: true,
683-
filename: (fileData) => {
675+
filename: (fileData) =>
684676
// The "fileData" argument contains object with "filename", "basename", "query" and "hash"
685-
return `${fileData.filename}.LICENSE.txt${fileData.query}`;
686-
},
687-
banner: (commentsFile) => {
688-
return `My custom banner about license information ${commentsFile}`;
689-
},
677+
`${fileData.filename}.LICENSE.txt${fileData.query}`,
678+
banner: (commentsFile) =>
679+
`My custom banner about license information ${commentsFile}`,
690680
},
691681
}),
692682
],
@@ -879,10 +869,10 @@ module.exports = {
879869
With built-in minify functions:
880870

881871
```ts
882-
import type { JsMinifyOptions as SwcOptions } from "@swc/core";
883-
import type { MinifyOptions as UglifyJSOptions } from "uglify-js";
884-
import type { TransformOptions as EsbuildOptions } from "esbuild";
885-
import type { MinifyOptions as TerserOptions } from "terser";
872+
import { type JsMinifyOptions as SwcOptions } from "@swc/core";
873+
import { type TransformOptions as EsbuildOptions } from "esbuild";
874+
import { type MinifyOptions as TerserOptions } from "terser";
875+
import { type MinifyOptions as UglifyJSOptions } from "uglify-js";
886876

887877
module.exports = {
888878
optimization: {

eslint.config.mjs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { defineConfig } from "eslint/config";
2+
import configs from "eslint-config-webpack/configs.js";
3+
4+
export default defineConfig([
5+
{
6+
extends: [configs["recommended-dirty"]],
7+
},
8+
]);

0 commit comments

Comments
 (0)