eslint 9.29.0 → 9.30.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.
Files changed (88) hide show
  1. package/README.md +1 -1
  2. package/lib/config/config-loader.js +2 -29
  3. package/lib/config/flat-config-array.js +1 -1
  4. package/lib/eslint/eslint.js +1 -1
  5. package/lib/languages/js/source-code/source-code.js +7 -0
  6. package/lib/rules/array-bracket-newline.js +3 -3
  7. package/lib/rules/array-bracket-spacing.js +3 -3
  8. package/lib/rules/array-element-newline.js +3 -3
  9. package/lib/rules/arrow-parens.js +3 -3
  10. package/lib/rules/arrow-spacing.js +3 -3
  11. package/lib/rules/block-spacing.js +3 -3
  12. package/lib/rules/brace-style.js +3 -3
  13. package/lib/rules/comma-dangle.js +3 -3
  14. package/lib/rules/comma-spacing.js +3 -3
  15. package/lib/rules/comma-style.js +3 -3
  16. package/lib/rules/computed-property-spacing.js +3 -3
  17. package/lib/rules/dot-location.js +3 -3
  18. package/lib/rules/eol-last.js +3 -3
  19. package/lib/rules/func-call-spacing.js +3 -3
  20. package/lib/rules/function-call-argument-newline.js +3 -3
  21. package/lib/rules/function-paren-newline.js +3 -3
  22. package/lib/rules/generator-star-spacing.js +3 -3
  23. package/lib/rules/implicit-arrow-linebreak.js +3 -3
  24. package/lib/rules/indent-legacy.js +3 -3
  25. package/lib/rules/indent.js +3 -3
  26. package/lib/rules/jsx-quotes.js +3 -3
  27. package/lib/rules/key-spacing.js +3 -3
  28. package/lib/rules/keyword-spacing.js +3 -3
  29. package/lib/rules/line-comment-position.js +3 -3
  30. package/lib/rules/linebreak-style.js +3 -3
  31. package/lib/rules/lines-around-comment.js +3 -3
  32. package/lib/rules/lines-around-directive.js +3 -3
  33. package/lib/rules/lines-between-class-members.js +3 -3
  34. package/lib/rules/max-len.js +3 -3
  35. package/lib/rules/max-statements-per-line.js +3 -3
  36. package/lib/rules/multiline-comment-style.js +3 -3
  37. package/lib/rules/multiline-ternary.js +3 -3
  38. package/lib/rules/new-parens.js +3 -3
  39. package/lib/rules/newline-after-var.js +3 -3
  40. package/lib/rules/newline-before-return.js +3 -3
  41. package/lib/rules/newline-per-chained-call.js +3 -3
  42. package/lib/rules/no-confusing-arrow.js +3 -3
  43. package/lib/rules/no-duplicate-imports.js +79 -7
  44. package/lib/rules/no-extra-parens.js +3 -3
  45. package/lib/rules/no-extra-semi.js +3 -3
  46. package/lib/rules/no-floating-decimal.js +3 -3
  47. package/lib/rules/no-mixed-operators.js +3 -3
  48. package/lib/rules/no-mixed-spaces-and-tabs.js +3 -3
  49. package/lib/rules/no-multi-spaces.js +3 -3
  50. package/lib/rules/no-multiple-empty-lines.js +3 -3
  51. package/lib/rules/no-restricted-properties.js +11 -2
  52. package/lib/rules/no-spaced-func.js +3 -3
  53. package/lib/rules/no-tabs.js +3 -3
  54. package/lib/rules/no-trailing-spaces.js +3 -3
  55. package/lib/rules/no-unused-vars.js +1 -1
  56. package/lib/rules/no-whitespace-before-property.js +3 -3
  57. package/lib/rules/nonblock-statement-body-position.js +3 -3
  58. package/lib/rules/object-curly-newline.js +3 -3
  59. package/lib/rules/object-curly-spacing.js +3 -3
  60. package/lib/rules/object-property-newline.js +3 -3
  61. package/lib/rules/one-var-declaration-per-line.js +3 -3
  62. package/lib/rules/operator-linebreak.js +3 -3
  63. package/lib/rules/padded-blocks.js +3 -3
  64. package/lib/rules/padding-line-between-statements.js +3 -3
  65. package/lib/rules/quote-props.js +3 -3
  66. package/lib/rules/quotes.js +3 -3
  67. package/lib/rules/rest-spread-spacing.js +3 -3
  68. package/lib/rules/semi-spacing.js +3 -3
  69. package/lib/rules/semi-style.js +3 -3
  70. package/lib/rules/semi.js +3 -3
  71. package/lib/rules/space-before-blocks.js +3 -3
  72. package/lib/rules/space-before-function-paren.js +3 -3
  73. package/lib/rules/space-in-parens.js +3 -3
  74. package/lib/rules/space-infix-ops.js +3 -3
  75. package/lib/rules/space-unary-ops.js +3 -3
  76. package/lib/rules/spaced-comment.js +3 -3
  77. package/lib/rules/switch-colon-spacing.js +3 -3
  78. package/lib/rules/template-curly-spacing.js +3 -3
  79. package/lib/rules/template-tag-spacing.js +3 -3
  80. package/lib/rules/utils/ast-utils.js +45 -0
  81. package/lib/rules/wrap-iife.js +3 -3
  82. package/lib/rules/wrap-regex.js +3 -3
  83. package/lib/rules/yield-star-spacing.js +3 -3
  84. package/lib/shared/flags.js +9 -1
  85. package/lib/shared/runtime-info.js +1 -1
  86. package/lib/types/index.d.ts +7 -0
  87. package/lib/types/rules.d.ts +78 -74
  88. package/package.json +4 -4
