eslint 9.36.0 → 9.38.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 +11 -1
- package/lib/cli-engine/lint-result-cache.js +47 -29
- package/lib/eslint/eslint-helpers.js +7 -4
- package/lib/eslint/eslint.js +151 -37
- package/lib/eslint/worker.js +1 -3
- package/lib/linter/esquery.js +1 -1
- package/lib/rules/array-bracket-newline.js +1 -1
- package/lib/rules/array-bracket-spacing.js +1 -1
- package/lib/rules/array-element-newline.js +1 -1
- package/lib/rules/arrow-parens.js +1 -1
- package/lib/rules/arrow-spacing.js +1 -1
- package/lib/rules/block-spacing.js +1 -1
- package/lib/rules/brace-style.js +1 -1
- package/lib/rules/callback-return.js +1 -1
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/comma-style.js +1 -1
- package/lib/rules/complexity.js +6 -0
- package/lib/rules/computed-property-spacing.js +1 -1
- package/lib/rules/dot-location.js +1 -1
- package/lib/rules/eol-last.js +1 -1
- package/lib/rules/func-call-spacing.js +2 -2
- package/lib/rules/function-call-argument-newline.js +1 -1
- package/lib/rules/function-paren-newline.js +1 -1
- package/lib/rules/generator-star-spacing.js +1 -1
- package/lib/rules/global-require.js +1 -1
- package/lib/rules/handle-callback-err.js +1 -1
- package/lib/rules/id-blacklist.js +1 -1
- package/lib/rules/implicit-arrow-linebreak.js +1 -1
- package/lib/rules/indent-legacy.js +1 -0
- package/lib/rules/indent.js +1 -1
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/key-spacing.js +1 -1
- package/lib/rules/keyword-spacing.js +1 -1
- package/lib/rules/line-comment-position.js +1 -1
- package/lib/rules/linebreak-style.js +1 -1
- package/lib/rules/lines-around-comment.js +1 -1
- package/lib/rules/lines-around-directive.js +1 -1
- package/lib/rules/lines-between-class-members.js +1 -1
- package/lib/rules/max-len.js +1 -1
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/multiline-comment-style.js +1 -1
- package/lib/rules/multiline-ternary.js +1 -1
- package/lib/rules/new-parens.js +1 -1
- package/lib/rules/newline-after-var.js +1 -1
- package/lib/rules/newline-before-return.js +1 -1
- package/lib/rules/newline-per-chained-call.js +1 -1
- package/lib/rules/no-buffer-constructor.js +1 -1
- package/lib/rules/no-catch-shadow.js +1 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-extra-parens.js +1 -1
- package/lib/rules/no-extra-semi.js +1 -1
- package/lib/rules/no-floating-decimal.js +1 -1
- package/lib/rules/no-loss-of-precision.js +206 -211
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/no-mixed-requires.js +1 -1
- package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
- package/lib/rules/no-multi-spaces.js +1 -1
- package/lib/rules/no-multiple-empty-lines.js +1 -1
- package/lib/rules/no-native-reassign.js +1 -1
- package/lib/rules/no-negated-in-lhs.js +1 -1
- package/lib/rules/no-new-object.js +1 -1
- package/lib/rules/no-new-require.js +1 -1
- package/lib/rules/no-new-symbol.js +1 -1
- package/lib/rules/no-path-concat.js +1 -1
- package/lib/rules/no-process-env.js +1 -1
- package/lib/rules/no-process-exit.js +1 -1
- package/lib/rules/no-restricted-imports.js +171 -4
- package/lib/rules/no-restricted-modules.js +1 -1
- package/lib/rules/no-spaced-func.js +1 -1
- package/lib/rules/no-sync.js +1 -1
- package/lib/rules/no-tabs.js +1 -1
- package/lib/rules/no-trailing-spaces.js +1 -1
- package/lib/rules/no-whitespace-before-property.js +1 -1
- package/lib/rules/nonblock-statement-body-position.js +1 -1
- package/lib/rules/object-curly-newline.js +1 -1
- package/lib/rules/object-curly-spacing.js +1 -1
- package/lib/rules/object-property-newline.js +1 -1
- package/lib/rules/one-var-declaration-per-line.js +1 -1
- package/lib/rules/operator-linebreak.js +1 -1
- package/lib/rules/padded-blocks.js +1 -1
- package/lib/rules/padding-line-between-statements.js +1 -1
- package/lib/rules/preserve-caught-error.js +1 -5
- package/lib/rules/quote-props.js +1 -1
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/rest-spread-spacing.js +1 -1
- package/lib/rules/semi-spacing.js +1 -1
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/semi.js +1 -1
- package/lib/rules/space-before-blocks.js +1 -1
- package/lib/rules/space-before-function-paren.js +1 -1
- package/lib/rules/space-in-parens.js +1 -1
- package/lib/rules/space-infix-ops.js +1 -1
- package/lib/rules/space-unary-ops.js +1 -1
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/switch-colon-spacing.js +1 -1
- package/lib/rules/template-curly-spacing.js +1 -1
- package/lib/rules/template-tag-spacing.js +1 -1
- package/lib/rules/wrap-iife.js +1 -1
- package/lib/rules/wrap-regex.js +1 -1
- package/lib/rules/yield-star-spacing.js +1 -1
- package/lib/shared/serialization.js +1 -1
- package/lib/types/config-api.d.ts +6 -2
- package/lib/types/index.d.ts +92 -407
- package/lib/types/rules.d.ts +2 -0
- package/package.json +9 -9
package/lib/types/index.d.ts
CHANGED
|
@@ -30,7 +30,6 @@ import type {
|
|
|
30
30
|
CustomRuleDefinitionType,
|
|
31
31
|
CustomRuleTypeDefinitions,
|
|
32
32
|
DeprecatedInfo,
|
|
33
|
-
Language,
|
|
34
33
|
LanguageOptions as GenericLanguageOptions,
|
|
35
34
|
RuleContext as CoreRuleContext,
|
|
36
35
|
RuleDefinition,
|
|
@@ -38,8 +37,28 @@ import type {
|
|
|
38
37
|
SourceRange,
|
|
39
38
|
TextSourceCode,
|
|
40
39
|
TraversalStep,
|
|
40
|
+
RulesConfig,
|
|
41
|
+
GlobalAccess,
|
|
42
|
+
GlobalsConfig,
|
|
43
|
+
LinterOptionsConfig,
|
|
44
|
+
EnvironmentConfig,
|
|
45
|
+
ObjectMetaProperties as CoreObjectMetaProperties,
|
|
46
|
+
Plugin as CorePlugin,
|
|
47
|
+
LintMessage as CoreLintMessage,
|
|
48
|
+
Processor as CoreProcessor,
|
|
49
|
+
ConfigObject,
|
|
50
|
+
LegacyConfigObject,
|
|
51
|
+
SeverityName,
|
|
52
|
+
SeverityLevel,
|
|
53
|
+
Severity as CoreSeverity,
|
|
54
|
+
EcmaVersion as CoreEcmaVersion,
|
|
55
|
+
ConfigOverride as CoreConfigOverride,
|
|
56
|
+
ProcessorFile as CoreProcessorFile,
|
|
57
|
+
JavaScriptParserOptionsConfig,
|
|
58
|
+
RulesMeta,
|
|
59
|
+
RuleTextEditor,
|
|
60
|
+
RuleTextEdit,
|
|
41
61
|
} from "@eslint/core";
|
|
42
|
-
import { JSONSchema4 } from "json-schema";
|
|
43
62
|
import { LegacyESLint } from "./use-at-your-own-risk.js";
|
|
44
63
|
|
|
45
64
|
export namespace AST {
|
|
@@ -47,12 +66,14 @@ export namespace AST {
|
|
|
47
66
|
| "Boolean"
|
|
48
67
|
| "Null"
|
|
49
68
|
| "Identifier"
|
|
69
|
+
| "PrivateIdentifier"
|
|
50
70
|
| "Keyword"
|
|
51
71
|
| "Punctuator"
|
|
52
72
|
| "JSXIdentifier"
|
|
53
73
|
| "JSXText"
|
|
54
74
|
| "Numeric"
|
|
55
75
|
| "String"
|
|
76
|
+
| "Template"
|
|
56
77
|
| "RegularExpression";
|
|
57
78
|
|
|
58
79
|
interface Token {
|
|
@@ -220,11 +241,16 @@ export class SourceCode
|
|
|
220
241
|
|
|
221
242
|
getDeclaredVariables(node: ESTree.Node): Scope.Variable[];
|
|
222
243
|
|
|
244
|
+
/** @deprecated */
|
|
223
245
|
getJSDocComment(node: ESTree.Node): ESTree.Comment | null;
|
|
224
246
|
|
|
225
247
|
getNodeByRangeIndex(index: number): ESTree.Node | null;
|
|
226
248
|
|
|
227
|
-
|
|
249
|
+
/** @deprecated Use `isSpaceBetween()` instead. */
|
|
250
|
+
isSpaceBetweenTokens(
|
|
251
|
+
first: ESTree.Node | AST.Token,
|
|
252
|
+
second: ESTree.Node | AST.Token,
|
|
253
|
+
): boolean;
|
|
228
254
|
|
|
229
255
|
getLocFromIndex(index: number): ESTree.Position;
|
|
230
256
|
|
|
@@ -258,6 +284,18 @@ export class SourceCode
|
|
|
258
284
|
|
|
259
285
|
getTokensAfter: SourceCode.UnaryCursorWithCountOptions;
|
|
260
286
|
|
|
287
|
+
/** @deprecated Use `getTokenBefore()` instead. */
|
|
288
|
+
getTokenOrCommentBefore(
|
|
289
|
+
node: ESTree.Node | AST.Token | ESTree.Comment,
|
|
290
|
+
skip?: number | undefined,
|
|
291
|
+
): AST.Token | ESTree.Comment | null;
|
|
292
|
+
|
|
293
|
+
/** @deprecated Use `getTokenAfter()` instead. */
|
|
294
|
+
getTokenOrCommentAfter(
|
|
295
|
+
node: ESTree.Node | AST.Token | ESTree.Comment,
|
|
296
|
+
skip?: number | undefined,
|
|
297
|
+
): AST.Token | ESTree.Comment | null;
|
|
298
|
+
|
|
261
299
|
getFirstTokenBetween: SourceCode.BinaryCursorWithSkipOptions;
|
|
262
300
|
|
|
263
301
|
getFirstTokensBetween: SourceCode.BinaryCursorWithCountOptions;
|
|
@@ -304,9 +342,10 @@ export namespace SourceCode {
|
|
|
304
342
|
interface Config {
|
|
305
343
|
text: string;
|
|
306
344
|
ast: AST.Program;
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
345
|
+
hasBOM?: boolean | undefined;
|
|
346
|
+
parserServices?: ParserServices | null | undefined;
|
|
347
|
+
scopeManager?: Scope.ScopeManager | null | undefined;
|
|
348
|
+
visitorKeys?: VisitorKeys | null | undefined;
|
|
310
349
|
}
|
|
311
350
|
|
|
312
351
|
type ParserServices = any;
|
|
@@ -1128,60 +1167,7 @@ export namespace Rule {
|
|
|
1128
1167
|
reachable: boolean;
|
|
1129
1168
|
}
|
|
1130
1169
|
|
|
1131
|
-
|
|
1132
|
-
/** Properties often used for documentation generation and tooling. */
|
|
1133
|
-
docs?:
|
|
1134
|
-
| {
|
|
1135
|
-
/** Provides a short description of the rule. Commonly used when generating lists of rules. */
|
|
1136
|
-
description?: string | undefined;
|
|
1137
|
-
/** Historically used by some plugins that divide rules into categories in their documentation. */
|
|
1138
|
-
category?: string | undefined;
|
|
1139
|
-
/** Historically used by some plugins to indicate a rule belongs in their `recommended` configuration. */
|
|
1140
|
-
recommended?: boolean | undefined;
|
|
1141
|
-
/** Specifies the URL at which the full documentation can be accessed. Code editors often use this to provide a helpful link on highlighted rule violations. */
|
|
1142
|
-
url?: string | undefined;
|
|
1143
|
-
}
|
|
1144
|
-
| undefined;
|
|
1145
|
-
/** Violation and suggestion messages. */
|
|
1146
|
-
messages?: { [messageId: string]: string } | undefined;
|
|
1147
|
-
/**
|
|
1148
|
-
* Specifies if the `--fix` option on the command line automatically fixes problems reported by the rule.
|
|
1149
|
-
* Mandatory for fixable rules.
|
|
1150
|
-
*/
|
|
1151
|
-
fixable?: "code" | "whitespace" | undefined;
|
|
1152
|
-
/**
|
|
1153
|
-
* Specifies the [options](https://eslint.org/docs/latest/extend/custom-rules#options-schemas)
|
|
1154
|
-
* so ESLint can prevent invalid [rule configurations](https://eslint.org/docs/latest/use/configure/rules#configuring-rules).
|
|
1155
|
-
* Mandatory for rules with options.
|
|
1156
|
-
*/
|
|
1157
|
-
schema?: JSONSchema4 | JSONSchema4[] | false | undefined;
|
|
1158
|
-
|
|
1159
|
-
/** Any default options to be recursively merged on top of any user-provided options. */
|
|
1160
|
-
defaultOptions?: unknown[];
|
|
1161
|
-
|
|
1162
|
-
/** Indicates whether the rule has been deprecated or provides additional metadata about the deprecation. Omit if not deprecated. */
|
|
1163
|
-
deprecated?: boolean | DeprecatedInfo | undefined;
|
|
1164
|
-
/**
|
|
1165
|
-
* @deprecated Use deprecated.replacedBy instead.
|
|
1166
|
-
* The name of the rule(s) this rule was replaced by, if it was deprecated.
|
|
1167
|
-
*/
|
|
1168
|
-
replacedBy?: readonly string[];
|
|
1169
|
-
|
|
1170
|
-
/**
|
|
1171
|
-
* Indicates the type of rule:
|
|
1172
|
-
* - `"problem"` means the rule is identifying code that either will cause an error or may cause a confusing behavior. Developers should consider this a high priority to resolve.
|
|
1173
|
-
* - `"suggestion"` means the rule is identifying something that could be done in a better way but no errors will occur if the code isn't changed.
|
|
1174
|
-
* - `"layout"` means the rule cares primarily about whitespace, semicolons, commas, and parentheses,
|
|
1175
|
-
* all the parts of the program that determine how the code looks rather than how it executes.
|
|
1176
|
-
* These rules work on parts of the code that aren't specified in the AST.
|
|
1177
|
-
*/
|
|
1178
|
-
type?: "problem" | "suggestion" | "layout" | undefined;
|
|
1179
|
-
/**
|
|
1180
|
-
* Specifies whether the rule can return suggestions (defaults to `false` if omitted).
|
|
1181
|
-
* Mandatory for rules that provide suggestions.
|
|
1182
|
-
*/
|
|
1183
|
-
hasSuggestions?: boolean | undefined;
|
|
1184
|
-
}
|
|
1170
|
+
type RuleMetaData = RulesMeta;
|
|
1185
1171
|
|
|
1186
1172
|
interface RuleContext
|
|
1187
1173
|
extends CoreRuleContext<{
|
|
@@ -1224,34 +1210,8 @@ export namespace Rule {
|
|
|
1224
1210
|
| { node: ESTree.Node }
|
|
1225
1211
|
| { loc: AST.SourceLocation | { line: number; column: number } };
|
|
1226
1212
|
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
nodeOrToken: ESTree.Node | AST.Token,
|
|
1230
|
-
text: string,
|
|
1231
|
-
): Fix;
|
|
1232
|
-
|
|
1233
|
-
insertTextAfterRange(range: AST.Range, text: string): Fix;
|
|
1234
|
-
|
|
1235
|
-
insertTextBefore(
|
|
1236
|
-
nodeOrToken: ESTree.Node | AST.Token,
|
|
1237
|
-
text: string,
|
|
1238
|
-
): Fix;
|
|
1239
|
-
|
|
1240
|
-
insertTextBeforeRange(range: AST.Range, text: string): Fix;
|
|
1241
|
-
|
|
1242
|
-
remove(nodeOrToken: ESTree.Node | AST.Token): Fix;
|
|
1243
|
-
|
|
1244
|
-
removeRange(range: AST.Range): Fix;
|
|
1245
|
-
|
|
1246
|
-
replaceText(nodeOrToken: ESTree.Node | AST.Token, text: string): Fix;
|
|
1247
|
-
|
|
1248
|
-
replaceTextRange(range: AST.Range, text: string): Fix;
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
interface Fix {
|
|
1252
|
-
range: AST.Range;
|
|
1253
|
-
text: string;
|
|
1254
|
-
}
|
|
1213
|
+
type RuleFixer = RuleTextEditor<ESTree.Node | AST.Token>;
|
|
1214
|
+
type Fix = RuleTextEdit;
|
|
1255
1215
|
}
|
|
1256
1216
|
|
|
1257
1217
|
export type JSRuleDefinitionTypeOptions = CustomRuleTypeDefinitions;
|
|
@@ -1327,21 +1287,21 @@ export namespace Linter {
|
|
|
1327
1287
|
*
|
|
1328
1288
|
* @see [Rule Severities](https://eslint.org/docs/latest/use/configure/rules#rule-severities)
|
|
1329
1289
|
*/
|
|
1330
|
-
type Severity =
|
|
1290
|
+
type Severity = SeverityLevel;
|
|
1331
1291
|
|
|
1332
1292
|
/**
|
|
1333
1293
|
* The human readable severity level for a rule.
|
|
1334
1294
|
*
|
|
1335
1295
|
* @see [Rule Severities](https://eslint.org/docs/latest/use/configure/rules#rule-severities)
|
|
1336
1296
|
*/
|
|
1337
|
-
type StringSeverity =
|
|
1297
|
+
type StringSeverity = SeverityName;
|
|
1338
1298
|
|
|
1339
1299
|
/**
|
|
1340
1300
|
* The numeric or human readable severity level for a rule.
|
|
1341
1301
|
*
|
|
1342
1302
|
* @see [Rule Severities](https://eslint.org/docs/latest/use/configure/rules#rule-severities)
|
|
1343
1303
|
*/
|
|
1344
|
-
type RuleSeverity =
|
|
1304
|
+
type RuleSeverity = CoreSeverity;
|
|
1345
1305
|
|
|
1346
1306
|
/**
|
|
1347
1307
|
* An array containing the rule severity level, followed by the rule options.
|
|
@@ -1365,52 +1325,24 @@ export namespace Linter {
|
|
|
1365
1325
|
/**
|
|
1366
1326
|
* The rules config object is a key/value map of rule names and their severity and options.
|
|
1367
1327
|
*/
|
|
1368
|
-
|
|
1369
|
-
[rule: string]: RuleEntry;
|
|
1370
|
-
}
|
|
1328
|
+
type RulesRecord = RulesConfig;
|
|
1371
1329
|
|
|
1372
1330
|
/**
|
|
1373
1331
|
* A configuration object that may have a `rules` block.
|
|
1374
1332
|
*/
|
|
1375
|
-
interface HasRules<Rules extends
|
|
1333
|
+
interface HasRules<Rules extends RulesConfig = RulesConfig> {
|
|
1376
1334
|
rules?: Partial<Rules> | undefined;
|
|
1377
1335
|
}
|
|
1378
1336
|
|
|
1379
1337
|
/**
|
|
1380
1338
|
* The ECMAScript version of the code being linted.
|
|
1381
1339
|
*/
|
|
1382
|
-
type EcmaVersion =
|
|
1383
|
-
| 3
|
|
1384
|
-
| 5
|
|
1385
|
-
| 6
|
|
1386
|
-
| 7
|
|
1387
|
-
| 8
|
|
1388
|
-
| 9
|
|
1389
|
-
| 10
|
|
1390
|
-
| 11
|
|
1391
|
-
| 12
|
|
1392
|
-
| 13
|
|
1393
|
-
| 14
|
|
1394
|
-
| 15
|
|
1395
|
-
| 16
|
|
1396
|
-
| 17
|
|
1397
|
-
| 2015
|
|
1398
|
-
| 2016
|
|
1399
|
-
| 2017
|
|
1400
|
-
| 2018
|
|
1401
|
-
| 2019
|
|
1402
|
-
| 2020
|
|
1403
|
-
| 2021
|
|
1404
|
-
| 2022
|
|
1405
|
-
| 2023
|
|
1406
|
-
| 2024
|
|
1407
|
-
| 2025
|
|
1408
|
-
| 2026
|
|
1409
|
-
| "latest";
|
|
1340
|
+
type EcmaVersion = CoreEcmaVersion;
|
|
1410
1341
|
|
|
1411
1342
|
/**
|
|
1412
1343
|
* The type of JavaScript source code.
|
|
1413
1344
|
*/
|
|
1345
|
+
// TODO: Refactor to JavaScriptSourceType when exported from @eslint/core.
|
|
1414
1346
|
type SourceType = "script" | "module" | "commonjs";
|
|
1415
1347
|
|
|
1416
1348
|
/**
|
|
@@ -1419,8 +1351,8 @@ export namespace Linter {
|
|
|
1419
1351
|
* @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
|
|
1420
1352
|
*/
|
|
1421
1353
|
interface BaseConfig<
|
|
1422
|
-
Rules extends
|
|
1423
|
-
OverrideRules extends
|
|
1354
|
+
Rules extends RulesConfig = RulesConfig,
|
|
1355
|
+
OverrideRules extends RulesConfig = Rules,
|
|
1424
1356
|
> extends HasRules<Rules> {
|
|
1425
1357
|
$schema?: string | undefined;
|
|
1426
1358
|
|
|
@@ -1473,7 +1405,7 @@ export namespace Linter {
|
|
|
1473
1405
|
* @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
|
|
1474
1406
|
* @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options)
|
|
1475
1407
|
*/
|
|
1476
|
-
parserOptions?:
|
|
1408
|
+
parserOptions?: JavaScriptParserOptionsConfig | undefined;
|
|
1477
1409
|
|
|
1478
1410
|
/**
|
|
1479
1411
|
* Which third-party plugins define additional rules, environments, configs, etc. for ESLint to use.
|
|
@@ -1507,18 +1439,8 @@ export namespace Linter {
|
|
|
1507
1439
|
/**
|
|
1508
1440
|
* The overwrites that apply more differing configuration to specific files or directories.
|
|
1509
1441
|
*/
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
/**
|
|
1513
|
-
* The glob patterns for excluded files.
|
|
1514
|
-
*/
|
|
1515
|
-
excludedFiles?: string | string[] | undefined;
|
|
1516
|
-
|
|
1517
|
-
/**
|
|
1518
|
-
* The glob patterns for target files.
|
|
1519
|
-
*/
|
|
1520
|
-
files: string | string[];
|
|
1521
|
-
}
|
|
1442
|
+
type ConfigOverride<Rules extends RulesConfig = RulesConfig> =
|
|
1443
|
+
CoreConfigOverride<Rules>;
|
|
1522
1444
|
|
|
1523
1445
|
/**
|
|
1524
1446
|
* ESLint legacy configuration.
|
|
@@ -1526,78 +1448,21 @@ export namespace Linter {
|
|
|
1526
1448
|
* @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
|
|
1527
1449
|
*/
|
|
1528
1450
|
// https://github.com/eslint/eslint/blob/v8.57.0/conf/config-schema.js
|
|
1529
|
-
|
|
1530
|
-
Rules extends
|
|
1531
|
-
OverrideRules extends
|
|
1532
|
-
>
|
|
1533
|
-
/**
|
|
1534
|
-
* Tell ESLint to ignore specific files and directories.
|
|
1535
|
-
*
|
|
1536
|
-
* @see [Ignore Patterns](https://eslint.org/docs/latest/use/configure/ignore-deprecated#ignorepatterns-in-config-files)
|
|
1537
|
-
*/
|
|
1538
|
-
ignorePatterns?: string | string[] | undefined;
|
|
1539
|
-
|
|
1540
|
-
/**
|
|
1541
|
-
* @see [Using Configuration Files](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#using-configuration-files)
|
|
1542
|
-
*/
|
|
1543
|
-
root?: boolean | undefined;
|
|
1544
|
-
}
|
|
1451
|
+
type LegacyConfig<
|
|
1452
|
+
Rules extends RulesConfig = RulesConfig,
|
|
1453
|
+
OverrideRules extends RulesConfig = Rules,
|
|
1454
|
+
> = LegacyConfigObject<Rules, OverrideRules>;
|
|
1545
1455
|
|
|
1546
1456
|
/**
|
|
1547
1457
|
* Parser options.
|
|
1548
1458
|
*
|
|
1549
1459
|
* @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
|
|
1550
1460
|
*/
|
|
1551
|
-
|
|
1552
|
-
/**
|
|
1553
|
-
* Allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
|
|
1554
|
-
*
|
|
1555
|
-
* @default false
|
|
1556
|
-
*/
|
|
1557
|
-
allowReserved?: boolean | undefined;
|
|
1558
|
-
|
|
1559
|
-
/**
|
|
1560
|
-
* Accepts any valid ECMAScript version number or `'latest'`:
|
|
1561
|
-
*
|
|
1562
|
-
* - A version: es3, es5, es6, es7, es8, es9, es10, es11, es12, es13, es14, ..., or
|
|
1563
|
-
* - A year: es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, ..., or
|
|
1564
|
-
* - `'latest'`
|
|
1565
|
-
*
|
|
1566
|
-
* When it's a version or a year, the value must be a number - so do not include the `es` prefix.
|
|
1567
|
-
*
|
|
1568
|
-
* Specifies the version of ECMAScript syntax you want to use. This is used by the parser to determine how to perform scope analysis, and it affects the default
|
|
1569
|
-
*
|
|
1570
|
-
* @default 5
|
|
1571
|
-
*/
|
|
1572
|
-
ecmaVersion?: EcmaVersion | undefined;
|
|
1573
|
-
|
|
1574
|
-
/**
|
|
1575
|
-
* The type of JavaScript source code. Possible values are "script" for
|
|
1576
|
-
* traditional script files, "module" for ECMAScript modules (ESM), and
|
|
1577
|
-
* "commonjs" for CommonJS files.
|
|
1578
|
-
*
|
|
1579
|
-
* @default 'script'
|
|
1580
|
-
*
|
|
1581
|
-
* @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
|
|
1582
|
-
*/
|
|
1583
|
-
sourceType?: SourceType | undefined;
|
|
1584
|
-
|
|
1585
|
-
/**
|
|
1586
|
-
* An object indicating which additional language features you'd like to use.
|
|
1587
|
-
*
|
|
1588
|
-
* @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
|
|
1589
|
-
*/
|
|
1590
|
-
ecmaFeatures?:
|
|
1591
|
-
| {
|
|
1592
|
-
globalReturn?: boolean | undefined;
|
|
1593
|
-
impliedStrict?: boolean | undefined;
|
|
1594
|
-
jsx?: boolean | undefined;
|
|
1595
|
-
[key: string]: any;
|
|
1596
|
-
}
|
|
1597
|
-
| undefined;
|
|
1598
|
-
[key: string]: any;
|
|
1599
|
-
}
|
|
1461
|
+
type ParserOptions = JavaScriptParserOptionsConfig;
|
|
1600
1462
|
|
|
1463
|
+
/**
|
|
1464
|
+
* Options used for linting code with `Linter#verify` and `Linter#verifyAndFix`.
|
|
1465
|
+
*/
|
|
1601
1466
|
interface LintOptions {
|
|
1602
1467
|
filename?: string | undefined;
|
|
1603
1468
|
preprocess?: ((code: string) => string[]) | undefined;
|
|
@@ -1612,6 +1477,7 @@ export namespace Linter {
|
|
|
1612
1477
|
reportUnusedDisableDirectives?: boolean | undefined;
|
|
1613
1478
|
}
|
|
1614
1479
|
|
|
1480
|
+
// TODO: Once exported from @eslint/core, remove this and use that instead
|
|
1615
1481
|
interface LintSuggestion {
|
|
1616
1482
|
/** A short description. */
|
|
1617
1483
|
desc: string;
|
|
@@ -1623,46 +1489,7 @@ export namespace Linter {
|
|
|
1623
1489
|
messageId?: string | undefined;
|
|
1624
1490
|
}
|
|
1625
1491
|
|
|
1626
|
-
|
|
1627
|
-
/** The 1-based column number. */
|
|
1628
|
-
column: number;
|
|
1629
|
-
|
|
1630
|
-
/** The 1-based line number. */
|
|
1631
|
-
line: number;
|
|
1632
|
-
|
|
1633
|
-
/** The 1-based column number of the end location. */
|
|
1634
|
-
endColumn?: number | undefined;
|
|
1635
|
-
|
|
1636
|
-
/** The 1-based line number of the end location. */
|
|
1637
|
-
endLine?: number | undefined;
|
|
1638
|
-
|
|
1639
|
-
/** The ID of the rule which makes this message. */
|
|
1640
|
-
ruleId: string | null;
|
|
1641
|
-
|
|
1642
|
-
/** The reported message. */
|
|
1643
|
-
message: string;
|
|
1644
|
-
|
|
1645
|
-
/** The ID of the message in the rule's meta. */
|
|
1646
|
-
messageId?: string | undefined;
|
|
1647
|
-
|
|
1648
|
-
/**
|
|
1649
|
-
* Type of node.
|
|
1650
|
-
* @deprecated `nodeType` is deprecated and will be removed in the next major version.
|
|
1651
|
-
*/
|
|
1652
|
-
nodeType?: string | undefined;
|
|
1653
|
-
|
|
1654
|
-
/** If `true` then this is a fatal error. */
|
|
1655
|
-
fatal?: true | undefined;
|
|
1656
|
-
|
|
1657
|
-
/** The severity of this message. */
|
|
1658
|
-
severity: Exclude<Severity, 0>;
|
|
1659
|
-
|
|
1660
|
-
/** Information for autofix. */
|
|
1661
|
-
fix?: Rule.Fix | undefined;
|
|
1662
|
-
|
|
1663
|
-
/** Information for suggestions. */
|
|
1664
|
-
suggestions?: LintSuggestion[] | undefined;
|
|
1665
|
-
}
|
|
1492
|
+
type LintMessage = CoreLintMessage;
|
|
1666
1493
|
|
|
1667
1494
|
interface LintSuppression {
|
|
1668
1495
|
kind: string;
|
|
@@ -1723,114 +1550,19 @@ export namespace Linter {
|
|
|
1723
1550
|
visitorKeys?: SourceCode.VisitorKeys | undefined;
|
|
1724
1551
|
}
|
|
1725
1552
|
|
|
1726
|
-
|
|
1727
|
-
text: string;
|
|
1728
|
-
filename: string;
|
|
1729
|
-
}
|
|
1553
|
+
type ProcessorFile = CoreProcessorFile;
|
|
1730
1554
|
|
|
1731
1555
|
// https://eslint.org/docs/latest/extend/plugins#processors-in-plugins
|
|
1732
|
-
|
|
1733
|
-
T
|
|
1734
|
-
> extends ESLint.ObjectMetaProperties {
|
|
1735
|
-
/** If `true` then it means the processor supports autofix. */
|
|
1736
|
-
supportsAutofix?: boolean | undefined;
|
|
1737
|
-
|
|
1738
|
-
/** The function to extract code blocks. */
|
|
1739
|
-
preprocess?(text: string, filename: string): T[];
|
|
1740
|
-
|
|
1741
|
-
/** The function to merge messages. */
|
|
1742
|
-
postprocess?(
|
|
1743
|
-
messages: LintMessage[][],
|
|
1744
|
-
filename: string,
|
|
1745
|
-
): LintMessage[];
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
interface Config<Rules extends RulesRecord = RulesRecord> {
|
|
1749
|
-
/**
|
|
1750
|
-
* An string to identify the configuration object. Used in error messages and
|
|
1751
|
-
* inspection tools.
|
|
1752
|
-
*/
|
|
1753
|
-
name?: string;
|
|
1754
|
-
|
|
1755
|
-
/**
|
|
1756
|
-
* Path to the directory where the configuration object should apply.
|
|
1757
|
-
* `files` and `ignores` patterns in the configuration object are
|
|
1758
|
-
* interpreted as relative to this path.
|
|
1759
|
-
*/
|
|
1760
|
-
basePath?: string;
|
|
1761
|
-
|
|
1762
|
-
/**
|
|
1763
|
-
* An array of glob patterns indicating the files that the configuration
|
|
1764
|
-
* object should apply to. If not specified, the configuration object applies
|
|
1765
|
-
* to all files
|
|
1766
|
-
*/
|
|
1767
|
-
files?: Array<string | string[]>;
|
|
1768
|
-
|
|
1769
|
-
/**
|
|
1770
|
-
* An array of glob patterns indicating the files that the configuration
|
|
1771
|
-
* object should not apply to. If not specified, the configuration object
|
|
1772
|
-
* applies to all files matched by files
|
|
1773
|
-
*/
|
|
1774
|
-
ignores?: string[];
|
|
1775
|
-
|
|
1776
|
-
/**
|
|
1777
|
-
* The name of the language used for linting. This is used to determine the
|
|
1778
|
-
* parser and other language-specific settings.
|
|
1779
|
-
* @since 9.7.0
|
|
1780
|
-
*/
|
|
1781
|
-
language?: string;
|
|
1782
|
-
|
|
1783
|
-
/**
|
|
1784
|
-
* An object containing settings related to how JavaScript is configured for
|
|
1785
|
-
* linting.
|
|
1786
|
-
*/
|
|
1787
|
-
languageOptions?: LanguageOptions;
|
|
1788
|
-
|
|
1789
|
-
/**
|
|
1790
|
-
* An object containing settings related to the linting process
|
|
1791
|
-
*/
|
|
1792
|
-
linterOptions?: LinterOptions;
|
|
1793
|
-
|
|
1794
|
-
/**
|
|
1795
|
-
* Either an object containing preprocess() and postprocess() methods or a
|
|
1796
|
-
* string indicating the name of a processor inside of a plugin
|
|
1797
|
-
* (i.e., "pluginName/processorName").
|
|
1798
|
-
*/
|
|
1799
|
-
processor?: string | Processor;
|
|
1800
|
-
|
|
1801
|
-
/**
|
|
1802
|
-
* An object containing a name-value mapping of plugin names to plugin objects.
|
|
1803
|
-
* When files is specified, these plugins are only available to the matching files.
|
|
1804
|
-
*/
|
|
1805
|
-
plugins?: Record<string, ESLint.Plugin>;
|
|
1556
|
+
type Processor<T extends string | ProcessorFile = string | ProcessorFile> =
|
|
1557
|
+
CoreProcessor<T>;
|
|
1806
1558
|
|
|
1807
|
-
|
|
1808
|
-
* An object containing the configured rules. When files or ignores are specified,
|
|
1809
|
-
* these rule configurations are only available to the matching files.
|
|
1810
|
-
*/
|
|
1811
|
-
rules?: Partial<Rules>;
|
|
1812
|
-
|
|
1813
|
-
/**
|
|
1814
|
-
* An object containing name-value pairs of information that should be
|
|
1815
|
-
* available to all rules.
|
|
1816
|
-
*/
|
|
1817
|
-
settings?: Record<string, unknown>;
|
|
1818
|
-
}
|
|
1559
|
+
type Config<Rules extends RulesConfig = RulesConfig> = ConfigObject<Rules>;
|
|
1819
1560
|
|
|
1820
1561
|
/** @deprecated Use `Config` instead of `FlatConfig` */
|
|
1821
|
-
type FlatConfig<Rules extends
|
|
1822
|
-
|
|
1823
|
-
type GlobalConf =
|
|
1824
|
-
|
|
1825
|
-
| "off"
|
|
1826
|
-
| "readable"
|
|
1827
|
-
| "readonly"
|
|
1828
|
-
| "writable"
|
|
1829
|
-
| "writeable";
|
|
1830
|
-
|
|
1831
|
-
interface Globals {
|
|
1832
|
-
[name: string]: GlobalConf;
|
|
1833
|
-
}
|
|
1562
|
+
type FlatConfig<Rules extends RulesConfig = RulesConfig> = Config<Rules>;
|
|
1563
|
+
|
|
1564
|
+
type GlobalConf = GlobalAccess;
|
|
1565
|
+
type Globals = GlobalsConfig;
|
|
1834
1566
|
|
|
1835
1567
|
interface LanguageOptions extends GenericLanguageOptions {
|
|
1836
1568
|
/**
|
|
@@ -1867,24 +1599,7 @@ export namespace Linter {
|
|
|
1867
1599
|
parserOptions?: Linter.ParserOptions | undefined;
|
|
1868
1600
|
}
|
|
1869
1601
|
|
|
1870
|
-
|
|
1871
|
-
/**
|
|
1872
|
-
* A boolean value indicating if inline configuration is allowed.
|
|
1873
|
-
*/
|
|
1874
|
-
noInlineConfig?: boolean;
|
|
1875
|
-
|
|
1876
|
-
/**
|
|
1877
|
-
* A severity value indicating if and how unused disable directives should be
|
|
1878
|
-
* tracked and reported.
|
|
1879
|
-
*/
|
|
1880
|
-
reportUnusedDisableDirectives?: Severity | StringSeverity | boolean;
|
|
1881
|
-
|
|
1882
|
-
/**
|
|
1883
|
-
* A severity value indicating if and how unused inline configs should be
|
|
1884
|
-
* tracked and reported.
|
|
1885
|
-
*/
|
|
1886
|
-
reportUnusedInlineConfigs?: Severity | StringSeverity;
|
|
1887
|
-
}
|
|
1602
|
+
type LinterOptions = LinterOptionsConfig;
|
|
1888
1603
|
|
|
1889
1604
|
/**
|
|
1890
1605
|
* Performance statistics.
|
|
@@ -1963,7 +1678,7 @@ export class ESLint {
|
|
|
1963
1678
|
|
|
1964
1679
|
calculateConfigForFile(filePath: string): Promise<any>;
|
|
1965
1680
|
|
|
1966
|
-
findConfigFile(): Promise<string | undefined>;
|
|
1681
|
+
findConfigFile(filePath?: string): Promise<string | undefined>;
|
|
1967
1682
|
|
|
1968
1683
|
isPathIgnored(filePath: string): Promise<boolean>;
|
|
1969
1684
|
|
|
@@ -1975,45 +1690,14 @@ export class ESLint {
|
|
|
1975
1690
|
}
|
|
1976
1691
|
|
|
1977
1692
|
export namespace ESLint {
|
|
1978
|
-
type ConfigData<Rules extends Linter.RulesRecord =
|
|
1979
|
-
|
|
1693
|
+
type ConfigData<Rules extends Linter.RulesRecord = RulesConfig> = Omit<
|
|
1694
|
+
Linter.LegacyConfig<Rules>,
|
|
1695
|
+
"$schema"
|
|
1696
|
+
>;
|
|
1980
1697
|
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
/** The parser options that will be enabled under this environment. */
|
|
1986
|
-
parserOptions?: Linter.ParserOptions | undefined;
|
|
1987
|
-
}
|
|
1988
|
-
|
|
1989
|
-
interface ObjectMetaProperties {
|
|
1990
|
-
/** @deprecated Use `meta.name` instead. */
|
|
1991
|
-
name?: string | undefined;
|
|
1992
|
-
|
|
1993
|
-
/** @deprecated Use `meta.version` instead. */
|
|
1994
|
-
version?: string | undefined;
|
|
1995
|
-
|
|
1996
|
-
meta?: {
|
|
1997
|
-
name?: string | undefined;
|
|
1998
|
-
version?: string | undefined;
|
|
1999
|
-
};
|
|
2000
|
-
}
|
|
2001
|
-
|
|
2002
|
-
interface Plugin extends ObjectMetaProperties {
|
|
2003
|
-
meta?: ObjectMetaProperties["meta"] & {
|
|
2004
|
-
namespace?: string | undefined;
|
|
2005
|
-
};
|
|
2006
|
-
configs?:
|
|
2007
|
-
| Record<
|
|
2008
|
-
string,
|
|
2009
|
-
Linter.LegacyConfig | Linter.Config | Linter.Config[]
|
|
2010
|
-
>
|
|
2011
|
-
| undefined;
|
|
2012
|
-
environments?: Record<string, Environment> | undefined;
|
|
2013
|
-
languages?: Record<string, Language> | undefined;
|
|
2014
|
-
processors?: Record<string, Linter.Processor> | undefined;
|
|
2015
|
-
rules?: Record<string, RuleDefinition> | undefined;
|
|
2016
|
-
}
|
|
1698
|
+
type Environment = EnvironmentConfig;
|
|
1699
|
+
type ObjectMetaProperties = CoreObjectMetaProperties;
|
|
1700
|
+
type Plugin = CorePlugin;
|
|
2017
1701
|
|
|
2018
1702
|
type FixType = "directive" | "problem" | "suggestion" | "layout";
|
|
2019
1703
|
|
|
@@ -2045,7 +1729,7 @@ export namespace ESLint {
|
|
|
2045
1729
|
|
|
2046
1730
|
// Autofix
|
|
2047
1731
|
fix?: boolean | ((message: Linter.LintMessage) => boolean) | undefined;
|
|
2048
|
-
fixTypes?: FixType[] | undefined;
|
|
1732
|
+
fixTypes?: FixType[] | null | undefined;
|
|
2049
1733
|
|
|
2050
1734
|
// Cache-related
|
|
2051
1735
|
cache?: boolean | undefined;
|
|
@@ -2079,7 +1763,7 @@ export namespace ESLint {
|
|
|
2079
1763
|
|
|
2080
1764
|
// Autofix
|
|
2081
1765
|
fix?: boolean | ((message: Linter.LintMessage) => boolean) | undefined;
|
|
2082
|
-
fixTypes?: FixType[] | undefined;
|
|
1766
|
+
fixTypes?: FixType[] | null | undefined;
|
|
2083
1767
|
|
|
2084
1768
|
// Cache-related
|
|
2085
1769
|
cache?: boolean | undefined;
|
|
@@ -2168,9 +1852,10 @@ export namespace ESLint {
|
|
|
2168
1852
|
|
|
2169
1853
|
/**
|
|
2170
1854
|
* The raw deprecated info provided by the rule.
|
|
2171
|
-
*
|
|
1855
|
+
* - Undefined if the rule's `meta.deprecated` property is a boolean.
|
|
1856
|
+
* - Unset when using the legacy eslintrc configuration.
|
|
2172
1857
|
*/
|
|
2173
|
-
info?: DeprecatedInfo;
|
|
1858
|
+
info?: DeprecatedInfo | undefined;
|
|
2174
1859
|
}
|
|
2175
1860
|
|
|
2176
1861
|
/**
|