eslint 9.39.1 → 10.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 (64) hide show
  1. package/README.md +3 -3
  2. package/bin/eslint.js +1 -2
  3. package/lib/api.js +4 -15
  4. package/lib/cli.js +14 -56
  5. package/lib/config/config-loader.js +6 -154
  6. package/lib/eslint/eslint-helpers.js +5 -8
  7. package/lib/eslint/eslint.js +1 -1
  8. package/lib/eslint/index.js +0 -2
  9. package/lib/languages/js/source-code/source-code.js +66 -252
  10. package/lib/languages/js/source-code/token-store/index.js +0 -26
  11. package/lib/languages/js/source-code/token-store/utils.js +29 -8
  12. package/lib/linter/apply-disable-directives.js +0 -1
  13. package/lib/linter/file-context.js +0 -56
  14. package/lib/linter/file-report.js +0 -4
  15. package/lib/linter/linter.js +45 -1086
  16. package/lib/linter/rule-fixer.js +30 -0
  17. package/lib/options.js +62 -182
  18. package/lib/rule-tester/rule-tester.js +265 -194
  19. package/lib/rules/array-bracket-spacing.js +4 -4
  20. package/lib/rules/block-spacing.js +1 -1
  21. package/lib/rules/comma-spacing.js +2 -5
  22. package/lib/rules/computed-property-spacing.js +4 -4
  23. package/lib/rules/dot-notation.js +2 -2
  24. package/lib/rules/func-names.js +2 -0
  25. package/lib/rules/keyword-spacing.js +4 -4
  26. package/lib/rules/no-eval.js +1 -1
  27. package/lib/rules/no-extra-parens.js +1 -1
  28. package/lib/rules/no-invalid-regexp.js +1 -0
  29. package/lib/rules/no-shadow-restricted-names.js +1 -1
  30. package/lib/rules/no-spaced-func.js +1 -1
  31. package/lib/rules/no-unassigned-vars.js +1 -1
  32. package/lib/rules/no-useless-assignment.js +1 -1
  33. package/lib/rules/no-useless-constructor.js +13 -3
  34. package/lib/rules/no-whitespace-before-property.js +1 -1
  35. package/lib/rules/object-curly-spacing.js +2 -8
  36. package/lib/rules/preserve-caught-error.js +1 -1
  37. package/lib/rules/radix.js +25 -48
  38. package/lib/rules/require-yield.js +11 -1
  39. package/lib/rules/rest-spread-spacing.js +1 -4
  40. package/lib/rules/semi-spacing.js +2 -2
  41. package/lib/rules/space-before-blocks.js +1 -1
  42. package/lib/rules/space-before-function-paren.js +1 -4
  43. package/lib/rules/space-in-parens.js +4 -4
  44. package/lib/rules/space-infix-ops.js +4 -7
  45. package/lib/rules/switch-colon-spacing.js +1 -1
  46. package/lib/rules/template-tag-spacing.js +1 -1
  47. package/lib/rules/utils/ast-utils.js +114 -22
  48. package/lib/rules/yield-star-spacing.js +1 -2
  49. package/lib/services/parser-service.js +0 -1
  50. package/lib/services/processor-service.js +0 -1
  51. package/lib/services/warning-service.js +0 -11
  52. package/lib/shared/flags.js +0 -19
  53. package/lib/shared/translate-cli-options.js +106 -164
  54. package/lib/types/index.d.ts +7 -81
  55. package/lib/types/rules.d.ts +11 -2
  56. package/lib/types/use-at-your-own-risk.d.ts +1 -54
  57. package/lib/unsupported-api.js +3 -6
  58. package/package.json +15 -20
  59. package/conf/default-cli-options.js +0 -32
  60. package/lib/cli-engine/cli-engine.js +0 -1109
  61. package/lib/cli-engine/file-enumerator.js +0 -541
  62. package/lib/cli-engine/index.js +0 -7
  63. package/lib/cli-engine/load-rules.js +0 -46
  64. package/lib/eslint/legacy-eslint.js +0 -786