@@ -30,12 +30,12 @@ module.exports = {
30
30
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
31
31
  url: "https://eslint.style/guide/migration",
32
32
  plugin: {
33
- name: "@stylistic/eslint-plugin-js",
34
- url: "https://eslint.style/packages/js",
33
+ name: "@stylistic/eslint-plugin",
34
+ url: "https://eslint.style",
35
35
  },
36
36
  rule: {
37
37
  name: "operator-linebreak",
38
- url: "https://eslint.style/rules/js/operator-linebreak",
38
+ url: "https://eslint.style/rules/operator-linebreak",
39
39
  },
40
40
  },
41
41
  ],
@@ -30,12 +30,12 @@ module.exports = {
30
30
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
31
31
  url: "https://eslint.style/guide/migration",
32
32
  plugin: {
33
- name: "@stylistic/eslint-plugin-js",
34
- url: "https://eslint.style/packages/js",
33
+ name: "@stylistic/eslint-plugin",
34
+ url: "https://eslint.style",
35
35
  },
36
36
  rule: {
37
37
  name: "padded-blocks",
38
- url: "https://eslint.style/rules/js/padded-blocks",
38
+ url: "https://eslint.style/rules/padded-blocks",
39
39
  },
40
40
  },
41
41
  ],
@@ -400,12 +400,12 @@ module.exports = {
400
400
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
401
401
  url: "https://eslint.style/guide/migration",
402
402
  plugin: {
403
- name: "@stylistic/eslint-plugin-js",
404
- url: "https://eslint.style/packages/js",
403
+ name: "@stylistic/eslint-plugin",
404
+ url: "https://eslint.style",
405
405
  },
406
406
  rule: {
407
407
  name: "padding-line-between-statements",
408
- url: "https://eslint.style/rules/js/padding-line-between-statements",
408
+ url: "https://eslint.style/rules/padding-line-between-statements",
409
409
  },
410
410
  },
411
411
  ],
@@ -31,12 +31,12 @@ module.exports = {
31
31
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
32
32
  url: "https://eslint.style/guide/migration",
33
33
  plugin: {
34
- name: "@stylistic/eslint-plugin-js",
35
- url: "https://eslint.style/packages/js",
34
+ name: "@stylistic/eslint-plugin",
35
+ url: "https://eslint.style",
36
36
  },
37
37
  rule: {
38
38
  name: "quote-props",
39
- url: "https://eslint.style/rules/js/quote-props",
39
+ url: "https://eslint.style/rules/quote-props",
40
40
  },
41
41
  },
