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