eslint 9.39.1 → 10.0.0-alpha.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.
- package/README.md +3 -3
- package/bin/eslint.js +1 -2
- package/lib/api.js +4 -15
- package/lib/cli.js +14 -56
- package/lib/config/config-loader.js +6 -154
- package/lib/eslint/eslint-helpers.js +5 -8
- package/lib/eslint/eslint.js +1 -1
- package/lib/eslint/index.js +0 -2
- package/lib/languages/js/source-code/source-code.js +39 -87
- package/lib/languages/js/source-code/token-store/utils.js +29 -8
- package/lib/linter/apply-disable-directives.js +0 -1
- package/lib/linter/file-context.js +0 -56
- package/lib/linter/file-report.js +0 -4
- package/lib/linter/linter.js +45 -1086
- package/lib/linter/rule-fixer.js +30 -0
- package/lib/options.js +62 -182
- package/lib/rule-tester/rule-tester.js +255 -194
- package/lib/rules/dot-notation.js +2 -2
- package/lib/rules/func-names.js +2 -0
- package/lib/rules/no-eval.js +1 -1
- package/lib/rules/no-invalid-regexp.js +1 -0
- package/lib/rules/no-shadow-restricted-names.js +1 -1
- package/lib/rules/no-unassigned-vars.js +1 -1
- package/lib/rules/no-useless-assignment.js +1 -1
- package/lib/rules/preserve-caught-error.js +1 -1
- package/lib/rules/radix.js +25 -48
- package/lib/services/parser-service.js +0 -1
- package/lib/services/processor-service.js +0 -1
- package/lib/services/warning-service.js +0 -11
- package/lib/shared/flags.js +0 -19
- package/lib/shared/translate-cli-options.js +106 -164
- package/lib/types/index.d.ts +7 -60
- package/lib/types/rules.d.ts +11 -2
- package/lib/types/use-at-your-own-risk.d.ts +1 -54
- package/lib/unsupported-api.js +3 -6
- package/package.json +14 -19
- package/conf/default-cli-options.js +0 -32
- package/lib/cli-engine/cli-engine.js +0 -1109
- package/lib/cli-engine/file-enumerator.js +0 -541
- package/lib/cli-engine/index.js +0 -7
- package/lib/cli-engine/load-rules.js +0 -46
- package/lib/eslint/legacy-eslint.js +0 -786
package/lib/rules/radix.js
CHANGED
|
@@ -15,9 +15,6 @@ const astUtils = require("./utils/ast-utils");
|
|
|
15
15
|
// Helpers
|
|
16
16
|
//------------------------------------------------------------------------------
|
|
17
17
|
|
|
18
|
-
const MODE_ALWAYS = "always",
|
|
19
|
-
MODE_AS_NEEDED = "as-needed";
|
|
20
|
-
|
|
21
18
|
const validRadixValues = new Set(
|
|
22
19
|
Array.from({ length: 37 - 2 }, (_, index) => index + 2),
|
|
23
20
|
);
|
|
@@ -63,15 +60,6 @@ function isValidRadix(radix) {
|
|
|
63
60
|
);
|
|
64
61
|
}
|
|
65
62
|
|
|
66
|
-
/**
|
|
67
|
-
* Checks whether a given node is a default value of radix or not.
|
|
68
|
-
* @param {ASTNode} radix A node of radix to check.
|
|
69
|
-
* @returns {boolean} `true` if the node is the literal node of `10`.
|
|
70
|
-
*/
|
|
71
|
-
function isDefaultRadix(radix) {
|
|
72
|
-
return radix.type === "Literal" && radix.value === 10;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
63
|
//------------------------------------------------------------------------------
|
|
76
64
|
// Rule Definition
|
|
77
65
|
//------------------------------------------------------------------------------
|
|
@@ -81,11 +69,9 @@ module.exports = {
|
|
|
81
69
|
meta: {
|
|
82
70
|
type: "suggestion",
|
|
83
71
|
|
|
84
|
-
defaultOptions: [MODE_ALWAYS],
|
|
85
|
-
|
|
86
72
|
docs: {
|
|
87
73
|
description:
|
|
88
|
-
"Enforce the
|
|
74
|
+
"Enforce the use of the radix argument when using `parseInt()`",
|
|
89
75
|
recommended: false,
|
|
90
76
|
url: "https://eslint.org/docs/latest/rules/radix",
|
|
91
77
|
},
|
|
@@ -93,6 +79,7 @@ module.exports = {
|
|
|
93
79
|
hasSuggestions: true,
|
|
94
80
|
|
|
95
81
|
schema: [
|
|
82
|
+
// deprecated
|
|
96
83
|
{
|
|
97
84
|
enum: ["always", "as-needed"],
|
|
98
85
|
},
|
|
@@ -100,7 +87,6 @@ module.exports = {
|
|
|
100
87
|
|
|
101
88
|
messages: {
|
|
102
89
|
missingParameters: "Missing parameters.",
|
|
103
|
-
redundantRadix: "Redundant radix parameter.",
|
|
104
90
|
missingRadix: "Missing radix parameter.",
|
|
105
91
|
invalidRadix:
|
|
106
92
|
"Invalid radix parameter, must be an integer between 2 and 36.",
|
|
@@ -110,7 +96,6 @@ module.exports = {
|
|
|
110
96
|
},
|
|
111
97
|
|
|
112
98
|
create(context) {
|
|
113
|
-
const [mode] = context.options;
|
|
114
99
|
const sourceCode = context.sourceCode;
|
|
115
100
|
|
|
116
101
|
/**
|
|
@@ -131,41 +116,33 @@ module.exports = {
|
|
|
131
116
|
break;
|
|
132
117
|
|
|
133
118
|
case 1:
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
hasTrailingComma ? " 10," : ", 10",
|
|
154
|
-
);
|
|
155
|
-
},
|
|
119
|
+
context.report({
|
|
120
|
+
node,
|
|
121
|
+
messageId: "missingRadix",
|
|
122
|
+
suggest: [
|
|
123
|
+
{
|
|
124
|
+
messageId: "addRadixParameter10",
|
|
125
|
+
fix(fixer) {
|
|
126
|
+
const tokens = sourceCode.getTokens(node);
|
|
127
|
+
const lastToken = tokens.at(-1); // Parenthesis.
|
|
128
|
+
const secondToLastToken = tokens.at(-2); // May or may not be a comma.
|
|
129
|
+
const hasTrailingComma =
|
|
130
|
+
secondToLastToken.type ===
|
|
131
|
+
"Punctuator" &&
|
|
132
|
+
secondToLastToken.value === ",";
|
|
133
|
+
|
|
134
|
+
return fixer.insertTextBefore(
|
|
135
|
+
lastToken,
|
|
136
|
+
hasTrailingComma ? " 10," : ", 10",
|
|
137
|
+
);
|
|
156
138
|
},
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
});
|
|
160
142
|
break;
|
|
161
143
|
|
|
162
144
|
default:
|
|
163
|
-
if (
|
|
164
|
-
context.report({
|
|
165
|
-
node,
|
|
166
|
-
messageId: "redundantRadix",
|
|
167
|
-
});
|
|
168
|
-
} else if (!isValidRadix(args[1])) {
|
|
145
|
+
if (!isValidRadix(args[1])) {
|
|
169
146
|
context.report({
|
|
170
147
|
node,
|
|
171
148
|
messageId: "invalidRadix",
|
|
@@ -59,17 +59,6 @@ class WarningService {
|
|
|
59
59
|
);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
/**
|
|
63
|
-
* Emits a warning when the ESLINT_USE_FLAT_CONFIG environment variable is set to "false".
|
|
64
|
-
* @returns {void}
|
|
65
|
-
*/
|
|
66
|
-
emitESLintRCWarning() {
|
|
67
|
-
this.emitWarning(
|
|
68
|
-
"You are using an eslintrc configuration file, which is deprecated and support will be removed in v10.0.0. Please migrate to an eslint.config.js file. See https://eslint.org/docs/latest/use/configure/migration-guide for details. An eslintrc configuration file is used because you have the ESLINT_USE_FLAT_CONFIG environment variable set to false. If you want to use an eslint.config.js file, remove the environment variable. If you want to find the location of the eslintrc configuration file, use the --debug flag.",
|
|
69
|
-
"ESLintRCWarning",
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
62
|
/**
|
|
74
63
|
* Emits a warning when an inactive flag is used.
|
|
75
64
|
* This method is used by the Linter and is safe to call outside Node.js.
|
package/lib/shared/flags.js
CHANGED
|
@@ -28,10 +28,6 @@
|
|
|
28
28
|
const activeFlags = new Map([
|
|
29
29
|
["test_only", "Used only for testing."],
|
|
30
30
|
["test_only_2", "Used only for testing."],
|
|
31
|
-
[
|
|
32
|
-
"v10_config_lookup_from_file",
|
|
33
|
-
"Look up `eslint.config.js` from the file being linted.",
|
|
34
|
-
],
|
|
35
31
|
[
|
|
36
32
|
"unstable_native_nodejs_ts_config",
|
|
37
33
|
"Use native Node.js to load TypeScript configuration.",
|
|
@@ -66,21 +62,6 @@ const inactiveFlags = new Map([
|
|
|
66
62
|
"Used only for testing flags whose features have been abandoned.",
|
|
67
63
|
},
|
|
68
64
|
],
|
|
69
|
-
[
|
|
70
|
-
"unstable_ts_config",
|
|
71
|
-
{
|
|
72
|
-
description: "Enable TypeScript configuration files.",
|
|
73
|
-
replacedBy: null,
|
|
74
|
-
},
|
|
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
|
-
],
|
|
84
65
|
]);
|
|
85
66
|
|
|
86
67
|
/**
|
|
@@ -19,7 +19,6 @@ const { ModuleImporter } = require("@humanwhocodes/module-importer");
|
|
|
19
19
|
//------------------------------------------------------------------------------
|
|
20
20
|
|
|
21
21
|
/** @typedef {import("../types").ESLint.Options} ESLintOptions */
|
|
22
|
-
/** @typedef {import("../types").ESLint.LegacyOptions} LegacyESLintOptions */
|
|
23
22
|
/** @typedef {import("../types").Linter.LintMessage} LintMessage */
|
|
24
23
|
/** @typedef {import("../options").ParsedCLIOptions} ParsedCLIOptions */
|
|
25
24
|
/** @typedef {import("../types").ESLint.Plugin} Plugin */
|
|
@@ -85,196 +84,139 @@ function quietRuleFilter(rule) {
|
|
|
85
84
|
/**
|
|
86
85
|
* Translates the CLI options into the options expected by the ESLint constructor.
|
|
87
86
|
* @param {ParsedCLIOptions} cliOptions The CLI options to translate.
|
|
88
|
-
* @
|
|
89
|
-
* @returns {Promise<ESLintOptions | LegacyESLintOptions>} The options object for the ESLint constructor.
|
|
87
|
+
* @returns {Promise<ESLintOptions>} The options object for the ESLint constructor.
|
|
90
88
|
*/
|
|
91
|
-
async function translateOptions(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
rulesdir,
|
|
123
|
-
stats,
|
|
124
|
-
warnIgnored,
|
|
125
|
-
passOnNoPatterns,
|
|
126
|
-
maxWarnings,
|
|
127
|
-
},
|
|
128
|
-
configType,
|
|
129
|
-
) {
|
|
130
|
-
let overrideConfig, overrideConfigFile;
|
|
89
|
+
async function translateOptions({
|
|
90
|
+
cache,
|
|
91
|
+
cacheFile,
|
|
92
|
+
cacheLocation,
|
|
93
|
+
cacheStrategy,
|
|
94
|
+
concurrency,
|
|
95
|
+
config,
|
|
96
|
+
configLookup,
|
|
97
|
+
errorOnUnmatchedPattern,
|
|
98
|
+
ext,
|
|
99
|
+
fix,
|
|
100
|
+
fixDryRun,
|
|
101
|
+
fixType,
|
|
102
|
+
flag,
|
|
103
|
+
global,
|
|
104
|
+
ignore,
|
|
105
|
+
ignorePattern,
|
|
106
|
+
inlineConfig,
|
|
107
|
+
parser,
|
|
108
|
+
parserOptions,
|
|
109
|
+
plugin,
|
|
110
|
+
quiet,
|
|
111
|
+
reportUnusedDisableDirectives,
|
|
112
|
+
reportUnusedDisableDirectivesSeverity,
|
|
113
|
+
reportUnusedInlineConfigs,
|
|
114
|
+
rule,
|
|
115
|
+
stats,
|
|
116
|
+
warnIgnored,
|
|
117
|
+
passOnNoPatterns,
|
|
118
|
+
maxWarnings,
|
|
119
|
+
}) {
|
|
131
120
|
const importer = new ModuleImporter();
|
|
132
121
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const languageOptions = {};
|
|
141
|
-
|
|
142
|
-
if (global) {
|
|
143
|
-
languageOptions.globals = global.reduce((obj, name) => {
|
|
144
|
-
if (name.endsWith(":true")) {
|
|
145
|
-
obj[name.slice(0, -5)] = "writable";
|
|
146
|
-
} else {
|
|
147
|
-
obj[name] = "readonly";
|
|
148
|
-
}
|
|
149
|
-
return obj;
|
|
150
|
-
}, {});
|
|
151
|
-
}
|
|
122
|
+
let overrideConfigFile =
|
|
123
|
+
typeof config === "string" ? config : !configLookup;
|
|
124
|
+
if (overrideConfigFile === false) {
|
|
125
|
+
overrideConfigFile = void 0;
|
|
126
|
+
}
|
|
152
127
|
|
|
153
|
-
|
|
154
|
-
languageOptions.parserOptions = parserOptions;
|
|
155
|
-
}
|
|
128
|
+
const languageOptions = {};
|
|
156
129
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
130
|
+
if (global) {
|
|
131
|
+
languageOptions.globals = global.reduce((obj, name) => {
|
|
132
|
+
if (name.endsWith(":true")) {
|
|
133
|
+
obj[name.slice(0, -5)] = "writable";
|
|
134
|
+
} else {
|
|
135
|
+
obj[name] = "readonly";
|
|
136
|
+
}
|
|
137
|
+
return obj;
|
|
138
|
+
}, {});
|
|
139
|
+
}
|
|
160
140
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
? { languageOptions }
|
|
165
|
-
: {}),
|
|
166
|
-
rules: rule ? rule : {},
|
|
167
|
-
},
|
|
168
|
-
];
|
|
141
|
+
if (parserOptions) {
|
|
142
|
+
languageOptions.parserOptions = parserOptions;
|
|
143
|
+
}
|
|
169
144
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
) {
|
|
174
|
-
overrideConfig[0].linterOptions = {
|
|
175
|
-
reportUnusedDisableDirectives: reportUnusedDisableDirectives
|
|
176
|
-
? "error"
|
|
177
|
-
: normalizeSeverityToString(
|
|
178
|
-
reportUnusedDisableDirectivesSeverity,
|
|
179
|
-
),
|
|
180
|
-
};
|
|
181
|
-
}
|
|
145
|
+
if (parser) {
|
|
146
|
+
languageOptions.parser = await importer.import(parser);
|
|
147
|
+
}
|
|
182
148
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
149
|
+
const overrideConfig = [
|
|
150
|
+
{
|
|
151
|
+
...(Object.keys(languageOptions).length > 0
|
|
152
|
+
? { languageOptions }
|
|
153
|
+
: {}),
|
|
154
|
+
rules: rule ? rule : {},
|
|
155
|
+
},
|
|
156
|
+
];
|
|
157
|
+
|
|
158
|
+
if (
|
|
159
|
+
reportUnusedDisableDirectives ||
|
|
160
|
+
reportUnusedDisableDirectivesSeverity !== void 0
|
|
161
|
+
) {
|
|
162
|
+
overrideConfig[0].linterOptions = {
|
|
163
|
+
reportUnusedDisableDirectives: reportUnusedDisableDirectives
|
|
164
|
+
? "error"
|
|
165
|
+
: normalizeSeverityToString(
|
|
166
|
+
reportUnusedDisableDirectivesSeverity,
|
|
167
|
+
),
|
|
168
|
+
};
|
|
169
|
+
}
|
|
191
170
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
171
|
+
if (reportUnusedInlineConfigs !== void 0) {
|
|
172
|
+
overrideConfig[0].linterOptions = {
|
|
173
|
+
...overrideConfig[0].linterOptions,
|
|
174
|
+
reportUnusedInlineConfigs: normalizeSeverityToString(
|
|
175
|
+
reportUnusedInlineConfigs,
|
|
176
|
+
),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
195
179
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
extension =>
|
|
200
|
-
`**/*${extension.startsWith(".") ? "" : "."}${extension}`,
|
|
201
|
-
),
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
} else {
|
|
205
|
-
overrideConfigFile = config;
|
|
180
|
+
if (plugin) {
|
|
181
|
+
overrideConfig[0].plugins = await loadPlugins(importer, plugin);
|
|
182
|
+
}
|
|
206
183
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
globals:
|
|
215
|
-
global &&
|
|
216
|
-
global.reduce((obj, name) => {
|
|
217
|
-
if (name.endsWith(":true")) {
|
|
218
|
-
obj[name.slice(0, -5)] = "writable";
|
|
219
|
-
} else {
|
|
220
|
-
obj[name] = "readonly";
|
|
221
|
-
}
|
|
222
|
-
return obj;
|
|
223
|
-
}, {}),
|
|
224
|
-
ignorePatterns: ignorePattern,
|
|
225
|
-
parser,
|
|
226
|
-
parserOptions,
|
|
227
|
-
plugins: plugin,
|
|
228
|
-
rules: rule,
|
|
229
|
-
};
|
|
184
|
+
if (ext) {
|
|
185
|
+
overrideConfig.push({
|
|
186
|
+
files: ext.map(
|
|
187
|
+
extension =>
|
|
188
|
+
`**/*${extension.startsWith(".") ? "" : "."}${extension}`,
|
|
189
|
+
),
|
|
190
|
+
});
|
|
230
191
|
}
|
|
231
192
|
|
|
193
|
+
/*
|
|
194
|
+
* For performance reasons rules not marked as 'error' are filtered out in quiet mode. As maxWarnings
|
|
195
|
+
* requires rules set to 'warn' to be run, we only filter out 'warn' rules if maxWarnings is not specified.
|
|
196
|
+
*/
|
|
197
|
+
const ruleFilter =
|
|
198
|
+
quiet && maxWarnings === -1 ? quietRuleFilter : () => true;
|
|
199
|
+
|
|
232
200
|
const options = {
|
|
233
201
|
allowInlineConfig: inlineConfig,
|
|
234
202
|
cache,
|
|
235
203
|
cacheLocation: cacheLocation || cacheFile,
|
|
236
204
|
cacheStrategy,
|
|
205
|
+
concurrency,
|
|
237
206
|
errorOnUnmatchedPattern,
|
|
238
207
|
fix: (fix || fixDryRun) && (quiet ? quietFixPredicate : true),
|
|
239
208
|
fixTypes: fixType,
|
|
209
|
+
flags: flag,
|
|
240
210
|
ignore,
|
|
211
|
+
ignorePatterns: ignorePattern,
|
|
241
212
|
overrideConfig,
|
|
242
213
|
overrideConfigFile,
|
|
243
214
|
passOnNoPatterns,
|
|
215
|
+
ruleFilter,
|
|
216
|
+
stats,
|
|
217
|
+
warnIgnored,
|
|
244
218
|
};
|
|
245
219
|
|
|
246
|
-
if (configType === "flat") {
|
|
247
|
-
options.concurrency = concurrency;
|
|
248
|
-
options.flags = flag;
|
|
249
|
-
options.ignorePatterns = ignorePattern;
|
|
250
|
-
options.stats = stats;
|
|
251
|
-
options.warnIgnored = warnIgnored;
|
|
252
|
-
|
|
253
|
-
/*
|
|
254
|
-
* For performance reasons rules not marked as 'error' are filtered out in quiet mode. As maxWarnings
|
|
255
|
-
* requires rules set to 'warn' to be run, we only filter out 'warn' rules if maxWarnings is not specified.
|
|
256
|
-
*/
|
|
257
|
-
options.ruleFilter =
|
|
258
|
-
quiet && maxWarnings === -1 ? quietRuleFilter : () => true;
|
|
259
|
-
} else {
|
|
260
|
-
options.resolvePluginsRelativeTo = resolvePluginsRelativeTo;
|
|
261
|
-
options.rulePaths = rulesdir;
|
|
262
|
-
options.useEslintrc = eslintrc;
|
|
263
|
-
options.extensions = ext;
|
|
264
|
-
options.ignorePath = ignorePath;
|
|
265
|
-
if (
|
|
266
|
-
reportUnusedDisableDirectives ||
|
|
267
|
-
reportUnusedDisableDirectivesSeverity !== void 0
|
|
268
|
-
) {
|
|
269
|
-
options.reportUnusedDisableDirectives =
|
|
270
|
-
reportUnusedDisableDirectives
|
|
271
|
-
? "error"
|
|
272
|
-
: normalizeSeverityToString(
|
|
273
|
-
reportUnusedDisableDirectivesSeverity,
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
220
|
return options;
|
|
279
221
|
}
|
|
280
222
|
|
package/lib/types/index.d.ts
CHANGED
|
@@ -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 {
|
|
@@ -785,7 +786,7 @@ export namespace Rule {
|
|
|
785
786
|
type ReportFixer = CoreRuleFixer;
|
|
786
787
|
|
|
787
788
|
/** @deprecated Use `ReportDescriptorOptions` instead. */
|
|
788
|
-
type ReportDescriptorOptionsBase = ViolationReportBase
|
|
789
|
+
type ReportDescriptorOptionsBase = Omit<ViolationReportBase, "suggest">;
|
|
789
790
|
|
|
790
791
|
type SuggestionReportOptions = SuggestedEditBase;
|
|
791
792
|
type SuggestionDescriptorMessage = SuggestionMessage;
|
|
@@ -794,9 +795,9 @@ export namespace Rule {
|
|
|
794
795
|
// redundant with ReportDescriptorOptionsBase but kept for clarity
|
|
795
796
|
type ReportDescriptorOptions = ViolationReportBase;
|
|
796
797
|
|
|
797
|
-
type ReportDescriptor = ViolationReport<
|
|
798
|
+
type ReportDescriptor = ViolationReport<JSSyntaxElement>;
|
|
798
799
|
type ReportDescriptorMessage = ViolationMessage;
|
|
799
|
-
type ReportDescriptorLocation = ViolationLocation<
|
|
800
|
+
type ReportDescriptorLocation = ViolationLocation<JSSyntaxElement>;
|
|
800
801
|
|
|
801
802
|
type RuleFixer = RuleTextEditor<ESTree.Node | AST.Token>;
|
|
802
803
|
type Fix = RuleTextEdit;
|
|
@@ -823,10 +824,7 @@ export class Linter {
|
|
|
823
824
|
|
|
824
825
|
version: string;
|
|
825
826
|
|
|
826
|
-
constructor(options?: {
|
|
827
|
-
cwd?: string | undefined;
|
|
828
|
-
configType?: "flat" | "eslintrc";
|
|
829
|
-
});
|
|
827
|
+
constructor(options?: { cwd?: string | undefined; configType?: "flat" });
|
|
830
828
|
|
|
831
829
|
verify(
|
|
832
830
|
code: SourceCode | string,
|
|
@@ -852,14 +850,6 @@ export class Linter {
|
|
|
852
850
|
|
|
853
851
|
getSourceCode(): SourceCode;
|
|
854
852
|
|
|
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
853
|
getTimes(): Linter.Stats["times"];
|
|
864
854
|
|
|
865
855
|
getFixPassCount(): Linter.Stats["fixPasses"];
|
|
@@ -1233,39 +1223,6 @@ export namespace ESLint {
|
|
|
1233
1223
|
flags?: string[] | undefined;
|
|
1234
1224
|
}
|
|
1235
1225
|
|
|
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
1226
|
/** A linting result. */
|
|
1270
1227
|
interface LintResult {
|
|
1271
1228
|
/** The path to the file that was linted. */
|
|
@@ -1396,15 +1353,9 @@ export namespace ESLint {
|
|
|
1396
1353
|
|
|
1397
1354
|
// #endregion
|
|
1398
1355
|
|
|
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
1356
|
export function loadESLint(options?: {
|
|
1406
1357
|
useFlatConfig?: boolean | undefined;
|
|
1407
|
-
}): Promise<typeof ESLint
|
|
1358
|
+
}): Promise<typeof ESLint>;
|
|
1408
1359
|
|
|
1409
1360
|
// #region RuleTester
|
|
1410
1361
|
|
|
@@ -1457,10 +1408,6 @@ export namespace RuleTester {
|
|
|
1457
1408
|
interface TestCaseError {
|
|
1458
1409
|
message?: string | RegExp;
|
|
1459
1410
|
messageId?: string;
|
|
1460
|
-
/**
|
|
1461
|
-
* @deprecated `type` is deprecated and will be removed in the next major version.
|
|
1462
|
-
*/
|
|
1463
|
-
type?: string | undefined;
|
|
1464
1411
|
data?: any;
|
|
1465
1412
|
line?: number | undefined;
|
|
1466
1413
|
column?: number | undefined;
|
package/lib/types/rules.d.ts
CHANGED
|
@@ -3783,7 +3783,7 @@ export interface ESLintRules extends Linter.RulesRecord {
|
|
|
3783
3783
|
[
|
|
3784
3784
|
Partial<{
|
|
3785
3785
|
/**
|
|
3786
|
-
* @default
|
|
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
|
|
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
|