eslint-config-webpack 4.15.0 → 5.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +48 -4
- package/configs/browser.js +70 -7
- package/configs/index.js +7 -6
- package/configs/javascript.js +746 -151
- package/configs/json.js +72 -0
- package/configs/markdown.js +111 -6
- package/configs/node.js +78 -23
- package/configs/performance.js +8 -0
- package/configs/react.js +7 -19
- package/configs/stylistic.js +17 -0
- package/configs/{jest.js → test.js} +65 -5
- package/configs/typescript.js +39 -10
- package/configs/utils/code-files.js +20 -0
- package/configs/utils/get-es-version-from-node.js +9 -4
- package/configs/utils/get-json-file.js +1 -5
- package/configs/utils/is-jest-installed.js +20 -0
- package/configs/utils/is-typescript-installed.js +3 -3
- package/configs.js +47 -31
- package/package.json +31 -26
- package/plugins/package-json/index.js +0 -5
- package/plugins/package-json/rules/order-properties.js +8 -18
- package/plugins/performance/index.js +60 -0
- package/plugins/performance/rules/no-case-insensitive-unicode-range.js +214 -0
- package/plugins/performance/rules/require-precompiled-schema.js +414 -0
- package/plugins/webpack/index.js +0 -1
- package/plugins/webpack/rules/comment-length.js +1 -3
- package/plugins/webpack/rules/format-schema.js +18 -16
- package/plugins/webpack/rules/inherit-jsdoc.js +2 -3
- package/plugins/webpack/rules/no-duplicate-import-tag.js +3 -4
- package/plugins/webpack/rules/no-unused-import-tag.js +8 -11
- package/plugins/webpack/rules/prefer-import-tag.js +1 -2
- package/plugins/webpack/rules/require-license-comment.js +3 -5
- package/plugins/webpack/rules/valid-schema.js +9 -13
- package/plugins/webpack/utils/import-tags.js +4 -3
- package/configs/package-json.js +0 -8
package/configs/typescript.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import webpackPlugin from "../plugins/webpack/index.js";
|
|
1
2
|
import {
|
|
2
3
|
javascriptExtensions,
|
|
3
4
|
typescriptExtensions,
|
|
@@ -54,6 +55,10 @@ async function getTypescriptJSDocRecommendedConfig() {
|
|
|
54
55
|
overrideReplacesDocs: false,
|
|
55
56
|
},
|
|
56
57
|
},
|
|
58
|
+
plugins: {
|
|
59
|
+
...jsdocConfig.plugins,
|
|
60
|
+
webpack: webpackPlugin,
|
|
61
|
+
},
|
|
57
62
|
rules: {
|
|
58
63
|
...jsdocConfig.rules,
|
|
59
64
|
|
|
@@ -171,8 +176,13 @@ async function getTypescriptJSDocRecommendedConfig() {
|
|
|
171
176
|
// types of `@throws` and `@yields`, so those go unchecked
|
|
172
177
|
"jsdoc/no-undefined-types": "off",
|
|
173
178
|
|
|
174
|
-
//
|
|
175
|
-
// "jsdoc/
|
|
179
|
+
// Needs type information (the `typescript-eslint` parser with a project)
|
|
180
|
+
// "jsdoc/no-unnecessary-type-assertion": "error",
|
|
181
|
+
|
|
182
|
+
"jsdoc/normalize-see-links": "error",
|
|
183
|
+
|
|
184
|
+
// We have own rule
|
|
185
|
+
"jsdoc/prefer-import-tag": "off",
|
|
176
186
|
|
|
177
187
|
"jsdoc/reject-any-type": "error",
|
|
178
188
|
|
|
@@ -280,6 +290,9 @@ async function getTypescriptJSDocRecommendedConfig() {
|
|
|
280
290
|
// No need
|
|
281
291
|
// "jsdoc/text-escaping": "error",
|
|
282
292
|
|
|
293
|
+
// From recommended
|
|
294
|
+
// "jsdoc/ts-ban-ts-comment": "error",
|
|
295
|
+
|
|
283
296
|
"jsdoc/type-formatting": [
|
|
284
297
|
"error",
|
|
285
298
|
{
|
|
@@ -293,6 +306,14 @@ async function getTypescriptJSDocRecommendedConfig() {
|
|
|
293
306
|
// Doesn't support function overloading/tuples/`readonly`/module keyword/etc
|
|
294
307
|
// Also `typescript` reports this itself
|
|
295
308
|
"jsdoc/valid-types": "off",
|
|
309
|
+
|
|
310
|
+
// `@import` tags, see `plugins/webpack`
|
|
311
|
+
|
|
312
|
+
"webpack/prefer-import-tag": "error",
|
|
313
|
+
|
|
314
|
+
"webpack/no-duplicate-import-tag": "error",
|
|
315
|
+
|
|
316
|
+
"webpack/no-unused-import-tag": "error",
|
|
296
317
|
},
|
|
297
318
|
};
|
|
298
319
|
}
|
|
@@ -323,8 +344,7 @@ async function getTypescriptRecommendedConfig() {
|
|
|
323
344
|
tsconfigJson.compilerOptions.strict) ||
|
|
324
345
|
true;
|
|
325
346
|
|
|
326
|
-
const
|
|
327
|
-
const { configs } = typescriptPlugin;
|
|
347
|
+
const { configs } = (await import("typescript-eslint")).default;
|
|
328
348
|
/** @type {import("eslint").Linter.Config} */
|
|
329
349
|
const baseConfig = configs.base;
|
|
330
350
|
/** @type {import("eslint").Linter.Config} */
|
|
@@ -363,15 +383,15 @@ async function getTypescriptRecommendedConfig() {
|
|
|
363
383
|
...baseConfig.plugins,
|
|
364
384
|
},
|
|
365
385
|
settings: {
|
|
366
|
-
"import/extensions": allExtensions,
|
|
367
|
-
"import/external-module-folders": [
|
|
386
|
+
"import-x/extensions": allExtensions,
|
|
387
|
+
"import-x/external-module-folders": [
|
|
368
388
|
"node_modules",
|
|
369
389
|
"node_modules/@types",
|
|
370
390
|
],
|
|
371
|
-
"import/parsers": {
|
|
391
|
+
"import-x/parsers": {
|
|
372
392
|
"@typescript-eslint/parser": typescriptExtensions,
|
|
373
393
|
},
|
|
374
|
-
"import/resolver": {
|
|
394
|
+
"import-x/resolver": {
|
|
375
395
|
node: {
|
|
376
396
|
extensions: allExtensions,
|
|
377
397
|
},
|
|
@@ -507,6 +527,9 @@ async function getTypescriptRecommendedConfig() {
|
|
|
507
527
|
// No need
|
|
508
528
|
// "@typescript-eslint/no-for-in-array": "error",
|
|
509
529
|
|
|
530
|
+
// No need
|
|
531
|
+
// "@typescript-eslint/no-generated-empty-object-type": "error",
|
|
532
|
+
|
|
510
533
|
// No need
|
|
511
534
|
// "@typescript-eslint/no-implied-eval": "error",
|
|
512
535
|
|
|
@@ -538,6 +561,9 @@ async function getTypescriptRecommendedConfig() {
|
|
|
538
561
|
// No need
|
|
539
562
|
// "@typescript-eslint/no-misused-promises": "error",
|
|
540
563
|
|
|
564
|
+
// No need
|
|
565
|
+
// "@typescript-eslint/no-misused-promises": "error",
|
|
566
|
+
|
|
541
567
|
// No need
|
|
542
568
|
// "@typescript-eslint/no-misused-spread": "error",
|
|
543
569
|
|
|
@@ -621,6 +647,9 @@ async function getTypescriptRecommendedConfig() {
|
|
|
621
647
|
// From recommended
|
|
622
648
|
// "@typescript-eslint/no-unsafe-declaration-merging": "error",
|
|
623
649
|
|
|
650
|
+
// No need
|
|
651
|
+
// "@typescript-eslint/no-unsafe-enum-assignment": "error",
|
|
652
|
+
|
|
624
653
|
// No need
|
|
625
654
|
// "@typescript-eslint/no-unsafe-enum-comparison": "error",
|
|
626
655
|
|
|
@@ -791,10 +820,10 @@ async function getTypescriptRecommendedConfig() {
|
|
|
791
820
|
// "use-unknown-in-catch-callback-variable": "error",
|
|
792
821
|
|
|
793
822
|
// TypeScript compilation already ensures that named imports exist in the referenced module
|
|
794
|
-
"import/named": "off",
|
|
823
|
+
"import-x/named": "off",
|
|
795
824
|
|
|
796
825
|
// TypeScript handles this for us
|
|
797
|
-
"import/no-unresolved": "off",
|
|
826
|
+
"import-x/no-unresolved": "off",
|
|
798
827
|
},
|
|
799
828
|
},
|
|
800
829
|
isStrict
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { allExtensions, javascriptExtensions } from "./extensions.js";
|
|
2
|
+
import isTypescriptInstalled from "./is-typescript-installed.js";
|
|
3
|
+
|
|
4
|
+
const extensions = isTypescriptInstalled()
|
|
5
|
+
? allExtensions
|
|
6
|
+
: javascriptExtensions;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The files the JavaScript config lints. Configs with JavaScript rules or
|
|
10
|
+
* language options use it as `files` (with `codeIgnores`), so they apply to
|
|
11
|
+
* the same files and not to other languages linted in the same run, such as
|
|
12
|
+
* Markdown.
|
|
13
|
+
*/
|
|
14
|
+
const codeFiles = [
|
|
15
|
+
`**/*.{${extensions.map((extension) => extension.slice(1)).join(",")}}`,
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
const codeIgnores = ["**/*.d.ts"];
|
|
19
|
+
|
|
20
|
+
export { codeFiles, codeIgnores, extensions as codeExtensions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import semver from "semver";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
* @typedef {2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025} EsVersion
|
|
4
|
+
* @typedef {2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 | 2024 | 2025 | 2026} EsVersion
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -18,11 +18,16 @@ import semver from "semver";
|
|
|
18
18
|
* @type {ReadonlyArray<{ range: string, esVersion: EsVersion }>}
|
|
19
19
|
*/
|
|
20
20
|
const ranges = [
|
|
21
|
+
// ECMAScript 2026 (ES17): Node 25.0 introduces practical built-in utilities to replace common boilerplate,
|
|
22
|
+
// including native Base64/Hex conversion for Uint8Array, Array.fromAsync(), and Map.prototype.getOrInsert().
|
|
23
|
+
// It also adds Math.sumPrecise() for accurate floating-point addition, Error.isError() for cross-realm checks, Iterator.concat(),
|
|
24
|
+
// and raw source text access in JSON.
|
|
25
|
+
{ range: ">=25.0.0", esVersion: 2026 },
|
|
21
26
|
// ES2025: Node 22.0 ships all ES2025 syntax — import attributes
|
|
22
27
|
// (`with { type: "json" }`), the RegExp `/v` flag, and duplicate named
|
|
23
|
-
// capturing groups.
|
|
24
|
-
//
|
|
25
|
-
//
|
|
28
|
+
// capturing groups. Its standard library has a gap: no Node 22 release has
|
|
29
|
+
// `Promise.try`, and no `eslint-plugin-n` rule reports it, so
|
|
30
|
+
// `unicorn/prefer-promise-try` is gated at ES2026 in `configs/javascript.js`.
|
|
26
31
|
{ range: ">=22.0.0", esVersion: 2025 },
|
|
27
32
|
// ES2023: Array-by-copy (toSorted/toReversed/toSpliced/with), findLast/findLastIndex.
|
|
28
33
|
{ range: ">=20.0.0", esVersion: 2023 },
|
|
@@ -70,11 +70,7 @@ function readJsonFile(dir, filename) {
|
|
|
70
70
|
const text = fs.readFileSync(filePath, "utf8");
|
|
71
71
|
const data = JSON.parse(text);
|
|
72
72
|
|
|
73
|
-
if (
|
|
74
|
-
data !== null &&
|
|
75
|
-
typeof data === "object" &&
|
|
76
|
-
Array.isArray(data) === false
|
|
77
|
-
) {
|
|
73
|
+
if (data !== null && typeof data === "object" && !Array.isArray(data)) {
|
|
78
74
|
data.filePath = filePath;
|
|
79
75
|
return data;
|
|
80
76
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import getJsonFile from "./get-json-file.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* @returns {boolean} true when jest is supported by project, otherwise false
|
|
5
|
+
*/
|
|
6
|
+
function isTypescriptInstalled() {
|
|
7
|
+
/** @type {import("type-fest").PackageJson | null} */
|
|
8
|
+
const packageJson = getJsonFile("package.json");
|
|
9
|
+
|
|
10
|
+
if (packageJson === null) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const dependencies = packageJson.dependencies || {};
|
|
15
|
+
const devDependencies = packageJson.devDependencies || {};
|
|
16
|
+
|
|
17
|
+
return dependencies.jest !== undefined || devDependencies.jest !== undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default isTypescriptInstalled;
|
|
@@ -14,9 +14,9 @@ function isTypescriptInstalled() {
|
|
|
14
14
|
const dependencies = packageJson.dependencies || {};
|
|
15
15
|
const devDependencies = packageJson.devDependencies || {};
|
|
16
16
|
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
return (
|
|
18
|
+
dependencies.typescript !== undefined ||
|
|
19
|
+
devDependencies.typescript !== undefined
|
|
20
20
|
);
|
|
21
21
|
}
|
|
22
22
|
|
package/configs.js
CHANGED
|
@@ -3,6 +3,7 @@ import semver from "semver";
|
|
|
3
3
|
import configs from "./configs/index.js";
|
|
4
4
|
import getEsVersionFromNode from "./configs/utils/get-es-version-from-node.js";
|
|
5
5
|
import getJsonFile from "./configs/utils/get-json-file.js";
|
|
6
|
+
import isJestInstalled from "./configs/utils/is-jest-installed.js";
|
|
6
7
|
import ignorePaths from "./ignore-paths.js";
|
|
7
8
|
|
|
8
9
|
const packageJson = getJsonFile("package.json");
|
|
@@ -69,6 +70,7 @@ function getJavascriptConfig() {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
const javascriptConfig = getJavascriptConfig();
|
|
73
|
+
const isJestIntalled = isJestInstalled();
|
|
72
74
|
|
|
73
75
|
const recommended = [
|
|
74
76
|
globalIgnores(ignorePaths),
|
|
@@ -79,15 +81,16 @@ const recommended = [
|
|
|
79
81
|
configs["typescript/jsdoc"],
|
|
80
82
|
configs["typescript/recommended"],
|
|
81
83
|
configs["react/recommended"],
|
|
82
|
-
|
|
84
|
+
isJestIntalled
|
|
85
|
+
? configs["jest/recommended"]
|
|
86
|
+
: configs["node-test/recommended"],
|
|
87
|
+
configs["json/recommended"],
|
|
83
88
|
configs["markdown/recommended"],
|
|
84
89
|
configs["stylistic/recommended"],
|
|
85
|
-
configs["
|
|
90
|
+
configs["performance/recommended"],
|
|
86
91
|
];
|
|
87
92
|
|
|
88
|
-
// TODO remove me in the next major release
|
|
89
93
|
configs.recommended = recommended;
|
|
90
|
-
|
|
91
94
|
configs["node-recommended"] = recommended;
|
|
92
95
|
|
|
93
96
|
const nodeRecommendedModule = [
|
|
@@ -97,15 +100,15 @@ const nodeRecommendedModule = [
|
|
|
97
100
|
configs["typescript/jsdoc"],
|
|
98
101
|
configs["typescript/recommended"],
|
|
99
102
|
configs["react/recommended"],
|
|
100
|
-
|
|
103
|
+
isJestIntalled
|
|
104
|
+
? configs["jest/recommended"]
|
|
105
|
+
: configs["node-test/recommended"],
|
|
106
|
+
configs["json/recommended"],
|
|
101
107
|
configs["markdown/recommended"],
|
|
102
108
|
configs["stylistic/recommended"],
|
|
103
|
-
configs["
|
|
109
|
+
configs["performance/recommended"],
|
|
104
110
|
];
|
|
105
111
|
|
|
106
|
-
// TODO remove me in the next major release
|
|
107
|
-
configs["recommended-module"] = nodeRecommendedModule;
|
|
108
|
-
|
|
109
112
|
configs["node-recommended-module"] = nodeRecommendedModule;
|
|
110
113
|
|
|
111
114
|
const nodeRecommendedCommonJS = [
|
|
@@ -115,15 +118,15 @@ const nodeRecommendedCommonJS = [
|
|
|
115
118
|
configs["typescript/jsdoc"],
|
|
116
119
|
configs["typescript/recommended"],
|
|
117
120
|
configs["react/recommended"],
|
|
118
|
-
|
|
121
|
+
isJestIntalled
|
|
122
|
+
? configs["jest/recommended"]
|
|
123
|
+
: configs["node-test/recommended"],
|
|
124
|
+
configs["json/recommended"],
|
|
119
125
|
configs["markdown/recommended"],
|
|
120
126
|
configs["stylistic/recommended"],
|
|
121
|
-
configs["
|
|
127
|
+
configs["performance/recommended"],
|
|
122
128
|
];
|
|
123
129
|
|
|
124
|
-
// TODO remove me in the next major release
|
|
125
|
-
configs["recommended-commonjs"] = nodeRecommendedCommonJS;
|
|
126
|
-
|
|
127
130
|
configs["node-recommended-commonjs"] = nodeRecommendedCommonJS;
|
|
128
131
|
|
|
129
132
|
const nodeRecommendedDirty = [
|
|
@@ -133,13 +136,14 @@ const nodeRecommendedDirty = [
|
|
|
133
136
|
configs["typescript/jsdoc"],
|
|
134
137
|
configs["typescript/recommended"],
|
|
135
138
|
configs["react/recommended"],
|
|
136
|
-
|
|
139
|
+
isJestIntalled
|
|
140
|
+
? configs["jest/recommended"]
|
|
141
|
+
: configs["node-test/recommended"],
|
|
142
|
+
configs["json/recommended"],
|
|
137
143
|
configs["markdown/recommended"],
|
|
138
144
|
configs["stylistic/recommended"],
|
|
139
|
-
configs["
|
|
145
|
+
configs["performance/recommended"],
|
|
140
146
|
];
|
|
141
|
-
// TODO remove me in the next major release
|
|
142
|
-
configs["recommended-dirty"] = nodeRecommendedDirty;
|
|
143
147
|
|
|
144
148
|
configs["node-recommended-dirty"] = nodeRecommendedDirty;
|
|
145
149
|
|
|
@@ -150,10 +154,13 @@ const browserRecommended = [
|
|
|
150
154
|
configs["typescript/jsdoc"],
|
|
151
155
|
configs["typescript/recommended"],
|
|
152
156
|
configs["react/recommended"],
|
|
153
|
-
|
|
157
|
+
isJestIntalled
|
|
158
|
+
? configs["jest/recommended"]
|
|
159
|
+
: configs["node-test/recommended"],
|
|
160
|
+
configs["json/recommended"],
|
|
154
161
|
configs["markdown/recommended"],
|
|
155
162
|
configs["stylistic/recommended"],
|
|
156
|
-
configs["
|
|
163
|
+
configs["performance/recommended"],
|
|
157
164
|
];
|
|
158
165
|
|
|
159
166
|
configs["browser-recommended"] = browserRecommended;
|
|
@@ -165,10 +172,13 @@ const browserOutdatedRecommendedScript = [
|
|
|
165
172
|
configs["typescript/jsdoc"],
|
|
166
173
|
configs["typescript/recommended"],
|
|
167
174
|
configs["react/recommended"],
|
|
168
|
-
|
|
175
|
+
isJestIntalled
|
|
176
|
+
? configs["jest/recommended"]
|
|
177
|
+
: configs["node-test/recommended"],
|
|
178
|
+
configs["json/recommended"],
|
|
169
179
|
configs["markdown/recommended"],
|
|
170
180
|
configs["stylistic/recommended"],
|
|
171
|
-
configs["
|
|
181
|
+
configs["performance/recommended"],
|
|
172
182
|
];
|
|
173
183
|
|
|
174
184
|
configs["browser-outdated-recommended-script"] =
|
|
@@ -181,10 +191,13 @@ const browserOutdatedRecommendedCommonjs = [
|
|
|
181
191
|
configs["typescript/jsdoc"],
|
|
182
192
|
configs["typescript/recommended"],
|
|
183
193
|
configs["react/recommended"],
|
|
184
|
-
|
|
194
|
+
isJestIntalled
|
|
195
|
+
? configs["jest/recommended"]
|
|
196
|
+
: configs["node-test/recommended"],
|
|
197
|
+
configs["json/recommended"],
|
|
185
198
|
configs["markdown/recommended"],
|
|
186
199
|
configs["stylistic/recommended"],
|
|
187
|
-
configs["
|
|
200
|
+
configs["performance/recommended"],
|
|
188
201
|
];
|
|
189
202
|
|
|
190
203
|
configs["browser-outdated-recommended-commonjs"] =
|
|
@@ -202,15 +215,15 @@ const browserOutdatedRecommendedModule = [
|
|
|
202
215
|
configs["typescript/jsdoc"],
|
|
203
216
|
configs["typescript/recommended"],
|
|
204
217
|
configs["react/recommended"],
|
|
205
|
-
|
|
218
|
+
isJestIntalled
|
|
219
|
+
? configs["jest/recommended"]
|
|
220
|
+
: configs["node-test/recommended"],
|
|
221
|
+
configs["json/recommended"],
|
|
206
222
|
configs["markdown/recommended"],
|
|
207
223
|
configs["stylistic/recommended"],
|
|
208
|
-
configs["
|
|
224
|
+
configs["performance/recommended"],
|
|
209
225
|
];
|
|
210
226
|
|
|
211
|
-
// TODO remove in the next major release
|
|
212
|
-
configs["browser-outdated-recommended"] = browserOutdatedRecommendedModule;
|
|
213
|
-
|
|
214
227
|
configs["browser-outdated-recommended-module"] =
|
|
215
228
|
browserOutdatedRecommendedModule;
|
|
216
229
|
|
|
@@ -224,10 +237,13 @@ const universalRecommended = [
|
|
|
224
237
|
configs["typescript/jsdoc"],
|
|
225
238
|
configs["typescript/recommended"],
|
|
226
239
|
configs["react/recommended"],
|
|
227
|
-
|
|
240
|
+
isJestIntalled
|
|
241
|
+
? configs["jest/recommended"]
|
|
242
|
+
: configs["node-test/recommended"],
|
|
243
|
+
configs["json/recommended"],
|
|
228
244
|
configs["markdown/recommended"],
|
|
229
245
|
configs["stylistic/recommended"],
|
|
230
|
-
configs["
|
|
246
|
+
configs["performance/recommended"],
|
|
231
247
|
];
|
|
232
248
|
|
|
233
249
|
configs["universal-recommended"] = universalRecommended;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "eslint-config-webpack",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Provides Webpack's eslint rules as an extensible shared config",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"eslint",
|
|
@@ -38,45 +38,50 @@
|
|
|
38
38
|
"fmt": "prettier --cache --write .",
|
|
39
39
|
"fmt:check": "prettier --cache --check .",
|
|
40
40
|
"test": "cd test && node --test",
|
|
41
|
+
"rules:not-enabled": "node scripts/find-not-enabled-rules.js",
|
|
42
|
+
"test:webpack": "node scripts/test-on-webpack.js",
|
|
41
43
|
"version": "changeset version",
|
|
42
44
|
"release": "changeset publish"
|
|
43
45
|
},
|
|
44
46
|
"dependencies": {
|
|
45
|
-
"@eslint/
|
|
46
|
-
"@eslint/
|
|
47
|
-
"@
|
|
47
|
+
"@eslint-community/eslint-utils": "^4.10.1",
|
|
48
|
+
"@eslint-community/regexpp": "^4.12.2",
|
|
49
|
+
"@eslint-react/eslint-plugin": "^5.30.5",
|
|
50
|
+
"@eslint/js": "^10.0.1",
|
|
51
|
+
"@eslint/json": "^2.1.1",
|
|
52
|
+
"@eslint/markdown": "^9.0.0",
|
|
53
|
+
"@stylistic/eslint-plugin": "^6.0.1",
|
|
48
54
|
"detect-indent": "^7.0.2",
|
|
49
55
|
"eslint-config-prettier": "^10.1.8",
|
|
50
|
-
"eslint-
|
|
51
|
-
"eslint-plugin-
|
|
52
|
-
"eslint-plugin-
|
|
53
|
-
"eslint-plugin-
|
|
54
|
-
"eslint-plugin-
|
|
55
|
-
"eslint-plugin-
|
|
56
|
+
"eslint-node-test": "^1.0.1",
|
|
57
|
+
"eslint-plugin-import-x": "^4.18.1",
|
|
58
|
+
"eslint-plugin-jest": "^29.17.0",
|
|
59
|
+
"eslint-plugin-jsdoc": "^65.5.0",
|
|
60
|
+
"eslint-plugin-n": "^18.3.0",
|
|
61
|
+
"eslint-plugin-prettier": "^5.5.7",
|
|
56
62
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
57
|
-
"eslint-plugin-unicorn": "^
|
|
58
|
-
"globals": "^17.
|
|
59
|
-
"jsonc-eslint-parser": "^3.
|
|
63
|
+
"eslint-plugin-unicorn": "^80.0.0",
|
|
64
|
+
"globals": "^17.14.0",
|
|
65
|
+
"jsonc-eslint-parser": "^3.3.0",
|
|
60
66
|
"semver": "^7.8.0",
|
|
61
67
|
"sort-package-json": "^4.0.0",
|
|
62
|
-
"typescript-eslint": "^8.
|
|
68
|
+
"typescript-eslint": "^8.72.1"
|
|
63
69
|
},
|
|
64
70
|
"devDependencies": {
|
|
65
71
|
"@changesets/cli": "^3.0.2",
|
|
66
|
-
"@changesets/get-github-info": "^0.
|
|
67
|
-
"@types/semver": "^7.
|
|
68
|
-
"eslint": "^
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"react": "^19.
|
|
73
|
-
"
|
|
74
|
-
"type-fest": "^5.6.0",
|
|
72
|
+
"@changesets/get-github-info": "^1.0.1",
|
|
73
|
+
"@types/semver": "^7.8.0",
|
|
74
|
+
"eslint": "^10.15.0",
|
|
75
|
+
"jest": "^30.5.2",
|
|
76
|
+
"prettier": "^3.9.10",
|
|
77
|
+
"react": "^19.3.1",
|
|
78
|
+
"react-dom": "^19.3.1",
|
|
79
|
+
"type-fest": "^6.0.3",
|
|
75
80
|
"typescript": "^6.0.3"
|
|
76
81
|
},
|
|
77
82
|
"peerDependencies": {
|
|
78
|
-
"eslint": ">=
|
|
79
|
-
"typescript": ">=
|
|
83
|
+
"eslint": ">= 10.15.0",
|
|
84
|
+
"typescript": ">=5.0.0 <8.0.0"
|
|
80
85
|
},
|
|
81
86
|
"peerDependenciesMeta": {
|
|
82
87
|
"typescript": {
|
|
@@ -84,6 +89,6 @@
|
|
|
84
89
|
}
|
|
85
90
|
},
|
|
86
91
|
"engines": {
|
|
87
|
-
"node": ">=
|
|
92
|
+
"node": "^22.11.0 || >=24.0.0"
|
|
88
93
|
}
|
|
89
94
|
}
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { createRequire } from "node:module";
|
|
2
|
-
// eslint-disable-next-line import/no-unresolved
|
|
3
|
-
import * as parserJsonc from "jsonc-eslint-parser";
|
|
4
2
|
import { rule as orderProperties } from "./rules/order-properties.js";
|
|
5
3
|
|
|
6
4
|
const require = createRequire(import.meta.url);
|
|
@@ -25,9 +23,6 @@ const configs = {
|
|
|
25
23
|
recommended: {
|
|
26
24
|
name: "package-json/recommended",
|
|
27
25
|
files: ["**/package.json"],
|
|
28
|
-
languageOptions: {
|
|
29
|
-
parser: parserJsonc,
|
|
30
|
-
},
|
|
31
26
|
plugins: {
|
|
32
27
|
get "package-json"() {
|
|
33
28
|
// eslint-disable-next-line no-use-before-define
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import detectIndent from "detect-indent";
|
|
2
2
|
import { sortOrder } from "sort-package-json";
|
|
3
3
|
|
|
4
|
-
/** @typedef {import("jsonc-eslint-parser").AST.JSONProgram} JSONProgram */
|
|
5
|
-
/** @typedef {import("jsonc-eslint-parser").AST.JSONExpression} JSONExpression */
|
|
6
|
-
/** @typedef {import("jsonc-eslint-parser").AST.JSONObjectExpression} JSONObjectExpression */
|
|
7
|
-
|
|
8
4
|
/**
|
|
9
5
|
* @param {string} string string
|
|
10
6
|
* @returns {"\r\n" | "\n" | undefined} detected newline
|
|
@@ -34,7 +30,7 @@ function detectNewlineGraceful(string) {
|
|
|
34
30
|
return detectNewline(string) || "\n";
|
|
35
31
|
}
|
|
36
32
|
|
|
37
|
-
/** @
|
|
33
|
+
/** @import { PackageJson } from "type-fest" */
|
|
38
34
|
|
|
39
35
|
/**
|
|
40
36
|
* @param {PackageJson} object object to sort
|
|
@@ -94,7 +90,7 @@ export const rule = {
|
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
return {
|
|
97
|
-
"
|
|
93
|
+
"Document:exit"() {
|
|
98
94
|
const { ast, text } = context.sourceCode;
|
|
99
95
|
|
|
100
96
|
const options = {
|
|
@@ -115,17 +111,12 @@ export const rule = {
|
|
|
115
111
|
]);
|
|
116
112
|
const orderedKeys = Object.keys(orderedSource);
|
|
117
113
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
(
|
|
121
|
-
/** @type {JSONProgram} */ (/** @type {unknown} */ (ast)).body[0]
|
|
122
|
-
.expression
|
|
123
|
-
);
|
|
114
|
+
// @ts-expect-error bad types
|
|
115
|
+
const { members } = ast.body;
|
|
124
116
|
|
|
125
|
-
for (let i = 0; i <
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
const { value } = property;
|
|
117
|
+
for (let i = 0; i < members.length; i += 1) {
|
|
118
|
+
// Strict JSON parsing guarantees that keys are always string literals
|
|
119
|
+
const { value } = members[i].name;
|
|
129
120
|
|
|
130
121
|
if (value === orderedKeys[i]) {
|
|
131
122
|
continue;
|
|
@@ -151,7 +142,7 @@ export const rule = {
|
|
|
151
142
|
|
|
152
143
|
return fixer.replaceText(context.sourceCode.ast, result);
|
|
153
144
|
},
|
|
154
|
-
loc:
|
|
145
|
+
loc: members[i].loc,
|
|
155
146
|
messageId: "incorrectOrder",
|
|
156
147
|
});
|
|
157
148
|
}
|
|
@@ -160,7 +151,6 @@ export const rule = {
|
|
|
160
151
|
},
|
|
161
152
|
meta: {
|
|
162
153
|
docs: {
|
|
163
|
-
category: "Best Practices",
|
|
164
154
|
description: "Package properties must be declared in standard order",
|
|
165
155
|
recommended: true,
|
|
166
156
|
},
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
import {
|
|
3
|
+
allExtensions,
|
|
4
|
+
javascriptExtensions,
|
|
5
|
+
} from "../../configs/utils/extensions.js";
|
|
6
|
+
import isTypescriptInstalled from "../../configs/utils/is-typescript-installed.js";
|
|
7
|
+
import { rule as noCaseInsensitiveUnicodeRange } from "./rules/no-case-insensitive-unicode-range.js";
|
|
8
|
+
import { rule as requirePrecompiledSchema } from "./rules/require-precompiled-schema.js";
|
|
9
|
+
|
|
10
|
+
const require = createRequire(import.meta.url);
|
|
11
|
+
|
|
12
|
+
const { version } = require("../../package.json");
|
|
13
|
+
|
|
14
|
+
const rules = {
|
|
15
|
+
"no-case-insensitive-unicode-range": noCaseInsensitiveUnicodeRange,
|
|
16
|
+
"require-precompiled-schema": requirePrecompiledSchema,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
/** @type {import("eslint").Linter.Config["rules"]} */
|
|
20
|
+
const recommendedRules = {
|
|
21
|
+
...Object.fromEntries(
|
|
22
|
+
Object.entries(rules)
|
|
23
|
+
.filter(([, rule]) => rule.meta?.docs?.recommended)
|
|
24
|
+
.map(([name]) => [`performance/${name}`, "error"]),
|
|
25
|
+
),
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Only the files the javascript config lints, so a project without TypeScript
|
|
29
|
+
// doesn't parse `.ts` files with the default parser.
|
|
30
|
+
const extensions = isTypescriptInstalled()
|
|
31
|
+
? allExtensions
|
|
32
|
+
: javascriptExtensions;
|
|
33
|
+
|
|
34
|
+
/** @type {Record<"recommended", import("eslint").Linter.Config>} */
|
|
35
|
+
const configs = {
|
|
36
|
+
recommended: {
|
|
37
|
+
name: "performance/recommended",
|
|
38
|
+
files: [`**/*.{${extensions.map((item) => item.slice(1)).join(",")}}`],
|
|
39
|
+
ignores: ["**/*.d.ts"],
|
|
40
|
+
plugins: {
|
|
41
|
+
get performance() {
|
|
42
|
+
// eslint-disable-next-line no-use-before-define
|
|
43
|
+
return plugin;
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
rules: recommendedRules,
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const plugin = {
|
|
51
|
+
configs,
|
|
52
|
+
meta: {
|
|
53
|
+
version,
|
|
54
|
+
},
|
|
55
|
+
rules,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export { configs, rules };
|
|
59
|
+
|
|
60
|
+
export default plugin;
|