Skip to content

Commit 264b229

Browse files
chore: migrate to eslint-config-webpack (#4481)
1 parent 93dd096 commit 264b229

File tree

225 files changed

+3358
-1843
lines changed

Some content is hidden

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

225 files changed

+3358
-1843
lines changed

.cspell.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
"**/yarn.lock",
117117
"**/*.png.tpl",
118118
"**/package-lock.json",
119+
"packages/*/lib/**",
119120
"node_modules",
120121
"coverage",
121122
"*.log"

.eslintignore

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

.eslintrc.js

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

eslint.config.mjs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { globalIgnores, defineConfig } from "eslint/config";
2+
import config from "eslint-config-webpack";
3+
import configs from "eslint-config-webpack/configs.js";
4+
5+
export default defineConfig([
6+
globalIgnores([
7+
"packages/*/lib/**/*",
8+
"test/**/dist/**/*",
9+
"test/**/bin/**/*",
10+
"test/**/binary/**/*",
11+
"test/**/index.js",
12+
"test/build/config/error-commonjs/syntax-error.js",
13+
"test/build/config/error-mjs/syntax-error.mjs",
14+
"test/build/config/error-array/webpack.config.js",
15+
"test/build/config-format/esm-require-await/webpack.config.js",
16+
"test/configtest/with-config-path/syntax-error.config.js",
17+
"test/build/config-format/esm-require/webpack.config.js",
18+
]),
19+
{
20+
extends: [config],
21+
ignores: ["./packages/create-webpack-app/**/*"],
22+
rules: {
23+
// We are CLI, so using `console.log` is normal
24+
"no-console": "off",
25+
strict: "off",
26+
},
27+
},
28+
{
29+
files: ["./packages/create-webpack-app/**/*"],
30+
extends: [configs["recommended-module"]],
31+
rules: {
32+
// We are CLI, so using `console.log` is normal
33+
"no-console": "off",
34+
},
35+
},
36+
]);

package.json

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@
3232
"build": "tsc --build",
3333
"build:ci": "tsc --build",
3434
"watch": "tsc --build --watch",
35-
"lint:prettier": "prettier --cache --list-different .",
36-
"lint:eslint": "eslint --cache --ext .js --ext .ts .",
37-
"lint:spelling": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
38-
"lint": "yarn lint:eslint && yarn lint:prettier && yarn lint:spelling",
39-
"fix": "yarn lint:eslint --fix && yarn lint:prettier --write",
35+
"lint": "yarn lint:code && yarn lint:spellcheck",
36+
"lint:code": "eslint --cache .",
37+
"lint:spellcheck": "cspell --cache --no-must-find-files --quiet \"**/*.*\"",
38+
"fmt": "yarn fmt:base --log-level warn --write",
39+
"fmt:check": "yarn fmt:base --check",
40+
"fmt:base": "prettier --cache --ignore-unknown .",
41+
"fix": "yarn fix:code",
42+
"fix:code": "yarn lint:code --fix",
4043
"pretest": "yarn build && yarn lint",
4144
"test": "jest --reporters=default",
4245
"test:smoketests": "nyc node smoketests",
@@ -56,32 +59,40 @@
5659
"@babel/core": "^7.25.2",
5760
"@babel/preset-env": "^7.25.2",
5861
"@babel/register": "^7.15.8",
62+
"@eslint/js": "^9.28.0",
63+
"@eslint/markdown": "^6.6.0",
5964
"@commitlint/cli": "^19.4.0",
6065
"@commitlint/config-conventional": "^19.2.2",
66+
"@stylistic/eslint-plugin": "^5.0.0",
6167
"@types/jest": "^29.5.13",
6268
"@types/node": "^22.5.5",
6369
"@types/rechoir": "^0.6.1",
64-
"@typescript-eslint/eslint-plugin": "^8.6.0",
65-
"@typescript-eslint/parser": "^8.6.0",
6670
"coffeescript": "^2.7.0",
6771
"colorette": "^2.0.16",
6872
"concat-stream": "^2.0.0",
6973
"cspell": "^8.3.2",
7074
"css-loader": "^7.1.2",
7175
"del-cli": "^6.0.0",
72-
"eslint": "^8.57.1",
73-
"eslint-config-prettier": "^9.1.0",
74-
"eslint-plugin-n": "^17.10.2",
76+
"eslint": "^9.29.0",
77+
"eslint-config-webpack": "^4.1.4",
78+
"eslint-config-prettier": "^10.1.5",
79+
"eslint-plugin-import": "^2.32.0",
80+
"eslint-plugin-jest": "^29.0.1",
81+
"eslint-plugin-jsdoc": "^51.2.3",
82+
"eslint-plugin-n": "^17.19.0",
83+
"eslint-plugin-prettier": "^5.4.1",
84+
"eslint-plugin-unicorn": "^59.0.1",
7585
"execa": "^5.0.0",
7686
"get-port": "^5.1.1",
87+
"globals": "^16.2.0",
7788
"husky": "^9.1.4",
7889
"jest": "^29.4.1",
7990
"jest-watch-typeahead": "^2.2.2",
8091
"lerna": "^8.1.8",
8192
"lint-staged": "^15.2.9",
8293
"mini-css-extract-plugin": "^2.6.1",
8394
"nyc": "^17.1.0",
84-
"prettier": "^3.3.3",
95+
"prettier": "^3.6.0",
8596
"readable-stream": "^4.5.2",
8697
"sass": "^1.54.9",
8798
"sass-loader": "^16.0.2",
@@ -91,6 +102,7 @@
91102
"ts-loader": "^9.3.1",
92103
"ts-node": "^10.9.1",
93104
"typescript": "^5.0.4",
105+
"typescript-eslint": "^8.35.0",
94106
"webpack": "^5.99.1",
95107
"webpack-bundle-analyzer": "^4.5.0",
96108
"webpack-dev-server": "^5.1.0"

packages/configtest/src/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@ class ConfigTestCommand {
2020
const configPaths = new Set<string>();
2121

2222
if (Array.isArray(config.options)) {
23-
config.options.forEach((options) => {
23+
for (const options of config.options) {
2424
const loadedConfigPaths = config.path.get(options);
2525

2626
if (loadedConfigPaths) {
27-
loadedConfigPaths.forEach((path) => configPaths.add(path));
27+
for (const path of loadedConfigPaths) configPaths.add(path);
2828
}
29-
});
29+
}
3030
} else if (config.path.get(config.options)) {
3131
const loadedConfigPaths = config.path.get(config.options);
3232

3333
if (loadedConfigPaths) {
34-
loadedConfigPaths.forEach((path) => configPaths.add(path));
34+
for (const path of loadedConfigPaths) configPaths.add(path);
3535
}
3636
}
3737

@@ -40,7 +40,7 @@ class ConfigTestCommand {
4040
process.exit(2);
4141
}
4242

43-
cli.logger.info(`Validate '${Array.from(configPaths).join(" ,")}'.`);
43+
cli.logger.info(`Validate '${[...configPaths].join(" ,")}'.`);
4444

4545
try {
4646
cli.webpack.validate(config.options);
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
#!/usr/bin/env node
22

3-
//eslint-disable-next-line
4-
import * as cli from "../lib/index.js";
3+
import "../lib/index.js";

packages/create-webpack-app/src/generators/init/default.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { type Answers, type ActionType, type FileRecord } from "../../types";
1+
import { type Answers, type ActionType, type FileRecord } from "../../types.js";
22
import { type NodePlopAPI, type DynamicActionsFunction } from "node-plop";
3-
import { dirname, join, resolve } from "path";
4-
import { fileURLToPath } from "url";
3+
import { dirname, join, resolve } from "node:path";
4+
import { fileURLToPath } from "node:url";
55

6-
export default async function (plop: NodePlopAPI) {
6+
export default async function defaultInitGenerator(plop: NodePlopAPI) {
77
const __dirname = dirname(fileURLToPath(import.meta.url));
88

99
// dependencies to be installed
10-
const devDependencies: Array<string> = ["webpack", "webpack-cli"];
10+
const devDependencies: string[] = ["webpack", "webpack-cli"];
1111

1212
await plop.load("../../utils/install-dependencies.js", {}, true);
1313
await plop.load("../../utils/generate-files.js", {}, true);
@@ -74,7 +74,7 @@ export default async function (plop: NodePlopAPI) {
7474
type: "confirm",
7575
name: "isPostCSS",
7676
message: "Do you want to use PostCSS in your project?",
77-
default: (answers: Answers) => answers.cssType == "CSS only",
77+
default: (answers: Answers) => answers.cssType === "CSS only",
7878
},
7979
{
8080
type: "list",
@@ -97,7 +97,7 @@ export default async function (plop: NodePlopAPI) {
9797
},
9898
},
9999
],
100-
actions: function (answers: Answers) {
100+
actions: function actions(answers: Answers) {
101101
const actions: ActionType[] = [];
102102

103103
switch (answers.langType) {
@@ -147,7 +147,7 @@ export default async function (plop: NodePlopAPI) {
147147
devDependencies.push("mini-css-extract-plugin");
148148
}
149149

150-
const files: Array<FileRecord> = [
150+
const files: FileRecord[] = [
151151
{ filePath: "./index.html", fileType: "text" },
152152
{ filePath: "webpack.config.js", fileType: "text" },
153153
{ filePath: "package.json", fileType: "text" },

packages/create-webpack-app/src/generators/init/react.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { type Answers, type ActionType, type FileRecord } from "../../types";
1+
import { type Answers, type ActionType, type FileRecord } from "../../types.js";
22
import { type NodePlopAPI, type DynamicActionsFunction } from "node-plop";
3-
import { dirname, resolve, join } from "path";
4-
import { fileURLToPath } from "url";
3+
import { dirname, resolve, join } from "node:path";
4+
import { fileURLToPath } from "node:url";
55

6-
export default async function (plop: NodePlopAPI) {
6+
export default async function reactInitGenerator(plop: NodePlopAPI) {
77
const __dirname = dirname(fileURLToPath(import.meta.url));
88

99
// dependencies to be installed
10-
const devDependencies: Array<string> = [
10+
const devDependencies: string[] = [
1111
"webpack",
1212
"webpack-cli",
1313
"react@18",
@@ -77,7 +77,7 @@ export default async function (plop: NodePlopAPI) {
7777
type: "confirm",
7878
name: "isPostCSS",
7979
message: "Do you want to use PostCSS in your project?",
80-
default: (answers: Answers) => answers.cssType == "CSS only",
80+
default: (answers: Answers) => answers.cssType === "CSS only",
8181
},
8282
{
8383
type: "list",
@@ -100,7 +100,7 @@ export default async function (plop: NodePlopAPI) {
100100
},
101101
},
102102
],
103-
actions: function (answers: Answers) {
103+
actions: function actions(answers: Answers) {
104104
// setting some default values based on the answers
105105
const actions: ActionType[] = [];
106106
answers.htmlWebpackPlugin = true;
@@ -149,7 +149,7 @@ export default async function (plop: NodePlopAPI) {
149149
devDependencies.push("workbox-webpack-plugin");
150150
}
151151

152-
const files: Array<FileRecord> = [
152+
const files: FileRecord[] = [
153153
{ filePath: "./index.html", fileType: "text" },
154154
{ filePath: "webpack.config.js", fileType: "text" },
155155
{ filePath: "package.json", fileType: "text" },

packages/create-webpack-app/src/generators/init/svelte.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import { type Answers, type ActionType, type FileRecord } from "../../types";
1+
import { type Answers, type ActionType, type FileRecord } from "../../types.js";
22
import { type NodePlopAPI, type DynamicActionsFunction } from "node-plop";
3-
import { dirname, join, resolve } from "path";
4-
import { fileURLToPath } from "url";
3+
import { dirname, join, resolve } from "node:path";
4+
import { fileURLToPath } from "node:url";
55

6-
export default async function (plop: NodePlopAPI) {
6+
export default async function svelteInitGenerator(plop: NodePlopAPI) {
77
const __dirname = dirname(fileURLToPath(import.meta.url));
88

99
// dependencies to be installed
10-
const devDependencies: Array<string> = [
10+
const devDependencies: string[] = [
1111
"webpack",
1212
"webpack-cli",
1313
"svelte",
@@ -68,7 +68,7 @@ export default async function (plop: NodePlopAPI) {
6868
type: "confirm",
6969
name: "isPostCSS",
7070
message: "Do you want to use PostCSS in your project?",
71-
default: (answers: Answers) => answers.cssType == "CSS only",
71+
default: (answers: Answers) => answers.cssType === "CSS only",
7272
},
7373
{
7474
type: "list",
@@ -91,7 +91,7 @@ export default async function (plop: NodePlopAPI) {
9191
},
9292
},
9393
],
94-
actions: function (answers: Answers) {
94+
actions: function actions(answers: Answers) {
9595
// setting some default values based on the answers
9696
const actions: ActionType[] = [];
9797
answers.htmlWebpackPlugin = true;
@@ -140,7 +140,7 @@ export default async function (plop: NodePlopAPI) {
140140
devDependencies.push("mini-css-extract-plugin");
141141
}
142142

143-
const files: Array<FileRecord> = [
143+
const files: FileRecord[] = [
144144
{ filePath: "./index.html", fileType: "text" },
145145
{ filePath: "./src/assets/webpack.png", fileType: "binary" },
146146
{ filePath: "webpack.config.js", fileType: "text" },

0 commit comments

Comments
 (0)