@@ -72,7 +72,6 @@ import type {
72
72
  SuggestedEdit,
73
73
  ViolationReport,
74
74
  } from "@eslint/core";
75
- import { LegacyESLint } from "./use-at-your-own-risk.js";
76
75
 
77
76
  //------------------------------------------------------------------------------
78
77
  // Helpers
@@ -134,6 +133,8 @@ export namespace Scope {
134
133
  acquire(node: ESTree.Node, inner?: boolean): Scope | null;
135
134
 
136
135
  getDeclaredVariables(node: ESTree.Node): Variable[];
136
+
137
+ addGlobals(names: string[]): void;
137
138
  }
138
139
 
139
140
  interface Scope {
@@ -280,17 +281,8 @@ export class SourceCode
280
281
 
281
282
  getDeclaredVariables(node: ESTree.Node): Scope.Variable[];
282
283
 
283
- /** @deprecated */
284
- getJSDocComment(node: ESTree.Node): ESTree.Comment | null;
285
-
286
284
  getNodeByRangeIndex(index: number): ESTree.Node | null;
287
285
 
288
- /** @deprecated Use `isSpaceBetween()` instead. */
289
- isSpaceBetweenTokens(
290
- first: ESTree.Node | AST.Token,
291
- second: ESTree.Node | AST.Token,
292
- ): boolean;
293
-
294
286
  getLocFromIndex(index: number): ESTree.Position;
295
287
 
296
288
  getIndexFromLoc(location: ESTree.Position): number;
@@ -323,18 +315,6 @@ export class SourceCode
323
315
 
324
316
  getTokensAfter: SourceCode.UnaryCursorWithCountOptions;
325
317
 
326
- /** @deprecated Use `getTokenBefore()` instead. */
327
- getTokenOrCommentBefore(
328
- node: ESTree.Node | AST.Token | ESTree.Comment,
329
- skip?: number | undefined,
330
- ): AST.Token | ESTree.Comment | null;
331
-
332
- /** @deprecated Use `getTokenAfter()` instead. */
333
- getTokenOrCommentAfter(
334
- node: ESTree.Node | AST.Token | ESTree.Comment,
335
- skip?: number | undefined,
336
- ): AST.Token | ESTree.Comment | null;
337
-
338
318
  getFirstTokenBetween: SourceCode.BinaryCursorWithSkipOptions;
339
319
 
340
320
  getFirstTokensBetween: SourceCode.BinaryCursorWithCountOptions;
@@ -785,7 +765,7 @@ export namespace Rule {
785
765
  type ReportFixer = CoreRuleFixer;
786
766
 
787
767
  /** @deprecated Use `ReportDescriptorOptions` instead. */
788
- type ReportDescriptorOptionsBase = ViolationReportBase;
768
+ type ReportDescriptorOptionsBase = Omit<ViolationReportBase, "suggest">;
789
769
 
790
770
  type SuggestionReportOptions = SuggestedEditBase;
791
771
  type SuggestionDescriptorMessage = SuggestionMessage;
@@ -794,9 +774,9 @@ export namespace Rule {
794
774
  // redundant with ReportDescriptorOptionsBase but kept for clarity
795
775
  type ReportDescriptorOptions = ViolationReportBase;
796
776
 
797
- type ReportDescriptor = ViolationReport<ESTree.Node>;
777
+ type ReportDescriptor = ViolationReport<JSSyntaxElement>;
798
778
  type ReportDescriptorMessage = ViolationMessage;
799
- type ReportDescriptorLocation = ViolationLocation<ESTree.Node>;
779
+ type ReportDescriptorLocation = ViolationLocation<JSSyntaxElement>;
800
780
 
801
781
  type RuleFixer = RuleTextEditor<ESTree.Node | AST.Token>;
802
782
  type Fix = RuleTextEdit;
@@ -823,10 +803,7 @@ export class Linter {
823
803
 
824
804
  version: string;
825
805
 
826
- constructor(options?: {
827
- cwd?: string | undefined;
828
- configType?: "flat" | "eslintrc";
829
- });
806
+ constructor(options?: { cwd?: string | undefined; configType?: "flat" });
830
807
 
831
808
  verify(
832
809
  code: SourceCode | string,
@@ -852,14 +829,6 @@ export class Linter {
852
829
 
853
830
  getSourceCode(): SourceCode;
854
831
 
855
- defineRule(name: string, rule: Rule.RuleModule): void;
856
-
857
- defineRules(rules: { [name: string]: Rule.RuleModule }): void;
858
-
859
- getRules(): Map<string, Rule.RuleModule>;
860
-
861
- defineParser(name: string, parser: Linter.Parser): void;
862
-
863
832
  getTimes(): Linter.Stats["times"];
864
833
 
865
834
  getFixPassCount(): Linter.Stats["fixPasses"];
@@ -1233,39 +1202,6 @@ export namespace ESLint {
1233
1202
  flags?: string[] | undefined;
1234
1203
  }
1235
1204
 
1236
- interface LegacyOptions {
1237
- // File enumeration
1238
- cwd?: string | undefined;
1239
- errorOnUnmatchedPattern?: boolean | undefined;
1240
- extensions?: string[] | undefined;
1241
- globInputPaths?: boolean | undefined;
1242
- ignore?: boolean | undefined;
1243
- ignorePath?: string | undefined;
1244
-
1245
- // Linting
1246
- allowInlineConfig?: boolean | undefined;
1247
- baseConfig?: Linter.LegacyConfig | undefined;
1248
- overrideConfig?: Linter.LegacyConfig | undefined;
1249
- overrideConfigFile?: string | undefined;
1250
- plugins?: Record<string, Plugin> | undefined;
1251
- reportUnusedDisableDirectives?: Linter.StringSeverity | undefined;
1252
- resolvePluginsRelativeTo?: string | undefined;
1253
- rulePaths?: string[] | undefined;
1254
- useEslintrc?: boolean | undefined;
1255
-
1256
- // Autofix
1257
- fix?: boolean | ((message: Linter.LintMessage) => boolean) | undefined;
1258
- fixTypes?: FixType[] | null | undefined;
1259
-
1260
- // Cache-related
1261
- cache?: boolean | undefined;
1262
- cacheLocation?: string | undefined;
1263
- cacheStrategy?: CacheStrategy | undefined;
1264
-
1265
- // Other Options
1266
- flags?: string[] | undefined;
1267
- }
1268
-
1269
1205
  /** A linting result. */
1270
1206
  interface LintResult {
1271
1207
  /** The path to the file that was linted. */
@@ -1396,15 +1332,9 @@ export namespace ESLint {
1396
1332
 
1397
1333
  // #endregion
1398
1334
 
1399
- export function loadESLint(options: {
1400
- useFlatConfig: true;
1401
- }): Promise<typeof ESLint>;
1402
- export function loadESLint(options: {
1403
- useFlatConfig: false;
1404
- }): Promise<typeof LegacyESLint>;
1405
1335
  export function loadESLint(options?: {
1406
1336
  useFlatConfig?: boolean | undefined;
1407
- }): Promise<typeof ESLint | typeof LegacyESLint>;
1337
+ }): Promise<typeof ESLint>;
1408
1338
 
1409
1339
  // #region RuleTester
1410
1340
 
@@ -1457,10 +1387,6 @@ export namespace RuleTester {
1457
1387
  interface TestCaseError {
1458
1388
  message?: string | RegExp;
1459
1389
  messageId?: string;
1460
- /**
1461
- * @deprecated `type` is deprecated and will be removed in the next major version.
1462
- */
1463
- type?: string | undefined;
1464
1390
  data?: any;
1465
1391
  line?: number | undefined;
1466
1392
  column?: number | undefined;
@@ -3783,7 +3783,7 @@ export interface ESLintRules extends Linter.RulesRecord {
3783
3783
  [
3784
3784
  Partial<{
3785
3785
  /**
3786
- * @default false
3786
+ * @default true
3787
3787
  */
3788
3788
  reportGlobalThis: boolean;
3789
3789
  }>,
@@ -3914,6 +3914,9 @@ export interface ESLintRules extends Linter.RulesRecord {
3914
3914
  /**
3915
3915
  * Rule to disallow `let` or `var` variables that are read but never assigned.
3916
3916
  *
3917
+ * @remarks
3918
+ * Recommended by ESLint, the rule was enabled in `eslint:recommended`.
3919
+ *
3917
3920
  * @since 9.27.0
3918
3921
  * @see https://eslint.org/docs/latest/rules/no-unassigned-vars
3919
3922
  */
@@ -4279,6 +4282,9 @@ export interface ESLintRules extends Linter.RulesRecord {
4279
4282
  /**
4280
4283
  * Rule to disallow variable assignments when the value is not used.
4281
4284
  *
4285
+ * @remarks
4286
+ * Recommended by ESLint, the rule was enabled in `eslint:recommended`.
4287
+ *
4282
4288
  * @since 9.0.0-alpha.1
4283
4289
  * @see https://eslint.org/docs/latest/rules/no-useless-assignment
4284
4290
  */
@@ -4944,6 +4950,9 @@ export interface ESLintRules extends Linter.RulesRecord {
4944
4950
  /**
4945
4951
  * Rule to disallow losing originally caught error when re-throwing custom errors.
4946
4952
  *
4953
+ * @remarks
4954
+ * Recommended by ESLint, the rule was enabled in `eslint:recommended`.
4955
+ *
4947
4956
  * @since 9.35.0
4948
4957
  * @see https://eslint.org/docs/latest/rules/preserve-caught-error
4949
4958
  */
@@ -5026,7 +5035,7 @@ export interface ESLintRules extends Linter.RulesRecord {
5026
5035
  >;
5027
5036
 
5028
5037
  /**
5029
- * Rule to enforce the consistent use of the radix argument when using `parseInt()`.
5038
+ * Rule to enforce the use of the radix argument when using `parseInt()`.
5030
5039
  *
5031
5040
  * @since 0.0.7
5032
5041
  * @see https://eslint.org/docs/latest/rules/radix
@@ -25,63 +25,10 @@
25
25
  * SOFTWARE
26
26
  */
27
27
 
28
- import { ESLint, Rule } from "./index.js";
28
+ import { Rule } from "./index.js";
29
29
 
30
30
  /** @deprecated */
31
31
  export const builtinRules: Map<string, Rule.RuleModule>;
32
32
 
33
- /** @deprecated */
34
- export class FileEnumerator {
35
- constructor(params?: {
36
- cwd?: string;
37
- configArrayFactory?: any;
38
- extensions?: any;
39
- globInputPaths?: boolean;
40
- errorOnUnmatchedPattern?: boolean;
41
- ignore?: boolean;
42
- });
43
- isTargetPath(filePath: string, providedConfig?: any): boolean;
44
- iterateFiles(
45
- patternOrPatterns: string | string[],
46
- ): IterableIterator<{ config: any; filePath: string; ignored: boolean }>;
47
- }
48
-
49
- export { /** @deprecated */ ESLint as FlatESLint };
50
-
51
- /** @deprecated */
52
- export class LegacyESLint {
53
- static configType: "eslintrc";
54
-
55
- static readonly version: string;
56
-
57
- static outputFixes(results: ESLint.LintResult[]): Promise<void>;
58
-
59
- static getErrorResults(results: ESLint.LintResult[]): ESLint.LintResult[];
60
-
61
- constructor(options?: ESLint.LegacyOptions);
62
-
63
- lintFiles(patterns: string | string[]): Promise<ESLint.LintResult[]>;
64
-
65
- lintText(
66
- code: string,
67
- options?: {
68
- filePath?: string | undefined;
69
- warnIgnored?: boolean | undefined;
70
- },
71
- ): Promise<ESLint.LintResult[]>;
72
-
73
- getRulesMetaForResults(
74
- results: ESLint.LintResult[],
75
- ): ESLint.LintResultData["rulesMeta"];
76
-
77
- hasFlag(flag: string): false;
78
-
79
- calculateConfigForFile(filePath: string): Promise<any>;
80
-
81
- isPathIgnored(filePath: string): Promise<boolean>;
82
-
83
- loadFormatter(nameOrPath?: string): Promise<ESLint.Formatter>;
84
- }
85
-
86
33
  /** @deprecated */
87
34
  export function shouldUseFlatConfig(): Promise<boolean>;
@@ -11,9 +11,7 @@
11
11
  // Requirements
12
12
  //-----------------------------------------------------------------------------
13
13
 
14
- const { FileEnumerator } = require("./cli-engine/file-enumerator");
15
- const { ESLint: FlatESLint, shouldUseFlatConfig } = require("./eslint/eslint");
16
- const { LegacyESLint } = require("./eslint/legacy-eslint");
14
+ const { shouldUseFlatConfig } = require("./eslint/eslint");
17
15
  const builtinRules = require("./rules");
18
16
 
19
17
  //-----------------------------------------------------------------------------
@@ -22,8 +20,7 @@ const builtinRules = require("./rules");
22
20
 
23
21
  module.exports = {
24
22
  builtinRules,
25
- FlatESLint,
23
+ FlatESLint: null,
24
+ LegacyESLint: null,
26
25
  shouldUseFlatConfig,
27
- FileEnumerator,
28
- LegacyESLint,
29
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "9.39.1",
3
+ "version": "10.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
  "type": "commonjs",
@@ -108,12 +108,10 @@
108
108
  "dependencies": {
109
109
  "@eslint-community/eslint-utils": "^4.8.0",
110
110
  "@eslint-community/regexpp": "^4.12.1",
111
- "@eslint/config-array": "^0.21.1",
112
- "@eslint/config-helpers": "^0.4.2",
113
- "@eslint/core": "^0.17.0",
114
- "@eslint/eslintrc": "^3.3.1",
115
- "@eslint/js": "9.39.1",
116
- "@eslint/plugin-kit": "^0.4.1",
111
+ "@eslint/config-array": "^0.23.0",
112
+ "@eslint/config-helpers": "^0.5.0",
113
+ "@eslint/core": "^1.0.0",
114
+ "@eslint/plugin-kit": "^0.5.0",
117
115
  "@humanfs/node": "^0.16.6",
118
116
  "@humanwhocodes/module-importer": "^1.0.1",
119
117
  "@humanwhocodes/retry": "^0.4.2",
@@ -123,9 +121,9 @@
123
121
  "cross-spawn": "^7.0.6",
124
122
  "debug": "^4.3.2",
125
123
  "escape-string-regexp": "^4.0.0",
126
- "eslint-scope": "^8.4.0",
127
- "eslint-visitor-keys": "^4.2.1",
128
- "espree": "^10.4.0",
124
+ "eslint-scope": "^9.0.0",
125
+ "eslint-visitor-keys": "^5.0.0",
126
+ "espree": "^11.0.0",
129
127
  "esquery": "^1.5.0",
130
128
  "esutils": "^2.0.2",
131
129
  "fast-deep-equal": "^3.1.3",
@@ -136,8 +134,7 @@
136
134
  "imurmurhash": "^0.1.4",
137
135
  "is-glob": "^4.0.0",
138
136
  "json-stable-stringify-without-jsonify": "^1.0.1",
139
- "lodash.merge": "^4.6.2",
140
- "minimatch": "^3.1.2",
137
+ "minimatch": "^10.1.1",
141
138
  "natural-compare": "^1.4.0",
142
139
  "optionator": "^0.9.3"
143
140
  },
@@ -146,11 +143,12 @@
146
143
  "@babel/core": "^7.4.3",
147
144
  "@babel/preset-env": "^7.4.3",
148
145
  "@cypress/webpack-preprocessor": "^6.0.2",
149
- "@eslint/json": "^0.13.2",
146
+ "@eslint/json": "^0.14.0",
147
+ "@eslint/eslintrc": "^3.3.1",
150
148
  "@trunkio/launcher": "^1.3.4",
151
149
  "@types/esquery": "^1.5.4",
152
150
  "@types/node": "^22.13.14",
153
- "@typescript-eslint/parser": "^8.4.0",
151
+ "@typescript-eslint/parser": "file:tools/typescript-eslint-parser",
154
152
  "babel-loader": "^8.0.5",
155
153
  "c8": "^7.12.0",
156
154
  "chai": "^4.0.1",
@@ -165,18 +163,15 @@
165
163
  "eslint-plugin-expect-type": "^0.6.0",
166
164
  "eslint-plugin-yml": "^1.14.0",
167
165
  "eslint-release": "^3.3.0",
168
- "eslint-rule-composer": "^0.3.0",
166
+ "eslint-rule-extender": "^0.0.1",
169
167
  "eslump": "^3.0.0",
170
168
  "esprima": "^4.0.1",
171
- "fast-glob": "^3.2.11",
172
169
  "fs-teardown": "^0.1.3",
173
170
  "glob": "^10.0.0",
174
171
  "globals": "^16.2.0",
175
172
  "got": "^11.8.3",
176
173
  "gray-matter": "^4.0.3",
177
174
  "jiti": "^2.6.1",
178
- "jiti-v2.0": "npm:jiti@2.0.x",
179
- "jiti-v2.1": "npm:jiti@2.1.x",
180
175
  "knip": "^5.60.2",
181
176
  "lint-staged": "^11.0.0",
182
177
  "markdown-it": "^12.2.0",
@@ -191,7 +186,7 @@
191
186
  "mocha": "^11.7.1",
192
187
  "node-polyfill-webpack-plugin": "^1.0.3",
193
188
  "npm-license": "^0.3.3",
194
- "pirates": "^4.0.5",
189
+ "prettier": "3.5.3",
195
190
  "progress": "^2.0.3",
196
191
  "proxyquire": "^2.0.1",
197
192
  "recast": "^0.23.0",
@@ -221,6 +216,6 @@
221
216
  ],
222
217
  "license": "MIT",
223
218
  "engines": {
224
- "node": "^18.18.0 || ^20.9.0 || >=21.1.0"
219
+ "node": "^20.19.0 || ^22.13.0 || >=24"
225
220
  }
226
221
  }
@@ -1,32 +0,0 @@
1
- /**
2
- * @fileoverview Default CLIEngineOptions.
3
- * @author Ian VanSchooten
4
- */
5
-
6
- "use strict";
7
-
8
- module.exports = {
9
- configFile: null,
10
- baseConfig: false,
11
- rulePaths: [],
12
- useEslintrc: true,
13
- envs: [],
14
- globals: [],
15
- extensions: null,
16
- ignore: true,
17
- ignorePath: void 0,
18
- cache: false,
19
-
20
- /*
21
- * in order to honor the cacheFile option if specified
22
- * this option should not have a default value otherwise
23
- * it will always be used
24
- */
25
- cacheLocation: "",
26
- cacheFile: ".eslintcache",
27
- cacheStrategy: "metadata",
28
- fix: false,
29
- allowInlineConfig: true,
30
- reportUnusedDisableDirectives: void 0,
31
- globInputPaths: true,
32
- };