42
42
  ],
@@ -108,12 +108,12 @@ module.exports = {
108
108
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
109
109
  url: "https://eslint.style/guide/migration",
110
110
  plugin: {
111
- name: "@stylistic/eslint-plugin-js",
112
- url: "https://eslint.style/packages/js",
111
+ name: "@stylistic/eslint-plugin",
112
+ url: "https://eslint.style",
113
113
  },
114
114
  rule: {
115
115
  name: "quotes",
116
- url: "https://eslint.style/rules/js/quotes",
116
+ url: "https://eslint.style/rules/quotes",
117
117
  },
118
118
  },
119
119
  ],
@@ -24,12 +24,12 @@ module.exports = {
24
24
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
25
25
  url: "https://eslint.style/guide/migration",
26
26
  plugin: {
27
- name: "@stylistic/eslint-plugin-js",
28
- url: "https://eslint.style/packages/js",
27
+ name: "@stylistic/eslint-plugin",
28
+ url: "https://eslint.style",
29
29
  },
30
30
  rule: {
31
31
  name: "rest-spread-spacing",
32
- url: "https://eslint.style/rules/js/rest-spread-spacing",
32
+ url: "https://eslint.style/rules/rest-spread-spacing",
33
33
  },
34
34
  },
35
35
  ],
@@ -26,12 +26,12 @@ module.exports = {
26
26
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
27
27
  url: "https://eslint.style/guide/migration",
28
28
  plugin: {
29
- name: "@stylistic/eslint-plugin-js",
30
- url: "https://eslint.style/packages/js",
29
+ name: "@stylistic/eslint-plugin",
30
+ url: "https://eslint.style",
31
31
  },
32
32
  rule: {
33
33
  name: "semi-spacing",
34
- url: "https://eslint.style/rules/js/semi-spacing",
34
+ url: "https://eslint.style/rules/semi-spacing",
35
35
  },
36
36
  },
37
37
  ],
@@ -96,12 +96,12 @@ module.exports = {
96
96
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
97
97
  url: "https://eslint.style/guide/migration",
98
98
  plugin: {
99
- name: "@stylistic/eslint-plugin-js",
100
- url: "https://eslint.style/packages/js",
99
+ name: "@stylistic/eslint-plugin",
100
+ url: "https://eslint.style",
101
101
  },
102
102
  rule: {
103
103
  name: "semi-style",
104
- url: "https://eslint.style/rules/js/semi-style",
104
+ url: "https://eslint.style/rules/semi-style",
105
105
  },
106
106
  },
107
107
  ],
package/lib/rules/semi.js CHANGED
@@ -30,12 +30,12 @@ module.exports = {
30
30
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
31
31
  url: "https://eslint.style/guide/migration",
32
32
  plugin: {
33
- name: "@stylistic/eslint-plugin-js",
34
- url: "https://eslint.style/packages/js",
33
+ name: "@stylistic/eslint-plugin",
34
+ url: "https://eslint.style",
35
35
  },
36
36
  rule: {
37
37
  name: "semi",
38
- url: "https://eslint.style/rules/js/semi",
38
+ url: "https://eslint.style/rules/semi",
39
39
  },
40
40
  },
41
41
  ],
@@ -49,12 +49,12 @@ module.exports = {
49
49
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
50
50
  url: "https://eslint.style/guide/migration",
51
51
  plugin: {
52
- name: "@stylistic/eslint-plugin-js",
53
- url: "https://eslint.style/packages/js",
52
+ name: "@stylistic/eslint-plugin",
53
+ url: "https://eslint.style",
54
54
  },
55
55
  rule: {
56
56
  name: "space-before-blocks",
57
- url: "https://eslint.style/rules/js/space-before-blocks",
57
+ url: "https://eslint.style/rules/space-before-blocks",
58
58
  },
59
59
  },
