eslint-config-webpack 4.15.0 → 5.0.1
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 +70 -11
- 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
|
@@ -52,11 +52,13 @@ function processSchema(visitor, json, context) {
|
|
|
52
52
|
if (visitor.schema) json = visitor.schema(json, context);
|
|
53
53
|
|
|
54
54
|
for (const name of NESTED_WITH_NAME) {
|
|
55
|
-
if (name in json && json[name] && typeof json[name] === "object") {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
if (!(name in json && json[name] && typeof json[name] === "object")) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (visitor.object) json[name] = visitor.object(json[name], context);
|
|
60
|
+
for (const key of Object.keys(json[name])) {
|
|
61
|
+
json[name][key] = processSchema(visitor, json[name][key], context);
|
|
60
62
|
}
|
|
61
63
|
}
|
|
62
64
|
for (const name of NESTED_DIRECT) {
|
|
@@ -65,13 +67,15 @@ function processSchema(visitor, json, context) {
|
|
|
65
67
|
}
|
|
66
68
|
}
|
|
67
69
|
for (const name of NESTED_ARRAY) {
|
|
68
|
-
if (name in json && Array.isArray(json[name])) {
|
|
69
|
-
|
|
70
|
-
for (let i = 0; i < json[name].length; i++) {
|
|
71
|
-
json[name][i] = processSchema(visitor, json[name][i], context);
|
|
72
|
-
}
|
|
73
|
-
if (visitor.array) json[name] = visitor.array(json[name], context);
|
|
70
|
+
if (!(name in json && Array.isArray(json[name]))) {
|
|
71
|
+
continue;
|
|
74
72
|
}
|
|
73
|
+
|
|
74
|
+
json[name] = [...json[name]];
|
|
75
|
+
for (let i = 0; i < json[name].length; i++) {
|
|
76
|
+
json[name][i] = processSchema(visitor, json[name][i], context);
|
|
77
|
+
}
|
|
78
|
+
if (visitor.array) json[name] = visitor.array(json[name], context);
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
return json;
|
|
@@ -100,10 +104,9 @@ function sortArrayByType(array) {
|
|
|
100
104
|
const bType = b.type || b.instanceof || (b.enum && "enum");
|
|
101
105
|
const aPosition = TYPE_ORDER.indexOf(aType);
|
|
102
106
|
const bPosition = TYPE_ORDER.indexOf(bType);
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
return aPosition - bPosition;
|
|
107
|
+
return aPosition === bPosition
|
|
108
|
+
? array.indexOf(a) - array.indexOf(b)
|
|
109
|
+
: aPosition - bPosition;
|
|
107
110
|
});
|
|
108
111
|
}
|
|
109
112
|
|
|
@@ -311,7 +314,6 @@ export const rule = {
|
|
|
311
314
|
},
|
|
312
315
|
meta: {
|
|
313
316
|
docs: {
|
|
314
|
-
category: "Stylistic Issues",
|
|
315
317
|
description:
|
|
316
318
|
"Keep schema keys ordered and shared definitions in sync with the base schema",
|
|
317
319
|
recommended: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** @typedef {import("eslint").Rule.RuleFixer} RuleFixer */
|
|
2
2
|
/** @typedef {import("eslint").Rule.Fix} Fix */
|
|
3
|
-
/** @
|
|
3
|
+
/** @import { MethodDefinition } from "estree" */
|
|
4
4
|
|
|
5
5
|
// The TypeScript AST is reached through the parser services, which type them as
|
|
6
6
|
// `unknown` outside a TypeScript-aware parser.
|
|
@@ -34,7 +34,7 @@ function rewriteJSDoc(text, indent, stripTags) {
|
|
|
34
34
|
return lines
|
|
35
35
|
.filter(
|
|
36
36
|
(line, index) =>
|
|
37
|
-
index === 0 ||
|
|
37
|
+
index === 0 || [...stripped].every((regexp) => !regexp.test(line)),
|
|
38
38
|
)
|
|
39
39
|
.map((line, index) =>
|
|
40
40
|
index === 0 ? line : `${indent} ${line.trimStart()}`,
|
|
@@ -174,7 +174,6 @@ export const rule = {
|
|
|
174
174
|
},
|
|
175
175
|
meta: {
|
|
176
176
|
docs: {
|
|
177
|
-
category: "Best Practices",
|
|
178
177
|
description:
|
|
179
178
|
"Require a method to carry the JSDoc of the method it overrides",
|
|
180
179
|
recommended: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { collectImportTags } from "../utils/import-tags.js";
|
|
2
2
|
|
|
3
|
-
/** @
|
|
3
|
+
/** @import { ImportTag } from "../utils/import-tags.js" */
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Whether two tags could be written as one import statement. A namespace binding
|
|
@@ -23,7 +23,7 @@ const isMergeable = (first, second) => {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
return (
|
|
26
|
-
|
|
26
|
+
heads.every((tag) => !tag.namespace) ||
|
|
27
27
|
first.named.length + second.named.length === 0
|
|
28
28
|
);
|
|
29
29
|
};
|
|
@@ -69,9 +69,8 @@ export const rule = {
|
|
|
69
69
|
},
|
|
70
70
|
meta: {
|
|
71
71
|
docs: {
|
|
72
|
-
category: "Stylistic Issues",
|
|
73
72
|
description: "Require one `@import` per module in a file",
|
|
74
|
-
recommended:
|
|
73
|
+
recommended: false,
|
|
75
74
|
},
|
|
76
75
|
messages: {
|
|
77
76
|
duplicateImportTag:
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { collectImportTags } from "../utils/import-tags.js";
|
|
2
2
|
|
|
3
3
|
/** @typedef {import("eslint").Rule.ReportFixer} ReportFixer */
|
|
4
|
-
/** @
|
|
5
|
-
/** @
|
|
6
|
-
/** @typedef {import("../utils/import-tags.js").ImportTag} ImportTag */
|
|
4
|
+
/** @import { SourceCode } from "eslint" */
|
|
5
|
+
/** @import { ImportBinding, ImportTag } from "../utils/import-tags.js" */
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* The source with every `@import` tag blanked out, so one import can never keep
|
|
@@ -47,11 +46,10 @@ const lineRangeAt = (text, index) => {
|
|
|
47
46
|
const removableCommentRange = (text, tag) => {
|
|
48
47
|
const commentRange = /** @type {[number, number]} */ (tag.comment.range);
|
|
49
48
|
|
|
50
|
-
if (
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (/@\w/.test(text.slice(tag.end, commentRange[1]))) {
|
|
49
|
+
if (
|
|
50
|
+
text.slice(commentRange[0], tag.start).replaceAll(/[/*\s]/g, "") !== "" ||
|
|
51
|
+
/@\w/.test(text.slice(tag.end, commentRange[1]))
|
|
52
|
+
) {
|
|
55
53
|
return null;
|
|
56
54
|
}
|
|
57
55
|
|
|
@@ -102,7 +100,7 @@ const buildFixer = (sourceCode, tag, binding, bindingCount) => {
|
|
|
102
100
|
.toSorted((one, another) => another.end - one.end);
|
|
103
101
|
const strandedComma =
|
|
104
102
|
previous !== undefined &&
|
|
105
|
-
|
|
103
|
+
tag.named.every((other) => !(other.start >= binding.end))
|
|
106
104
|
? text.indexOf(",", previous.end)
|
|
107
105
|
: -1;
|
|
108
106
|
|
|
@@ -178,9 +176,8 @@ export const rule = {
|
|
|
178
176
|
},
|
|
179
177
|
meta: {
|
|
180
178
|
docs: {
|
|
181
|
-
category: "Stylistic Issues",
|
|
182
179
|
description: "Require every `@import` binding to be referenced",
|
|
183
|
-
recommended:
|
|
180
|
+
recommended: false,
|
|
184
181
|
},
|
|
185
182
|
fixable: "code",
|
|
186
183
|
messages: {
|
|
@@ -72,10 +72,9 @@ export const rule = {
|
|
|
72
72
|
},
|
|
73
73
|
meta: {
|
|
74
74
|
docs: {
|
|
75
|
-
category: "Stylistic Issues",
|
|
76
75
|
description:
|
|
77
76
|
"Require `@import` rather than a `@typedef` that only aliases an `import()`",
|
|
78
|
-
recommended:
|
|
77
|
+
recommended: false,
|
|
79
78
|
},
|
|
80
79
|
fixable: "code",
|
|
81
80
|
messages: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @
|
|
1
|
+
/** @import { Comment } from "estree" */
|
|
2
2
|
/** @typedef {import("eslint").AST.SourceLocation} SourceLocation */
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export const rule = {
|
|
8
8
|
create(context) {
|
|
9
|
-
const sourceCode = context
|
|
9
|
+
const { sourceCode } = context;
|
|
10
10
|
|
|
11
11
|
return {
|
|
12
12
|
"Program:exit"(program) {
|
|
@@ -17,7 +17,7 @@ export const rule = {
|
|
|
17
17
|
comments.find(
|
|
18
18
|
(comment) =>
|
|
19
19
|
comment.type === "Block" &&
|
|
20
|
-
/\n\s*MIT License
|
|
20
|
+
/\n\s*MIT License https?:\/\/www\.opensource\.org\/licenses\/mit-license\.php\n\s*(?:(Authors? .+)\n)?\s*/.test(
|
|
21
21
|
comment.value,
|
|
22
22
|
),
|
|
23
23
|
)
|
|
@@ -57,11 +57,9 @@ export const rule = {
|
|
|
57
57
|
},
|
|
58
58
|
meta: {
|
|
59
59
|
docs: {
|
|
60
|
-
category: "Best Practices",
|
|
61
60
|
description: "Require license comment",
|
|
62
61
|
recommended: true,
|
|
63
62
|
},
|
|
64
|
-
fixable: "code",
|
|
65
63
|
type: "layout",
|
|
66
64
|
},
|
|
67
65
|
};
|
|
@@ -26,11 +26,9 @@ function getKeywordName(property) {
|
|
|
26
26
|
* @returns {JSONProperty | undefined} property declaring the keyword
|
|
27
27
|
*/
|
|
28
28
|
function getKeyword(node, name) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
return node.properties.find((property) => getKeywordName(property) === name);
|
|
29
|
+
return !node || node.type !== "JSONObjectExpression"
|
|
30
|
+
? undefined
|
|
31
|
+
: node.properties.find((property) => getKeywordName(property) === name);
|
|
34
32
|
}
|
|
35
33
|
|
|
36
34
|
/**
|
|
@@ -278,16 +276,15 @@ export const rule = {
|
|
|
278
276
|
}
|
|
279
277
|
}
|
|
280
278
|
|
|
281
|
-
if (
|
|
279
|
+
if (!(
|
|
282
280
|
additionalProperties &&
|
|
283
281
|
additionalProperties.value.type === "JSONObjectExpression"
|
|
284
|
-
) {
|
|
285
|
-
|
|
286
|
-
additionalProperties.value,
|
|
287
|
-
additionalProperties.key,
|
|
288
|
-
);
|
|
289
|
-
walk(additionalProperties.value);
|
|
282
|
+
)) {
|
|
283
|
+
return;
|
|
290
284
|
}
|
|
285
|
+
|
|
286
|
+
validateDescription(additionalProperties.value, additionalProperties.key);
|
|
287
|
+
walk(additionalProperties.value);
|
|
291
288
|
}
|
|
292
289
|
|
|
293
290
|
return {
|
|
@@ -308,7 +305,6 @@ export const rule = {
|
|
|
308
305
|
},
|
|
309
306
|
meta: {
|
|
310
307
|
docs: {
|
|
311
|
-
category: "Possible Errors",
|
|
312
308
|
description: "Enforce webpack's conventions for JSON schema files",
|
|
313
309
|
recommended: false,
|
|
314
310
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/** @
|
|
2
|
-
/** @
|
|
1
|
+
/** @import { SourceCode } from "eslint" */
|
|
2
|
+
/** @import { Comment } from "estree" */
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @typedef {object} ImportBinding
|
|
@@ -39,7 +39,8 @@ export const stripLineMarkers = (text) =>
|
|
|
39
39
|
*/
|
|
40
40
|
export const localNameOf = (binding) => {
|
|
41
41
|
const parts = binding.split(/[ \t\n]+as[ \t\n]+/);
|
|
42
|
-
|
|
42
|
+
// `split()` always returns at least one part
|
|
43
|
+
return /** @type {string} */ (parts.at(-1)).trim();
|
|
43
44
|
};
|
|
44
45
|
|
|
45
46
|
/**
|
package/configs/package-json.js
DELETED