eslint 9.25.1 → 9.27.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.
Files changed (40) hide show
  1. package/README.md +44 -39
  2. package/bin/eslint.js +15 -0
  3. package/conf/rule-type-list.json +2 -1
  4. package/lib/cli-engine/cli-engine.js +8 -8
  5. package/lib/cli.js +6 -5
  6. package/lib/config/config-loader.js +10 -18
  7. package/lib/config/config.js +328 -5
  8. package/lib/eslint/eslint-helpers.js +3 -1
  9. package/lib/eslint/eslint.js +31 -17
  10. package/lib/eslint/legacy-eslint.js +7 -7
  11. package/lib/languages/js/index.js +4 -3
  12. package/lib/languages/js/source-code/source-code.js +10 -6
  13. package/lib/linter/apply-disable-directives.js +1 -1
  14. package/lib/linter/esquery.js +329 -0
  15. package/lib/linter/file-context.js +11 -0
  16. package/lib/linter/linter.js +81 -89
  17. package/lib/linter/node-event-generator.js +94 -251
  18. package/lib/linter/report-translator.js +2 -1
  19. package/lib/options.js +11 -0
  20. package/lib/rule-tester/rule-tester.js +17 -9
  21. package/lib/rules/eqeqeq.js +31 -8
  22. package/lib/rules/index.js +2 -1
  23. package/lib/rules/max-params.js +32 -7
  24. package/lib/rules/no-array-constructor.js +51 -1
  25. package/lib/rules/no-shadow-restricted-names.js +25 -2
  26. package/lib/rules/no-unassigned-vars.js +72 -0
  27. package/lib/rules/no-unused-expressions.js +7 -1
  28. package/lib/rules/no-useless-escape.js +24 -2
  29. package/lib/rules/prefer-named-capture-group.js +7 -1
  30. package/lib/rules/utils/lazy-loading-rule-map.js +2 -2
  31. package/lib/services/processor-service.js +1 -2
  32. package/lib/services/suppressions-service.js +5 -3
  33. package/lib/shared/flags.js +1 -0
  34. package/lib/shared/serialization.js +29 -6
  35. package/lib/types/index.d.ts +126 -6
  36. package/lib/types/rules.d.ts +33 -2
  37. package/package.json +7 -6
  38. package/lib/config/flat-config-helpers.js +0 -128
  39. package/lib/config/rule-validator.js +0 -199
  40. package/lib/shared/types.js +0 -246