60
60
  ],
@@ -29,12 +29,12 @@ module.exports = {
29
29
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
30
30
  url: "https://eslint.style/guide/migration",
31
31
  plugin: {
32
- name: "@stylistic/eslint-plugin-js",
33
- url: "https://eslint.style/packages/js",
32
+ name: "@stylistic/eslint-plugin",
33
+ url: "https://eslint.style",
34
34
  },
35
35
  rule: {
36
36
  name: "space-before-function-paren",
37
- url: "https://eslint.style/rules/js/space-before-function-paren",
37
+ url: "https://eslint.style/rules/space-before-function-paren",
38
38
  },
39
39
  },
40
40
  ],
@@ -25,12 +25,12 @@ module.exports = {
25
25
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
26
26
  url: "https://eslint.style/guide/migration",
27
27
  plugin: {
28
- name: "@stylistic/eslint-plugin-js",
29
- url: "https://eslint.style/packages/js",
28
+ name: "@stylistic/eslint-plugin",
29
+ url: "https://eslint.style",
30
30
  },
31
31
  rule: {
32
32
  name: "space-in-parens",
33
- url: "https://eslint.style/rules/js/space-in-parens",
33
+ url: "https://eslint.style/rules/space-in-parens",
34
34
  },
35
35
  },
36
36
  ],
@@ -25,12 +25,12 @@ module.exports = {
25
25
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
26
26
  url: "https://eslint.style/guide/migration",
27
27
  plugin: {
28
- name: "@stylistic/eslint-plugin-js",
29
- url: "https://eslint.style/packages/js",
28
+ name: "@stylistic/eslint-plugin",
29
+ url: "https://eslint.style",
30
30
  },
31
31
  rule: {
32
32
  name: "space-infix-ops",
33
- url: "https://eslint.style/rules/js/space-infix-ops",
33
+ url: "https://eslint.style/rules/space-infix-ops",
34
34
  },
35
35
  },
36
36
  ],
@@ -29,12 +29,12 @@ module.exports = {
29
29
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
30
30
  url: "https://eslint.style/guide/migration",
31
31
  plugin: {
32
- name: "@stylistic/eslint-plugin-js",
33
- url: "https://eslint.style/packages/js",
32
+ name: "@stylistic/eslint-plugin",
33
+ url: "https://eslint.style",
34
34
  },
35
35
  rule: {
36
36
  name: "space-unary-ops",
37
- url: "https://eslint.style/rules/js/space-unary-ops",
37
+ url: "https://eslint.style/rules/space-unary-ops",
38
38
  },
39
39
  },
40
40
  ],
@@ -154,12 +154,12 @@ module.exports = {
154
154
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
155
155
  url: "https://eslint.style/guide/migration",
156
156
  plugin: {
157
- name: "@stylistic/eslint-plugin-js",
158
- url: "https://eslint.style/packages/js",
157
+ name: "@stylistic/eslint-plugin",
158
+ url: "https://eslint.style",
159
159
  },
160
160
  rule: {
161
161
  name: "spaced-comment",
162
- url: "https://eslint.style/rules/js/spaced-comment",
162
+ url: "https://eslint.style/rules/spaced-comment",
163
163
  },
164
164
  },
165
165
  ],
@@ -30,12 +30,12 @@ module.exports = {
30
30
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
31
31
  url: "https://eslint.style/guide/migration",
32
32
  plugin: {
33
- name: "@stylistic/eslint-plugin-js",
34
- url: "https://eslint.style/packages/js",
33
+ name: "@stylistic/eslint-plugin",
34
+ url: "https://eslint.style",
35
35
  },
36
36
  rule: {
37
37
  name: "switch-colon-spacing",
38
- url: "https://eslint.style/rules/js/switch-colon-spacing",
38
+ url: "https://eslint.style/rules/switch-colon-spacing",
39
39
  },
40
40
  },
41
41
  ],
