eslint 8.56.0 → 9.0.0-alpha.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 (121) hide show
  1. package/README.md +7 -2
  2. package/conf/ecma-version.js +16 -0
  3. package/conf/rule-type-list.json +3 -1
  4. package/lib/api.js +1 -1
  5. package/lib/cli-engine/cli-engine.js +14 -3
  6. package/lib/cli-engine/formatters/formatters-meta.json +1 -29
  7. package/lib/cli-engine/lint-result-cache.js +2 -2
  8. package/lib/cli.js +46 -25
  9. package/lib/config/default-config.js +3 -0
  10. package/lib/config/flat-config-array.js +0 -20
  11. package/lib/config/flat-config-helpers.js +41 -20
  12. package/lib/config/flat-config-schema.js +35 -25
  13. package/lib/config/rule-validator.js +27 -4
  14. package/lib/eslint/eslint-helpers.js +32 -12
  15. package/lib/eslint/eslint.js +856 -373
  16. package/lib/eslint/index.js +2 -2
  17. package/lib/eslint/legacy-eslint.js +722 -0
  18. package/lib/linter/apply-disable-directives.js +35 -7
  19. package/lib/linter/code-path-analysis/code-path.js +5 -19
  20. package/lib/linter/code-path-analysis/fork-context.js +1 -1
  21. package/lib/linter/config-comment-parser.js +8 -11
  22. package/lib/linter/linter.js +196 -100
  23. package/lib/linter/report-translator.js +2 -2
  24. package/lib/linter/rules.js +6 -15
  25. package/lib/linter/source-code-fixer.js +1 -1
  26. package/lib/options.js +9 -1
  27. package/lib/rule-tester/rule-tester.js +234 -291
  28. package/lib/rules/array-bracket-newline.js +1 -1
  29. package/lib/rules/array-bracket-spacing.js +1 -1
  30. package/lib/rules/block-scoped-var.js +1 -1
  31. package/lib/rules/callback-return.js +2 -2
  32. package/lib/rules/comma-dangle.js +1 -1
  33. package/lib/rules/comma-style.js +2 -2
  34. package/lib/rules/complexity.js +1 -1
  35. package/lib/rules/constructor-super.js +1 -1
  36. package/lib/rules/default-case.js +1 -1
  37. package/lib/rules/eol-last.js +2 -2
  38. package/lib/rules/function-paren-newline.js +2 -2
  39. package/lib/rules/indent-legacy.js +5 -5
  40. package/lib/rules/indent.js +5 -5
  41. package/lib/rules/index.js +1 -2
  42. package/lib/rules/key-spacing.js +2 -2
  43. package/lib/rules/line-comment-position.js +1 -1
  44. package/lib/rules/lines-around-directive.js +2 -2
  45. package/lib/rules/max-depth.js +1 -1
  46. package/lib/rules/max-len.js +3 -3
  47. package/lib/rules/max-lines.js +3 -3
  48. package/lib/rules/max-nested-callbacks.js +1 -1
  49. package/lib/rules/max-params.js +1 -1
  50. package/lib/rules/max-statements.js +1 -1
  51. package/lib/rules/multiline-comment-style.js +7 -7
  52. package/lib/rules/new-cap.js +1 -1
  53. package/lib/rules/newline-after-var.js +1 -1
  54. package/lib/rules/newline-before-return.js +1 -1
  55. package/lib/rules/no-constant-binary-expression.js +6 -6
  56. package/lib/rules/no-constructor-return.js +2 -2
  57. package/lib/rules/no-dupe-class-members.js +2 -2
  58. package/lib/rules/no-else-return.js +1 -1
  59. package/lib/rules/no-empty-function.js +2 -2
  60. package/lib/rules/no-empty-static-block.js +1 -1
  61. package/lib/rules/no-extra-semi.js +1 -1
  62. package/lib/rules/no-fallthrough.js +1 -1
  63. package/lib/rules/no-implicit-coercion.js +17 -1
  64. package/lib/rules/no-inner-declarations.js +23 -2
  65. package/lib/rules/no-invalid-regexp.js +1 -1
  66. package/lib/rules/no-invalid-this.js +1 -1
  67. package/lib/rules/no-lone-blocks.js +2 -2
  68. package/lib/rules/no-loss-of-precision.js +1 -1
  69. package/lib/rules/no-misleading-character-class.js +174 -65
  70. package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
  71. package/lib/rules/no-multiple-empty-lines.js +1 -1
  72. package/lib/rules/no-new-native-nonconstructor.js +1 -1
  73. package/lib/rules/no-new-symbol.js +8 -1
  74. package/lib/rules/no-restricted-globals.js +1 -1
  75. package/lib/rules/no-restricted-imports.js +2 -2
  76. package/lib/rules/no-restricted-modules.js +2 -2
  77. package/lib/rules/no-return-await.js +1 -1
  78. package/lib/rules/no-sequences.js +1 -0
  79. package/lib/rules/no-trailing-spaces.js +2 -3
  80. package/lib/rules/no-unneeded-ternary.js +1 -1
  81. package/lib/rules/no-unsafe-optional-chaining.js +1 -1
  82. package/lib/rules/no-unused-private-class-members.js +1 -1
  83. package/lib/rules/no-unused-vars.js +6 -8
  84. package/lib/rules/no-useless-assignment.js +566 -0
  85. package/lib/rules/no-useless-backreference.js +1 -1
  86. package/lib/rules/object-curly-spacing.js +3 -3
  87. package/lib/rules/object-property-newline.js +1 -1
  88. package/lib/rules/one-var.js +5 -5
  89. package/lib/rules/padded-blocks.js +7 -7
  90. package/lib/rules/prefer-arrow-callback.js +3 -3
  91. package/lib/rules/prefer-reflect.js +1 -1
  92. package/lib/rules/prefer-regex-literals.js +1 -1
  93. package/lib/rules/prefer-template.js +1 -1
  94. package/lib/rules/radix.js +2 -2
  95. package/lib/rules/semi-style.js +1 -1
  96. package/lib/rules/sort-imports.js +1 -1
  97. package/lib/rules/sort-keys.js +1 -1
  98. package/lib/rules/sort-vars.js +1 -1
  99. package/lib/rules/space-unary-ops.js +1 -1
  100. package/lib/rules/strict.js +1 -1
  101. package/lib/rules/utils/ast-utils.js +7 -7
  102. package/lib/rules/yield-star-spacing.js +1 -1
  103. package/lib/shared/types.js +1 -1
  104. package/lib/source-code/source-code.js +5 -83
  105. package/lib/source-code/token-store/index.js +2 -2
  106. package/lib/unsupported-api.js +3 -5
  107. package/package.json +12 -14
  108. package/conf/config-schema.js +0 -93
  109. package/lib/cli-engine/formatters/checkstyle.js +0 -60
  110. package/lib/cli-engine/formatters/compact.js +0 -60
  111. package/lib/cli-engine/formatters/jslint-xml.js +0 -41
  112. package/lib/cli-engine/formatters/junit.js +0 -82
  113. package/lib/cli-engine/formatters/tap.js +0 -95
  114. package/lib/cli-engine/formatters/unix.js +0 -58
  115. package/lib/cli-engine/formatters/visualstudio.js +0 -63
  116. package/lib/eslint/flat-eslint.js +0 -1142
  117. package/lib/rule-tester/flat-rule-tester.js +0 -1122
  118. package/lib/rules/require-jsdoc.js +0 -122
  119. package/lib/rules/valid-jsdoc.js +0 -516
  120. package/lib/shared/config-validator.js +0 -347
  121. package/lib/shared/relative-module-resolver.js +0 -50
