eslint 9.17.0 → 9.19.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 +27 -8
- package/lib/cli.js +11 -4
- package/lib/config/config-loader.js +9 -22
- package/lib/config/flat-config-schema.js +16 -1
- package/lib/eslint/eslint.js +2 -5
- package/lib/linter/linter.js +74 -5
- package/lib/options.js +13 -0
- package/lib/rules/arrow-body-style.js +1 -0
- package/lib/rules/camelcase.js +1 -0
- package/lib/rules/capitalized-comments.js +1 -0
- package/lib/rules/consistent-this.js +1 -0
- package/lib/rules/curly.js +1 -0
- package/lib/rules/default-case-last.js +2 -2
- package/lib/rules/default-param-last.js +1 -0
- package/lib/rules/dot-notation.js +1 -0
- package/lib/rules/func-name-matching.js +1 -0
- package/lib/rules/func-style.js +1 -0
- package/lib/rules/id-denylist.js +1 -0
- package/lib/rules/id-length.js +1 -0
- package/lib/rules/id-match.js +1 -0
- package/lib/rules/init-declarations.js +1 -0
- package/lib/rules/logical-assignment-operators.js +1 -0
- package/lib/rules/no-console.js +3 -1
- package/lib/rules/no-continue.js +1 -0
- package/lib/rules/no-div-regex.js +1 -0
- package/lib/rules/no-else-return.js +1 -0
- package/lib/rules/no-extra-boolean-cast.js +1 -0
- package/lib/rules/no-extra-label.js +1 -0
- package/lib/rules/no-implicit-coercion.js +1 -0
- package/lib/rules/no-inline-comments.js +1 -0
- package/lib/rules/no-label-var.js +1 -0
- package/lib/rules/no-labels.js +1 -0
- package/lib/rules/no-lonely-if.js +1 -0
- package/lib/rules/no-magic-numbers.js +1 -0
- package/lib/rules/no-multi-str.js +1 -0
- package/lib/rules/no-negated-condition.js +1 -0
- package/lib/rules/no-nested-ternary.js +1 -0
- package/lib/rules/no-plusplus.js +1 -0
- package/lib/rules/no-shadow-restricted-names.js +17 -7
- package/lib/rules/no-ternary.js +1 -0
- package/lib/rules/no-undef-init.js +1 -0
- package/lib/rules/no-undefined.js +1 -0
- package/lib/rules/no-underscore-dangle.js +1 -0
- package/lib/rules/no-unneeded-ternary.js +1 -0
- package/lib/rules/no-useless-computed-key.js +1 -0
- package/lib/rules/no-useless-concat.js +1 -0
- package/lib/rules/no-void.js +1 -0
- package/lib/rules/no-warning-comments.js +1 -0
- package/lib/rules/object-shorthand.js +1 -0
- package/lib/rules/one-var.js +1 -0
- package/lib/rules/operator-assignment.js +1 -0
- package/lib/rules/prefer-arrow-callback.js +1 -0
- package/lib/rules/prefer-destructuring.js +1 -0
- package/lib/rules/prefer-exponentiation-operator.js +1 -0
- package/lib/rules/prefer-numeric-literals.js +1 -0
- package/lib/rules/prefer-object-spread.js +1 -0
- package/lib/rules/prefer-spread.js +1 -0
- package/lib/rules/prefer-template.js +1 -0
- package/lib/rules/sort-imports.js +3 -2
- package/lib/rules/sort-keys.js +1 -0
- package/lib/rules/sort-vars.js +1 -0
- package/lib/rules/vars-on-top.js +1 -0
- package/lib/rules/yoda.js +1 -0
- package/lib/shared/flags.js +3 -3
- package/lib/shared/option-utils.js +56 -0
- package/lib/types/index.d.ts +7 -1
- package/lib/types/rules/best-practices.d.ts +109 -95
- package/lib/types/rules/deprecated.d.ts +32 -15
- package/lib/types/rules/ecmascript-6.d.ts +39 -39
- package/lib/types/rules/node-commonjs.d.ts +23 -12
- package/lib/types/rules/possible-errors.d.ts +86 -54
- package/lib/types/rules/strict-mode.d.ts +1 -1
- package/lib/types/rules/stylistic-issues.d.ts +105 -99
- package/lib/types/rules/variables.d.ts +12 -12
- package/package.json +8 -6
package/lib/rules/no-labels.js
CHANGED
package/lib/rules/no-plusplus.js
CHANGED
@@ -45,17 +45,27 @@ module.exports = {
|
|
45
45
|
const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]);
|
46
46
|
const sourceCode = context.sourceCode;
|
47
47
|
|
48
|
+
// Track reported nodes to avoid duplicate reports. For example, on class declarations.
|
49
|
+
const reportedNodes = new Set();
|
50
|
+
|
48
51
|
return {
|
49
|
-
"VariableDeclaration, :function, CatchClause"(node) {
|
52
|
+
"VariableDeclaration, :function, CatchClause, ImportDeclaration, ClassDeclaration, ClassExpression"(node) {
|
50
53
|
for (const variable of sourceCode.getDeclaredVariables(node)) {
|
51
54
|
if (variable.defs.length > 0 && RESTRICTED.has(variable.name) && !safelyShadowsUndefined(variable)) {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
55
|
+
for (const def of variable.defs) {
|
56
|
+
const nodeToReport = def.name;
|
57
|
+
|
58
|
+
if (!reportedNodes.has(nodeToReport)) {
|
59
|
+
reportedNodes.add(nodeToReport);
|
60
|
+
context.report({
|
61
|
+
node: nodeToReport,
|
62
|
+
messageId: "shadowingRestrictedName",
|
63
|
+
data: {
|
64
|
+
name: variable.name
|
65
|
+
}
|
66
|
+
});
|
57
67
|
}
|
58
|
-
}
|
68
|
+
}
|
59
69
|
}
|
60
70
|
}
|
61
71
|
}
|
package/lib/rules/no-ternary.js
CHANGED
package/lib/rules/no-void.js
CHANGED
package/lib/rules/one-var.js
CHANGED
@@ -47,6 +47,7 @@ module.exports = {
|
|
47
47
|
docs: {
|
48
48
|
description: "Disallow `parseInt()` and `Number.parseInt()` in favor of binary, octal, and hexadecimal literals",
|
49
49
|
recommended: false,
|
50
|
+
frozen: true,
|
50
51
|
url: "https://eslint.org/docs/latest/rules/prefer-numeric-literals"
|
51
52
|
},
|
52
53
|
|
@@ -248,6 +248,7 @@ module.exports = {
|
|
248
248
|
description:
|
249
249
|
"Disallow using `Object.assign` with an object literal as the first argument and prefer the use of object spread instead",
|
250
250
|
recommended: false,
|
251
|
+
frozen: true,
|
251
252
|
url: "https://eslint.org/docs/latest/rules/prefer-object-spread"
|
252
253
|
},
|
253
254
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @fileoverview Rule to
|
2
|
+
* @fileoverview Rule to enforce sorted `import` declarations within modules
|
3
3
|
* @author Christian Schuller
|
4
4
|
*/
|
5
5
|
|
@@ -23,8 +23,9 @@ module.exports = {
|
|
23
23
|
}],
|
24
24
|
|
25
25
|
docs: {
|
26
|
-
description: "Enforce sorted import declarations within modules",
|
26
|
+
description: "Enforce sorted `import` declarations within modules",
|
27
27
|
recommended: false,
|
28
|
+
frozen: true,
|
28
29
|
url: "https://eslint.org/docs/latest/rules/sort-imports"
|
29
30
|
},
|
30
31
|
|
package/lib/rules/sort-keys.js
CHANGED
package/lib/rules/sort-vars.js
CHANGED
package/lib/rules/vars-on-top.js
CHANGED
package/lib/rules/yoda.js
CHANGED
package/lib/shared/flags.js
CHANGED
@@ -10,8 +10,7 @@
|
|
10
10
|
*/
|
11
11
|
const activeFlags = new Map([
|
12
12
|
["test_only", "Used only for testing."],
|
13
|
-
["unstable_config_lookup_from_file", "Look up `eslint.config.js` from the file being linted."]
|
14
|
-
["unstable_ts_config", "Enable TypeScript configuration files."]
|
13
|
+
["unstable_config_lookup_from_file", "Look up `eslint.config.js` from the file being linted."]
|
15
14
|
]);
|
16
15
|
|
17
16
|
/**
|
@@ -19,7 +18,8 @@ const activeFlags = new Map([
|
|
19
18
|
* @type {Map<string, string>}
|
20
19
|
*/
|
21
20
|
const inactiveFlags = new Map([
|
22
|
-
["test_only_old", "Used only for testing."]
|
21
|
+
["test_only_old", "Used only for testing."],
|
22
|
+
["unstable_ts_config", "This flag is no longer required to enable TypeScript configuration files."]
|
23
23
|
]);
|
24
24
|
|
25
25
|
module.exports = {
|
@@ -0,0 +1,56 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Utilities to operate on option objects.
|
3
|
+
* @author Josh Goldberg
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Determines whether any of input's properties are different
|
10
|
+
* from values that already exist in original.
|
11
|
+
* @template T
|
12
|
+
* @param {Partial<T>} input New value.
|
13
|
+
* @param {T} original Original value.
|
14
|
+
* @returns {boolean} Whether input includes an explicit difference.
|
15
|
+
*/
|
16
|
+
function containsDifferentProperty(input, original) {
|
17
|
+
if (input === original) {
|
18
|
+
return false;
|
19
|
+
}
|
20
|
+
|
21
|
+
if (
|
22
|
+
typeof input !== typeof original ||
|
23
|
+
Array.isArray(input) !== Array.isArray(original)
|
24
|
+
) {
|
25
|
+
return true;
|
26
|
+
}
|
27
|
+
|
28
|
+
if (Array.isArray(input)) {
|
29
|
+
return (
|
30
|
+
input.length !== original.length ||
|
31
|
+
input.some((value, i) =>
|
32
|
+
containsDifferentProperty(value, original[i]))
|
33
|
+
);
|
34
|
+
}
|
35
|
+
|
36
|
+
if (typeof input === "object") {
|
37
|
+
if (input === null || original === null) {
|
38
|
+
return true;
|
39
|
+
}
|
40
|
+
|
41
|
+
const inputKeys = Object.keys(input);
|
42
|
+
const originalKeys = Object.keys(original);
|
43
|
+
|
44
|
+
return inputKeys.length !== originalKeys.length || inputKeys.some(
|
45
|
+
inputKey =>
|
46
|
+
!Object.hasOwn(original, inputKey) ||
|
47
|
+
containsDifferentProperty(input[inputKey], original[inputKey])
|
48
|
+
);
|
49
|
+
}
|
50
|
+
|
51
|
+
return true;
|
52
|
+
}
|
53
|
+
|
54
|
+
module.exports = {
|
55
|
+
containsDifferentProperty
|
56
|
+
};
|
package/lib/types/index.d.ts
CHANGED
@@ -1371,6 +1371,12 @@ export namespace Linter {
|
|
1371
1371
|
* tracked and reported.
|
1372
1372
|
*/
|
1373
1373
|
reportUnusedDisableDirectives?: Severity | StringSeverity | boolean;
|
1374
|
+
|
1375
|
+
/**
|
1376
|
+
* A severity value indicating if and how unused inline configs should be
|
1377
|
+
* tracked and reported.
|
1378
|
+
*/
|
1379
|
+
reportUnusedInlineConfigs?: Severity | StringSeverity;
|
1374
1380
|
}
|
1375
1381
|
|
1376
1382
|
interface Stats {
|
@@ -1484,7 +1490,7 @@ export namespace ESLint {
|
|
1484
1490
|
allowInlineConfig?: boolean | undefined;
|
1485
1491
|
baseConfig?: Linter.Config | Linter.Config[] | null | undefined;
|
1486
1492
|
overrideConfig?: Linter.Config | Linter.Config[] | null | undefined;
|
1487
|
-
overrideConfigFile?: string |
|
1493
|
+
overrideConfigFile?: string | true | null | undefined;
|
1488
1494
|
plugins?: Record<string, Plugin> | null | undefined;
|
1489
1495
|
ruleFilter?: ((arg: { ruleId: string; severity: Exclude<Linter.Severity, 0> }) => boolean) | undefined;
|
1490
1496
|
stats?: boolean | undefined;
|