@@ -30,12 +30,12 @@ module.exports = {
30
30
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
31
31
  url: "https://eslint.style/guide/migration",
32
32
  plugin: {
33
- name: "@stylistic/eslint-plugin-js",
34
- url: "https://eslint.style/packages/js",
33
+ name: "@stylistic/eslint-plugin",
34
+ url: "https://eslint.style",
35
35
  },
36
36
  rule: {
37
37
  name: "template-curly-spacing",
38
- url: "https://eslint.style/rules/js/template-curly-spacing",
38
+ url: "https://eslint.style/rules/template-curly-spacing",
39
39
  },
40
40
  },
41
41
  ],
@@ -24,12 +24,12 @@ module.exports = {
24
24
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
25
25
  url: "https://eslint.style/guide/migration",
26
26
  plugin: {
27
- name: "@stylistic/eslint-plugin-js",
28
- url: "https://eslint.style/packages/js",
27
+ name: "@stylistic/eslint-plugin",
28
+ url: "https://eslint.style",
29
29
  },
30
30
  rule: {
31
31
  name: "template-tag-spacing",
32
- url: "https://eslint.style/rules/js/template-tag-spacing",
32
+ url: "https://eslint.style/rules/template-tag-spacing",
33
33
  },
34
34
  },
35
35
  ],
@@ -1193,6 +1193,35 @@ let needsPrecedingSemicolon;
1193
1193
  "WithStatement",
1194
1194
  ]);
1195
1195
 
1196
+ const TS_TYPE_NODE_TYPES = new Set([
1197
+ "TSAsExpression",
1198
+ "TSSatisfiesExpression",
1199
+ "TSTypeAliasDeclaration",
1200
+ "TSTypeAnnotation",
1201
+ ]);
1202
+
1203
+ /**
1204
+ * Determines whether a specified node is inside a TypeScript type context.
1205
+ * @param {ASTNode} node The node to check.
1206
+ * @returns {boolean} Whether the node is inside a TypeScript type context.
1207
+ */
1208
+ function isInType(node) {
1209
+ for (let currNode = node; ; ) {
1210
+ const { parent } = currNode;
1211
+ if (!parent) {
1212
+ break;
1213
+ }
1214
+ if (
1215
+ TS_TYPE_NODE_TYPES.has(parent.type) &&
1216
+ currNode === parent.typeAnnotation
1217
+ ) {
1218
+ return true;
1219
+ }
1220
+ currNode = parent;
1221
+ }
1222
+ return false;
1223
+ }
1224
+
1196
1225
  needsPrecedingSemicolon = function (sourceCode, node) {
1197
1226
  const prevToken = sourceCode.getTokenBefore(node);
1198
1227
 
@@ -1206,6 +1235,16 @@ let needsPrecedingSemicolon;
1206
1235
 
1207
1236
  const prevNode = sourceCode.getNodeByRangeIndex(prevToken.range[0]);
1208
1237
 
1238
+ if (
1239
+ prevNode.type === "TSDeclareFunction" ||
1240
+ prevNode.parent.type === "TSImportEqualsDeclaration" ||
1241
+ prevNode.parent.parent?.type === "TSImportEqualsDeclaration" ||
1242
+ TS_TYPE_NODE_TYPES.has(prevNode.type) ||
1243
+ isInType(prevNode)
1244
+ ) {
1245
+ return false;
1246
+ }
1247
+
1209
1248
  if (isClosingParenToken(prevToken)) {
1210
1249
  return !STATEMENTS.has(prevNode.type);
1211
1250
  }
@@ -1222,6 +1261,12 @@ let needsPrecedingSemicolon;
1222
1261
  }
1223
1262
 