@@ -1,246 +0,0 @@
1
- /**
2
- * @fileoverview Define common types for input completion.
3
- * @author Toru Nagashima <https://github.com/mysticatea>
4
- */
5
- "use strict";
6
-
7
- /** @type {any} */
8
- module.exports = {};
9
-
10
- /** @typedef {boolean | "off" | "readable" | "readonly" | "writable" | "writeable"} GlobalConf */
11
- /** @typedef {0 | 1 | 2 | "off" | "warn" | "error"} SeverityConf */
12
- /** @typedef {SeverityConf | [SeverityConf, ...any[]]} RuleConf */
13
-
14
- /**
15
- * @typedef {Object} EcmaFeatures
16
- * @property {boolean} [globalReturn] Enabling `return` statements at the top-level.
17
- * @property {boolean} [jsx] Enabling JSX syntax.
18
- * @property {boolean} [impliedStrict] Enabling strict mode always.
19
- */
20
-
21
- /**
22
- * @typedef {Object} ParserOptions
23
- * @property {EcmaFeatures} [ecmaFeatures] The optional features.
24
- * @property {3|5|6|7|8|9|10|11|12|13|14|15|16|2015|2016|2017|2018|2019|2020|2021|2022|2023|2024|2025} [ecmaVersion] The ECMAScript version (or revision number).
25
- * @property {"script"|"module"} [sourceType] The source code type.
26
- * @property {boolean} [allowReserved] Allowing the use of reserved words as identifiers in ES3.
27
- */
28
-
29
- /**
30
- * @typedef {Object} LanguageOptions
31
- * @property {number|"latest"} [ecmaVersion] The ECMAScript version (or revision number).
32
- * @property {Record<string, GlobalConf>} [globals] The global variable settings.
33
- * @property {"script"|"module"|"commonjs"} [sourceType] The source code type.
34
- * @property {string|Object} [parser] The parser to use.
35
- * @property {Object} [parserOptions] The parser options to use.
36
- */
37
-
38
- /**
39
- * @typedef {Object} ConfigData
40
- * @property {Record<string, boolean>} [env] The environment settings.
41
- * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
42
- * @property {Record<string, GlobalConf>} [globals] The global variable settings.
43
- * @property {string | string[]} [ignorePatterns] The glob patterns that ignore to lint.
44
- * @property {boolean} [noInlineConfig] The flag that disables directive comments.
45
- * @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
46
- * @property {string} [parser] The path to a parser or the package name of a parser.
47
- * @property {ParserOptions} [parserOptions] The parser options.
48
- * @property {string[]} [plugins] The plugin specifiers.
49
- * @property {string} [processor] The processor specifier.
50
- * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments.
51
- * @property {boolean} [root] The root flag.
52
- * @property {Record<string, RuleConf>} [rules] The rule settings.
53
- * @property {Object} [settings] The shared settings.
54
- */
55
-
56
- /**
57
- * @typedef {Object} OverrideConfigData
58
- * @property {Record<string, boolean>} [env] The environment settings.
59
- * @property {string | string[]} [excludedFiles] The glob patterns for excluded files.
60
- * @property {string | string[]} [extends] The path to other config files or the package name of shareable configs.
61
- * @property {string | string[]} files The glob patterns for target files.
62
- * @property {Record<string, GlobalConf>} [globals] The global variable settings.
63
- * @property {boolean} [noInlineConfig] The flag that disables directive comments.
64
- * @property {OverrideConfigData[]} [overrides] The override settings per kind of files.
65
- * @property {string} [parser] The path to a parser or the package name of a parser.
66
- * @property {ParserOptions} [parserOptions] The parser options.
67
- * @property {string[]} [plugins] The plugin specifiers.
68
- * @property {string} [processor] The processor specifier.
69
- * @property {boolean} [reportUnusedDisableDirectives] The flag to report unused `eslint-disable` comments.
70
- * @property {Record<string, RuleConf>} [rules] The rule settings.
71
- * @property {Object} [settings] The shared settings.
72
- */
73
-
74
- /**
75
- * @typedef {Object} ParseResult
76
- * @property {Object} ast The AST.
77
- * @property {ScopeManager} [scopeManager] The scope manager of the AST.
78
- * @property {Record<string, any>} [services] The services that the parser provides.
79
- * @property {Record<string, string[]>} [visitorKeys] The visitor keys of the AST.
80
- */
81
-
82
- /**
83
- * @typedef {Object} Parser
84
- * @property {(text:string, options:ParserOptions) => Object} parse The definition of global variables.
85
- * @property {(text:string, options:ParserOptions) => ParseResult} [parseForESLint] The parser options that will be enabled under this environment.
86
- */
87
-
88
- /**
89
- * @typedef {Object} Environment
90
- * @property {Record<string, GlobalConf>} [globals] The definition of global variables.
91
- * @property {ParserOptions} [parserOptions] The parser options that will be enabled under this environment.
92
- */
93
-
94
- /**
95
- * @typedef {Object} LintMessage
96
- * @property {number|undefined} column The 1-based column number.
97
- * @property {number} [endColumn] The 1-based column number of the end location.
98
- * @property {number} [endLine] The 1-based line number of the end location.
99
- * @property {boolean} [fatal] If `true` then this is a fatal error.
100
- * @property {{range:[number,number], text:string}} [fix] Information for autofix.
101
- * @property {number|undefined} line The 1-based line number.
102
- * @property {string} message The error message.
103
- * @property {string} [messageId] The ID of the message in the rule's meta.
104
- * @property {(string|null)} nodeType Type of node
105
- * @property {string|null} ruleId The ID of the rule which makes this message.
106
- * @property {0|1|2} severity The severity of this message.
107
- * @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions.
108
- */
109
-
110
- /**
111
- * @typedef {Object} SuppressedLintMessage
112
- * @property {number|undefined} column The 1-based column number.
113
- * @property {number} [endColumn] The 1-based column number of the end location.
114
- * @property {number} [endLine] The 1-based line number of the end location.
115
- * @property {boolean} [fatal] If `true` then this is a fatal error.
116
- * @property {{range:[number,number], text:string}} [fix] Information for autofix.
117
- * @property {number|undefined} line The 1-based line number.
118
- * @property {string} message The error message.
119
- * @property {string} [messageId] The ID of the message in the rule's meta.
120
- * @property {(string|null)} nodeType Type of node
121
- * @property {string|null} ruleId The ID of the rule which makes this message.
122
- * @property {0|1|2} severity The severity of this message.
123
- * @property {Array<{kind: string, justification: string}>} suppressions The suppression info.
124
- * @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions.
125
- */
126
-
127
- /**
128
- * @typedef {Record<string, Record<string, { count: number }>>} SuppressedViolations
129
- */
130
-
131
- /**
132
- * @typedef {Object} SuggestionResult
133
- * @property {string} desc A short description.
134
- * @property {string} [messageId] Id referencing a message for the description.
135
- * @property {{ text: string, range: number[] }} fix fix result info
136
- */
137
-
138
- /**
139
- * @typedef {Object} Processor
140
- * @property {(text:string, filename:string) => Array<string | { text:string, filename:string }>} [preprocess] The function to extract code blocks.
141
- * @property {(messagesList:LintMessage[][], filename:string) => LintMessage[]} [postprocess] The function to merge messages.
142
- * @property {boolean} [supportsAutofix] If `true` then it means the processor supports autofix.
143
- */
144
-
145
- /**
146
- * @typedef {Object} RuleMetaDocs
147
- * @property {string} description The description of the rule.
148
- * @property {boolean} recommended If `true` then the rule is included in `eslint:recommended` preset.
149
- * @property {string} url The URL of the rule documentation.
150
- */
151
-
152
- /**
153
- * @typedef {Object} DeprecatedInfo
154
- * @property {string} [message] General message presented to the user
155
- * @property {string} [url] URL to more information about this deprecation in general
156
- * @property {ReplacedByInfo[]} [replacedBy] Potential replacements for the rule
157
- * @property {string} [deprecatedSince] Version since the rule is deprecated
158
- * @property {?string} [availableUntil] Version until it is available or null if indefinite
159
- */
160
-
161
- /**
162
- * @typedef {Object} ReplacedByInfo
163
- * @property {string} [message] General message presented to the user
164
- * @property {string} [url] URL to more information about this replacement in general
165
- * @property {{ name?: string, url?: string }} [plugin] Use "eslint" for a core rule. Omit if the rule is in the same plugin.
166
- * @property {{ name?: string, url?: string }} [rule] Name and information of the replacement rule
167
- */
168
-
169
- /**
170
- * @typedef {Object} Plugin
171
- * @property {Record<string, ConfigData>} [configs] The definition of plugin configs.
172
- * @property {Record<string, Environment>} [environments] The definition of plugin environments.
173
- * @property {Record<string, Processor>} [processors] The definition of plugin processors.
174
- * @property {Record<string, Rule>} [rules] The definition of plugin rules.
175
- */
176
-
177
- /**
178
- * Information of deprecated rules.
179
- * @typedef {Object} DeprecatedRuleInfo
180
- * @property {string} ruleId The rule ID.
181
- * @property {string[]} replacedBy The rule IDs that replace this deprecated rule.
182
- * @property {DeprecatedInfo} [info] The raw deprecated info provided by rule. Unset if `deprecated` is a boolean.
183
- */
184
-
185
- /**
186
- * A linting result.
187
- * @typedef {Object} LintResult
188
- * @property {string} filePath The path to the file that was linted.
189
- * @property {LintMessage[]} messages All of the messages for the result.
190
- * @property {SuppressedLintMessage[]} suppressedMessages All of the suppressed messages for the result.
191
- * @property {number} errorCount Number of errors for the result.
192
- * @property {number} fatalErrorCount Number of fatal errors for the result.
193
- * @property {number} warningCount Number of warnings for the result.
194
- * @property {number} fixableErrorCount Number of fixable errors for the result.
195
- * @property {number} fixableWarningCount Number of fixable warnings for the result.
196
- * @property {Stats} [stats] The performance statistics collected with the `stats` flag.
197
- * @property {string} [source] The source code of the file that was linted.
198
- * @property {string} [output] The source code of the file that was linted, with as many fixes applied as possible.
199
- * @property {DeprecatedRuleInfo[]} usedDeprecatedRules The list of used deprecated rules.
200
- */
201
-
202
- /**
203
- * Performance statistics
204
- * @typedef {Object} Stats
205
- * @property {number} fixPasses The number of times ESLint has applied at least one fix after linting.
206
- * @property {Times} times The times spent on (parsing, fixing, linting) a file.
207
- */
208
-
209
- /**
210
- * Performance Times for each ESLint pass
211
- * @typedef {Object} Times
212
- * @property {TimePass[]} passes Time passes
213
- */
214
-
215
- /**
216
- * @typedef {Object} TimePass
217
- * @property {ParseTime} parse The parse object containing all parse time information.
218
- * @property {Record<string, RuleTime>} [rules] The rules object containing all lint time information for each rule.
219
- * @property {FixTime} fix The parse object containing all fix time information.
220
- * @property {number} total The total time that is spent on (parsing, fixing, linting) a file.
221
- */
222
- /**
223
- * @typedef {Object} ParseTime
224
- * @property {number} total The total time that is spent when parsing a file.
225
- */
226
- /**
227
- * @typedef {Object} RuleTime
228
- * @property {number} total The total time that is spent on a rule.
229
- */
230
- /**
231
- * @typedef {Object} FixTime
232
- * @property {number} total The total time that is spent on applying fixes to the code.
233
- */
234
-
235
- /**
236
- * Information provided when the maximum warning threshold is exceeded.
237
- * @typedef {Object} MaxWarningsExceeded
238
- * @property {number} maxWarnings Number of warnings to trigger nonzero exit code.
239
- * @property {number} foundWarnings Number of warnings found while linting.
240
- */
241
-
242
- /**
243
- * Metadata about results for formatters.
244
- * @typedef {Object} ResultsMeta
245
- * @property {MaxWarningsExceeded} [maxWarningsExceeded] Present if the maxWarnings threshold was exceeded.
246
- */