@@ -109,12 +109,12 @@ module.exports = {
109
109
  options.var = { uninitialized: mode.var, initialized: mode.var };
110
110
  options.let = { uninitialized: mode.let, initialized: mode.let };
111
111
  options.const = { uninitialized: mode.const, initialized: mode.const };
112
- if (Object.prototype.hasOwnProperty.call(mode, "uninitialized")) {
112
+ if (Object.hasOwn(mode, "uninitialized")) {
113
113
  options.var.uninitialized = mode.uninitialized;
114
114
  options.let.uninitialized = mode.uninitialized;
115
115
  options.const.uninitialized = mode.uninitialized;
116
116
  }
117
- if (Object.prototype.hasOwnProperty.call(mode, "initialized")) {
117
+ if (Object.hasOwn(mode, "initialized")) {
118
118
  options.var.initialized = mode.initialized;
119
119
  options.let.initialized = mode.initialized;
120
120
  options.const.initialized = mode.initialized;
@@ -216,11 +216,11 @@ module.exports = {
216
216
  let currentScope;
217
217
 
218
218
  if (statementType === "var") {
219
- currentScope = functionStack[functionStack.length - 1];
219
+ currentScope = functionStack.at(-1);
220
220
  } else if (statementType === "let") {
221
- currentScope = blockStack[blockStack.length - 1].let;
221
+ currentScope = blockStack.at(-1).let;
222
222
  } else if (statementType === "const") {
223
- currentScope = blockStack[blockStack.length - 1].const;
223
+ currentScope = blockStack.at(-1).const;
224
224
  }
225
225
  return currentScope;
226
226
  }
@@ -84,18 +84,18 @@ module.exports = {
84
84
  options.switches = shouldHavePadding;
85
85
  options.classes = shouldHavePadding;
86
86
  } else {
87
- if (Object.prototype.hasOwnProperty.call(typeOptions, "blocks")) {
87
+ if (Object.hasOwn(typeOptions, "blocks")) {
88
88
  options.blocks = typeOptions.blocks === "always";
89
89
  }
90
- if (Object.prototype.hasOwnProperty.call(typeOptions, "switches")) {
90
+ if (Object.hasOwn(typeOptions, "switches")) {
91
91
  options.switches = typeOptions.switches === "always";
92
92
  }
93
- if (Object.prototype.hasOwnProperty.call(typeOptions, "classes")) {
93
+ if (Object.hasOwn(typeOptions, "classes")) {
94
94
  options.classes = typeOptions.classes === "always";
95
95
  }
96
96
  }
97
97
 
98
- if (Object.prototype.hasOwnProperty.call(exceptOptions, "allowSingleLineBlocks")) {
98
+ if (Object.hasOwn(exceptOptions, "allowSingleLineBlocks")) {
99
99
  options.allowSingleLineBlocks = exceptOptions.allowSingleLineBlocks === true;
100
100
  }
101
101
 
@@ -277,7 +277,7 @@ module.exports = {
277
277
 
278
278
  const rule = {};
279
279
 
280
- if (Object.prototype.hasOwnProperty.call(options, "switches")) {
280
+ if (Object.hasOwn(options, "switches")) {
281
281
  rule.SwitchStatement = function(node) {
282
282
  if (node.cases.length === 0) {
283
283
  return;
@@ -286,7 +286,7 @@ module.exports = {
286
286
  };
287
287
  }
288
288
 
289
- if (Object.prototype.hasOwnProperty.call(options, "blocks")) {
289
+ if (Object.hasOwn(options, "blocks")) {
290
290
  rule.BlockStatement = function(node) {
291
291
  if (node.body.length === 0) {
292
292
  return;
@@ -296,7 +296,7 @@ module.exports = {
296
296
  rule.StaticBlock = rule.BlockStatement;
297
297
  }
298
298
 
299
- if (Object.prototype.hasOwnProperty.call(options, "classes")) {
299
+ if (Object.hasOwn(options, "classes")) {
300
300
  rule.ClassBody = function(node) {
301
301
  if (node.body.length === 0) {
302
302
  return;
@@ -220,7 +220,7 @@ module.exports = {
220
220
 
221
221
  // If there are below, it cannot replace with arrow functions merely.
222
222
  ThisExpression() {
223
- const info = stack[stack.length - 1];
223
+ const info = stack.at(-1);
224
224
 
225
225
  if (info) {
226
226
  info.this = true;
@@ -228,7 +228,7 @@ module.exports = {
228
228
  },
229
229
 
230
230
  Super() {
231
- const info = stack[stack.length - 1];
231
+ const info = stack.at(-1);
232
232
 
233
233
  if (info) {
234
234
  info.super = true;
@@ -236,7 +236,7 @@ module.exports = {
236
236
  },
237
237
 
238
238
  MetaProperty(node) {
239
- const info = stack[stack.length - 1];
239
+ const info = stack.at(-1);
240
240
 
241
241
  if (info && checkMetaProperty(node, "new", "target")) {
242
242
  info.meta = true;
@@ -105,7 +105,7 @@ module.exports = {
105
105
  CallExpression(node) {
106
106
  const methodName = (node.callee.property || {}).name;
107
107
  const isReflectCall = (node.callee.object || {}).name === "Reflect";
108
- const hasReflectSubstitute = Object.prototype.hasOwnProperty.call(reflectSubstitutes, methodName);
108
+ const hasReflectSubstitute = Object.hasOwn(reflectSubstitutes, methodName);
109
109
  const userConfiguredException = exceptions.includes(methodName);
110
110
 
111
111
  if (hasReflectSubstitute && !isReflectCall && !userConfiguredException) {
@@ -34,7 +34,7 @@ function isStringLiteral(node) {
34
34
  * @returns {boolean} True if the node is a regex literal.
35
35
  */
36
36
  function isRegexLiteral(node) {
37
- return node.type === "Literal" && Object.prototype.hasOwnProperty.call(node, "regex");
37
+ return node.type === "Literal" && Object.hasOwn(node, "regex");
38
38
  }
39
39
 
40
40
  const validPrecedingTokens = new Set([
@@ -113,7 +113,7 @@ function endsWithTemplateCurly(node) {
113
113
  return startsWithTemplateCurly(node.right);
114
114
  }
115
115
  if (node.type === "TemplateLiteral") {
116
- return node.expressions.length && node.quasis.length && node.quasis[node.quasis.length - 1].range[0] === node.quasis[node.quasis.length - 1].range[1];
116
+ return node.expressions.length && node.quasis.length && node.quasis.at(-1).range[0] === node.quasis.at(-1).range[1];
117
117
  }
118
118
  return node.type !== "Literal" || typeof node.value !== "string";
119
119
  }
@@ -133,8 +133,8 @@ module.exports = {
133
133
  messageId: "addRadixParameter10",
134
134
  fix(fixer) {
135
135
  const tokens = sourceCode.getTokens(node);
136
- const lastToken = tokens[tokens.length - 1]; // Parenthesis.
137
- const secondToLastToken = tokens[tokens.length - 2]; // May or may not be a comma.
136
+ const lastToken = tokens.at(-1); // Parenthesis.
137
+ const secondToLastToken = tokens.at(-2); // May or may not be a comma.
138
138
  const hasTrailingComma = secondToLastToken.type === "Punctuator" && secondToLastToken.value === ",";
139
139
 
140
140
  return fixer.insertTextBefore(lastToken, hasTrailingComma ? " 10," : ", 10");
@@ -65,7 +65,7 @@ function isLastChild(node) {
65
65
  }
66
66
  const nodeList = getChildren(node.parent);
67
67
 
68
- return nodeList !== null && nodeList[nodeList.length - 1] === node; // before `}` or etc.
68
+ return nodeList !== null && nodeList.at(-1) === node; // before `}` or etc.
69
69
  }
70
70
 
71
71
  /** @type {import('../shared/types').Rule} */
@@ -208,7 +208,7 @@ module.exports = {
208
208
  }
209
209
 
210
210
  return fixer.replaceTextRange(
211
- [importSpecifiers[0].range[0], importSpecifiers[importSpecifiers.length - 1].range[1]],
211
+ [importSpecifiers[0].range[0], importSpecifiers.at(-1).range[1]],
212
212
  importSpecifiers
213
213
 
214
214
  // Clone the importSpecifiers array to avoid mutating it
@@ -185,7 +185,7 @@ module.exports = {
185
185
  });
186
186
 
187
187
  // check blank line between the current node and the last token
188
- if (!isBlankLineBetweenNodes && (node.loc.start.line - tokens[tokens.length - 1].loc.end.line > 1)) {
188
+ if (!isBlankLineBetweenNodes && (node.loc.start.line - tokens.at(-1).loc.end.line > 1)) {
189
189
  isBlankLineBetweenNodes = true;
190
190
  }
191
191
 
@@ -66,7 +66,7 @@ module.exports = {
66
66
  return null;
67
67
  }
68
68
  return fixer.replaceTextRange(
69
- [idDeclarations[0].range[0], idDeclarations[idDeclarations.length - 1].range[1]],
69
+ [idDeclarations[0].range[0], idDeclarations.at(-1).range[1]],
70
70
  idDeclarations
71
71
 
72
72
  // Clone the idDeclarations array to avoid mutating it
@@ -87,7 +87,7 @@ module.exports = {
87
87
  * @returns {boolean} Whether or not an override has been provided for the operator
88
88
  */
89
89
  function overrideExistsForOperator(operator) {
90
- return options.overrides && Object.prototype.hasOwnProperty.call(options.overrides, operator);
90
+ return options.overrides && Object.hasOwn(options.overrides, operator);
91
91
  }
92
92
 
93
93
  /**
@@ -173,7 +173,7 @@ module.exports = {
173
173
  function enterFunctionInFunctionMode(node, useStrictDirectives) {
174
174
  const isInClass = classScopes.length > 0,
175
175
  isParentGlobal = scopes.length === 0 && classScopes.length === 0,
176
- isParentStrict = scopes.length > 0 && scopes[scopes.length - 1],
176
+ isParentStrict = scopes.length > 0 && scopes.at(-1),
177
177
  isStrict = useStrictDirectives.length > 0;
178
178
 
179
179
  if (isStrict) {
@@ -969,7 +969,7 @@ function isConstant(scope, node, inBooleanPosition) {
969
969
  return false;
970
970
 
971
971
  case "SequenceExpression":
972
- return isConstant(scope, node.expressions[node.expressions.length - 1], inBooleanPosition);
972
+ return isConstant(scope, node.expressions.at(-1), inBooleanPosition);
973
973
  case "SpreadElement":
974
974
  return isConstant(scope, node.argument, inBooleanPosition);
975
975
  case "CallExpression":
@@ -1231,7 +1231,7 @@ module.exports = {
1231
1231
  * @private
1232
1232
  */
1233
1233
  isSurroundedBy(val, character) {
1234
- return val[0] === character && val[val.length - 1] === character;
1234
+ return val[0] === character && val.at(-1) === character;
1235
1235
  },
1236
1236
 
1237
1237
  /**
@@ -1909,8 +1909,8 @@ module.exports = {
1909
1909
  */
1910
1910
  getFunctionHeadLoc(node, sourceCode) {
1911
1911
  const parent = node.parent;
1912
- let start = null;
1913
- let end = null;
1912
+ let start;
1913
+ let end;
1914
1914
 
1915
1915
  if (parent.type === "Property" || parent.type === "MethodDefinition" || parent.type === "PropertyDefinition") {
1916
1916
  start = parent.loc.start;
@@ -2055,7 +2055,7 @@ module.exports = {
2055
2055
  case "SequenceExpression": {
2056
2056
  const exprs = node.expressions;
2057
2057
 
2058
- return exprs.length !== 0 && module.exports.couldBeError(exprs[exprs.length - 1]);
2058
+ return exprs.length !== 0 && module.exports.couldBeError(exprs.at(-1));
2059
2059
  }
2060
2060
 
2061
2061
  case "LogicalExpression":
@@ -2119,9 +2119,9 @@ module.exports = {
2119
2119
 
2120
2120
  const comments = tokens.comments;
2121
2121
 
2122
- leftToken = tokens[tokens.length - 1];
2122
+ leftToken = tokens.at(-1);
2123
2123
  if (comments.length) {
2124
- const lastComment = comments[comments.length - 1];
2124
+ const lastComment = comments.at(-1);
2125
2125
 
2126
2126
  if (!leftToken || lastComment.range[0] > leftToken.range[0]) {
2127
2127
  leftToken = lastComment;
@@ -79,7 +79,7 @@ module.exports = {
79
79
  const after = leftToken.value === "*";
80
80
  const spaceRequired = mode[side];
81
81
  const node = after ? leftToken : rightToken;
82
- let messageId = "";
82
+ let messageId;
83
83
 
84
84
  if (spaceRequired) {
85
85
  messageId = side === "before" ? "missingBefore" : "missingAfter";
@@ -168,7 +168,7 @@ module.exports = {};
168
168
  * @property {Record<string, ConfigData>} [configs] The definition of plugin configs.
169
169
  * @property {Record<string, Environment>} [environments] The definition of plugin environments.
170
170
  * @property {Record<string, Processor>} [processors] The definition of plugin processors.
171
- * @property {Record<string, Function | Rule>} [rules] The definition of plugin rules.
171
+ * @property {Record<string, Rule>} [rules] The definition of plugin rules.
172
172
  */
173
173
 
174
174
  /**
@@ -415,13 +415,10 @@ class SourceCode extends TokenStore {
415
415
  * and uses match.index to get the correct line start indices.
416
416
  */
417
417
  while ((match = lineEndingPattern.exec(this.text))) {
418
- this.lines.push(this.text.slice(this.lineStartIndices[this.lineStartIndices.length - 1], match.index));
418
+ this.lines.push(this.text.slice(this.lineStartIndices.at(-1), match.index));
419
419
  this.lineStartIndices.push(match.index + match[0].length);
420
420
  }
421
- this.lines.push(this.text.slice(this.lineStartIndices[this.lineStartIndices.length - 1]));
422
-
423
- // Cache for comments found using getComments().
424
- this._commentCache = new WeakMap();
421
+ this.lines.push(this.text.slice(this.lineStartIndices.at(-1)));
425
422
 
426
423
  // don't allow further modification of this object
427
424
  Object.freeze(this);
@@ -472,81 +469,6 @@ class SourceCode extends TokenStore {
472
469
  return this.ast.comments;
473
470
  }
474
471
 
475
- /**
476
- * Gets all comments for the given node.
477
- * @param {ASTNode} node The AST node to get the comments for.
478
- * @returns {Object} An object containing a leading and trailing array
479
- * of comments indexed by their position.
480
- * @public
481
- * @deprecated replaced by getCommentsBefore(), getCommentsAfter(), and getCommentsInside().
482
- */
483
- getComments(node) {
484
- if (this._commentCache.has(node)) {
485
- return this._commentCache.get(node);
486
- }
487
-
488
- const comments = {
489
- leading: [],
490
- trailing: []
491
- };
492
-
493
- /*
494
- * Return all comments as leading comments of the Program node when
495
- * there is no executable code.
496
- */
497
- if (node.type === "Program") {
498
- if (node.body.length === 0) {
499
- comments.leading = node.comments;
500
- }
501
- } else {
502
-
503
- /*
504
- * Return comments as trailing comments of nodes that only contain
505
- * comments (to mimic the comment attachment behavior present in Espree).
506
- */
507
- if ((node.type === "BlockStatement" || node.type === "ClassBody") && node.body.length === 0 ||
508
- node.type === "ObjectExpression" && node.properties.length === 0 ||
509
- node.type === "ArrayExpression" && node.elements.length === 0 ||
510
- node.type === "SwitchStatement" && node.cases.length === 0
511
- ) {
512
- comments.trailing = this.getTokens(node, {
513
- includeComments: true,
514
- filter: isCommentToken
515
- });
516
- }
517
-
518
- /*
519
- * Iterate over tokens before and after node and collect comment tokens.
520
- * Do not include comments that exist outside of the parent node
521
- * to avoid duplication.
522
- */
523
- let currentToken = this.getTokenBefore(node, { includeComments: true });
524
-
525
- while (currentToken && isCommentToken(currentToken)) {
526
- if (node.parent && node.parent.type !== "Program" && (currentToken.start < node.parent.start)) {
527
- break;
528
- }
529
- comments.leading.push(currentToken);
530
- currentToken = this.getTokenBefore(currentToken, { includeComments: true });
531
- }
532
-
533
- comments.leading.reverse();
534
-
535
- currentToken = this.getTokenAfter(node, { includeComments: true });
536
-
537
- while (currentToken && isCommentToken(currentToken)) {
538
- if (node.parent && node.parent.type !== "Program" && (currentToken.end > node.parent.end)) {
539
- break;
540
- }
541
- comments.trailing.push(currentToken);
542
- currentToken = this.getTokenAfter(currentToken, { includeComments: true });
543
- }
544
- }
545
-
546
- this._commentCache.set(node, comments);
547
- return comments;
548
- }
549
-
550
472
  /**
551
473
  * Retrieves the JSDoc comment for a given node.
552
474
  * @param {ASTNode} node The AST node to get the comment for.
@@ -701,14 +623,14 @@ class SourceCode extends TokenStore {
701
623
  * See getIndexFromLoc for the motivation for this special case.
702
624
  */
703
625
  if (index === this.text.length) {
704
- return { line: this.lines.length, column: this.lines[this.lines.length - 1].length };
626
+ return { line: this.lines.length, column: this.lines.at(-1).length };
705
627
  }
706
628
 
707
629
  /*
708
630
  * To figure out which line index is on, determine the last place at which index could
709
631
  * be inserted into lineStartIndices to keep the list sorted.
710
632
  */
711
- const lineNumber = index >= this.lineStartIndices[this.lineStartIndices.length - 1]
633
+ const lineNumber = index >= this.lineStartIndices.at(-1)
712
634
  ? this.lineStartIndices.length
713
635
  : this.lineStartIndices.findIndex(el => index < el);
714
636
 
@@ -963,7 +885,7 @@ class SourceCode extends TokenStore {
963
885
 
964
886
  switch (directiveText) {
965
887
  case "exported":
966
- Object.assign(exportedVariables, commentParser.parseStringConfig(directiveValue, comment));
888
+ Object.assign(exportedVariables, commentParser.parseListConfig(directiveValue, comment));
967
889
  break;
968
890
 
969
891
  case "globals":
@@ -37,8 +37,8 @@ function createIndexMap(tokens, comments) {
37
37
  const map = Object.create(null);
38
38
  let tokenIndex = 0;
39
39
  let commentIndex = 0;
40
- let nextStart = 0;
41
- let range = null;
40
+ let nextStart;
41
+ let range;
42
42
 
43
43
  while (tokenIndex < tokens.length || commentIndex < comments.length) {
44
44
  nextStart = (commentIndex < comments.length) ? comments[commentIndex].range[0] : Number.MAX_SAFE_INTEGER;
@@ -12,9 +12,8 @@
12
12
  //-----------------------------------------------------------------------------
13
13
 
14
14
  const { FileEnumerator } = require("./cli-engine/file-enumerator");
15
- const { FlatESLint, shouldUseFlatConfig } = require("./eslint/flat-eslint");
16
- const FlatRuleTester = require("./rule-tester/flat-rule-tester");
17
- const { ESLint } = require("./eslint/eslint");
15
+ const { ESLint: FlatESLint, shouldUseFlatConfig } = require("./eslint/eslint");
16
+ const { LegacyESLint } = require("./eslint/legacy-eslint");
18
17
 
19
18
  //-----------------------------------------------------------------------------
20
19
  // Exports
@@ -24,7 +23,6 @@ module.exports = {
24
23
  builtinRules: require("./rules"),
25
24
  FlatESLint,
26
25
  shouldUseFlatConfig,
27
- FlatRuleTester,
28
26
  FileEnumerator,
29
- LegacyESLint: ESLint
27
+ LegacyESLint
30
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "8.56.0",
3
+ "version": "9.0.0-alpha.1",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -17,6 +17,7 @@
17
17
  "build:site": "node Makefile.js gensite",
18
18
  "build:webpack": "node Makefile.js webpack",
19
19
  "build:readme": "node tools/update-readme.js",
20
+ "build:rules-index": "node Makefile.js generateRuleIndexPage",
20
21
  "lint": "node Makefile.js lint",
21
22
  "lint:docs:js": "node Makefile.js lintDocsJS",
22
23
  "lint:docs:rule-examples": "node Makefile.js checkRuleExamples",
@@ -64,19 +65,17 @@
64
65
  "dependencies": {
65
66
  "@eslint-community/eslint-utils": "^4.2.0",
66
67
  "@eslint-community/regexpp": "^4.6.1",
67
- "@eslint/eslintrc": "^2.1.4",
68
- "@eslint/js": "8.56.0",
69
- "@humanwhocodes/config-array": "^0.11.13",
68
+ "@eslint/eslintrc": "^3.0.0",
69
+ "@eslint/js": "9.0.0-alpha.0",
70
+ "@humanwhocodes/config-array": "^0.11.14",
70
71
  "@humanwhocodes/module-importer": "^1.0.1",
71
72
  "@nodelib/fs.walk": "^1.2.8",
72
- "@ungap/structured-clone": "^1.2.0",
73
73
  "ajv": "^6.12.4",
74
74
  "chalk": "^4.0.0",
75
75
  "cross-spawn": "^7.0.2",
76
76
  "debug": "^4.3.2",
77
- "doctrine": "^3.0.0",
78
77
  "escape-string-regexp": "^4.0.0",
79
- "eslint-scope": "^7.2.2",
78
+ "eslint-scope": "^8.0.0",
80
79
  "eslint-visitor-keys": "^3.4.3",
81
80
  "espree": "^9.6.1",
82
81
  "esquery": "^1.4.2",
@@ -91,7 +90,6 @@
91
90
  "imurmurhash": "^0.1.4",
92
91
  "is-glob": "^4.0.0",
93
92
  "is-path-inside": "^3.0.3",
94
- "js-yaml": "^4.1.0",
95
93
  "json-stable-stringify-without-jsonify": "^1.0.1",
96
94
  "levn": "^0.4.1",
97
95
  "lodash.merge": "^4.6.2",
@@ -121,23 +119,24 @@
121
119
  "eslint-plugin-eslint-comments": "^3.2.0",
122
120
  "eslint-plugin-eslint-plugin": "^5.2.1",
123
121
  "eslint-plugin-internal-rules": "file:tools/internal-rules",
124
- "eslint-plugin-jsdoc": "^46.2.5",
125
- "eslint-plugin-n": "^16.4.0",
122
+ "eslint-plugin-jsdoc": "^46.9.0",
123
+ "eslint-plugin-n": "^16.6.0",
126
124
  "eslint-plugin-unicorn": "^49.0.0",
127
125
  "eslint-release": "^3.2.0",
128
126
  "eslump": "^3.0.0",
129
127
  "esprima": "^4.0.1",
130
128
  "fast-glob": "^3.2.11",
131
129
  "fs-teardown": "^0.1.3",
132
- "glob": "^7.1.6",
130
+ "glob": "^10.0.0",
133
131
  "got": "^11.8.3",
134
132
  "gray-matter": "^4.0.3",
133
+ "js-yaml": "^4.1.0",
135
134
  "lint-staged": "^11.0.0",
136
135
  "load-perf": "^0.2.0",
137
136
  "markdown-it": "^12.2.0",
138
137
  "markdown-it-container": "^3.0.0",
139
138
  "markdownlint": "^0.32.0",
140
- "markdownlint-cli": "^0.37.0",
139
+ "markdownlint-cli": "^0.38.0",
141
140
  "marked": "^4.0.8",
142
141
  "memfs": "^3.0.1",
143
142
  "metascraper": "^5.25.7",
@@ -147,7 +146,6 @@
147
146
  "metascraper-logo-favicon": "^5.25.7",
148
147
  "metascraper-title": "^5.25.7",
149
148
  "mocha": "^8.3.2",
150
- "mocha-junit-reporter": "^2.0.0",
151
149
  "node-polyfill-webpack-plugin": "^1.0.3",
152
150
  "npm-license": "^0.3.3",
153
151
  "pirates": "^4.0.5",
@@ -174,6 +172,6 @@
174
172
  ],
175
173
  "license": "MIT",
176
174
  "engines": {
177
- "node": "^12.22.0 || ^14.17.0 || >=16.0.0"
175
+ "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
178
176
  }
179
177
  }
@@ -1,93 +0,0 @@
1
- /*
2
- * STOP!!! DO NOT MODIFY.
3
- *
4
- * This file is part of the ongoing work to move the eslintrc-style config
5
- * system into the @eslint/eslintrc package. This file needs to remain
6
- * unchanged in order for this work to proceed.
7
- *
8
- * If you think you need to change this file, please contact @nzakas first.
9
- *
10
- * Thanks in advance for your cooperation.
11
- */
12
-
13
- /**
14
- * @fileoverview Defines a schema for configs.
15
- * @author Sylvan Mably
16
- */
17
-
18
- "use strict";
19
-
20
- const baseConfigProperties = {
21
- $schema: { type: "string" },
22
- env: { type: "object" },
23
- extends: { $ref: "#/definitions/stringOrStrings" },
24
- globals: { type: "object" },
25
- overrides: {
26
- type: "array",
27
- items: { $ref: "#/definitions/overrideConfig" },
28
- additionalItems: false
29
- },
30
- parser: { type: ["string", "null"] },
31
- parserOptions: { type: "object" },
32
- plugins: { type: "array" },
33
- processor: { type: "string" },
34
- rules: { type: "object" },
35
- settings: { type: "object" },
36
- noInlineConfig: { type: "boolean" },
37
- reportUnusedDisableDirectives: { type: "boolean" },
38
-
39
- ecmaFeatures: { type: "object" } // deprecated; logs a warning when used
40
- };
41
-
42
- const configSchema = {
43
- definitions: {
44
- stringOrStrings: {
45
- oneOf: [
46
- { type: "string" },
47
- {
48
- type: "array",
49
- items: { type: "string" },
50
- additionalItems: false
51
- }
52
- ]
53
- },
54
- stringOrStringsRequired: {
55
- oneOf: [
56
- { type: "string" },
57
- {
58
- type: "array",
59
- items: { type: "string" },
60
- additionalItems: false,
61
- minItems: 1
62
- }
63
- ]
64
- },
65
-
66
- // Config at top-level.
67
- objectConfig: {
68
- type: "object",
69
- properties: {
70
- root: { type: "boolean" },
71
- ignorePatterns: { $ref: "#/definitions/stringOrStrings" },
72
- ...baseConfigProperties
73
- },
74
- additionalProperties: false
75
- },
76
-
77
- // Config in `overrides`.
78
- overrideConfig: {
79
- type: "object",
80
- properties: {
81
- excludedFiles: { $ref: "#/definitions/stringOrStrings" },
82
- files: { $ref: "#/definitions/stringOrStringsRequired" },
83
- ...baseConfigProperties
84
- },
85
- required: ["files"],
86
- additionalProperties: false
87
- }
88
- },
89
-
90
- $ref: "#/definitions/objectConfig"
91
- };
92
-
93
- module.exports = configSchema;