1224
1263
  if (IDENTIFIER_OR_KEYWORD.has(prevToken.type)) {
1264
+ if (
1265
+ prevNode.parent.type === "VariableDeclarator" &&
1266
+ !prevNode.parent.init
1267
+ ) {
1268
+ return false;
1269
+ }
1225
1270
  if (BREAK_OR_CONTINUE.has(prevNode.parent.type)) {
1226
1271
  return false;
1227
1272
  }
@@ -51,12 +51,12 @@ module.exports = {
51
51
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
52
52
  url: "https://eslint.style/guide/migration",
53
53
  plugin: {
54
- name: "@stylistic/eslint-plugin-js",
55
- url: "https://eslint.style/packages/js",
54
+ name: "@stylistic/eslint-plugin",
55
+ url: "https://eslint.style",
56
56
  },
57
57
  rule: {
58
58
  name: "wrap-iife",
59
- url: "https://eslint.style/rules/js/wrap-iife",
59
+ url: "https://eslint.style/rules/wrap-iife",
60
60
  },
61
61
  },
62
62
  ],
@@ -24,12 +24,12 @@ module.exports = {
24
24
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
25
25
  url: "https://eslint.style/guide/migration",
26
26
  plugin: {
27
- name: "@stylistic/eslint-plugin-js",
28
- url: "https://eslint.style/packages/js",
27
+ name: "@stylistic/eslint-plugin",
28
+ url: "https://eslint.style",
29
29
  },
30
30
  rule: {
31
31
  name: "wrap-regex",
32
- url: "https://eslint.style/rules/js/wrap-regex",
32
+ url: "https://eslint.style/rules/wrap-regex",
33
33
  },
34
34
  },
35
35
  ],
@@ -24,12 +24,12 @@ module.exports = {
24
24
  "ESLint Stylistic now maintains deprecated stylistic core rules.",
25
25
  url: "https://eslint.style/guide/migration",
26
26
  plugin: {
27
- name: "@stylistic/eslint-plugin-js",
28
- url: "https://eslint.style/packages/js",
27
+ name: "@stylistic/eslint-plugin",
28
+ url: "https://eslint.style",
29
29
  },
30
30
  rule: {
31
31
  name: "yield-star-spacing",
32
- url: "https://eslint.style/rules/js/yield-star-spacing",
32
+ url: "https://eslint.style/rules/yield-star-spacing",
33
33
  },
34
34
  },
35
35
  ],
@@ -29,7 +29,7 @@ const activeFlags = new Map([
29
29
  ["test_only", "Used only for testing."],
30
30
  ["test_only_2", "Used only for testing."],
31
31
  [
32
- "unstable_config_lookup_from_file",
32
+ "v10_config_lookup_from_file",
33
33
  "Look up `eslint.config.js` from the file being linted.",
34
34
  ],
35
35
  [
@@ -73,6 +73,14 @@ const inactiveFlags = new Map([
73
73
  replacedBy: null,
74
74
  },
75
75
  ],
76
+ [
77
+ "unstable_config_lookup_from_file",
78
+ {
79
+ description:
80
+ "Look up `eslint.config.js` from the file being linted.",
81
+ replacedBy: "v10_config_lookup_from_file",
82
+ },
83
+ ],
76
84
  ]);
77
85
 
78
86
  /**
@@ -150,7 +150,7 @@ function environment() {
150
150
  return [
151
151
  "Environment Info:",
152
152
  "",
153
- `Node version: ${getBinVersion("node")}`,
153
+ `Node version: ${process.version}`,
154
154
  `npm version: ${getBinVersion("npm")}`,
155
155
  `Local ESLint version: ${getNpmPackageVersion("eslint", { global: false })}`,
156
156
  `Global ESLint version: ${getNpmPackageVersion("eslint", { global: true })}`,
@@ -1776,6 +1776,13 @@ export namespace Linter {
1776
1776
  */
1777
1777
  name?: string;
1778
1778
 
1779
+ /**
1780
+ * Path to the directory where the configuration object should apply.
1781
+ * `files` and `ignores` patterns in the configuration object are
1782
+ * interpreted as relative to this path.
1783
+ */
1784
+ basePath?: string;
1785
+
1779
1786
  /**
1780
1787
  * An array of glob patterns indicating the files that the configuration
1781
1788
  * object should apply to. If not specified, the configuration object applies