eslint 9.37.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/eslint/eslint-helpers.js +1 -1
- package/lib/rules/callback-return.js +1 -1
- package/lib/rules/complexity.js +6 -0
- 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/no-buffer-constructor.js +1 -1
- package/lib/rules/no-catch-shadow.js +1 -1
- package/lib/rules/no-loss-of-precision.js +206 -208
- package/lib/rules/no-mixed-requires.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-modules.js +1 -1
- package/lib/rules/no-sync.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 +85 -403
- package/package.json +6 -6
|
@@ -56,7 +56,7 @@ function isSerializable(val, seenObjects = new Set()) {
|
|
|
56
56
|
/*
|
|
57
57
|
* We're creating a new Set of seen objects because we want to
|
|
58
58
|
* ensure that `val` doesn't appear again in this path, but it can appear
|
|
59
|
-
* in other paths. This allows for
|
|
59
|
+
* in other paths. This allows for reusing objects in the graph, as long as
|
|
60
60
|
* there are no cycles.
|
|
61
61
|
*/
|
|
62
62
|
!isSerializable(
|
|
@@ -3,6 +3,10 @@
|
|
|
3
3
|
* @author Nicholas C. Zakas
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
type Config,
|
|
8
|
+
defineConfig,
|
|
9
|
+
globalIgnores,
|
|
10
|
+
} from "@eslint/config-helpers";
|
|
7
11
|
|
|
8
|
-
export { defineConfig, globalIgnores };
|
|
12
|
+
export { type Config, defineConfig, globalIgnores };
|
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 {
|
|
@@ -222,11 +241,16 @@ export class SourceCode
|
|
|
222
241
|
|
|
223
242
|
getDeclaredVariables(node: ESTree.Node): Scope.Variable[];
|
|
224
243
|
|
|
244
|
+
/** @deprecated */
|
|
225
245
|
getJSDocComment(node: ESTree.Node): ESTree.Comment | null;
|
|
226
246
|
|
|
227
247
|
getNodeByRangeIndex(index: number): ESTree.Node | null;
|
|
228
248
|
|
|
229
|
-
|
|
249
|
+
/** @deprecated Use `isSpaceBetween()` instead. */
|
|
250
|
+
isSpaceBetweenTokens(
|
|
251
|
+
first: ESTree.Node | AST.Token,
|
|
252
|
+
second: ESTree.Node | AST.Token,
|
|
253
|
+
): boolean;
|
|
230
254
|
|
|
231
255
|
getLocFromIndex(index: number): ESTree.Position;
|
|
232
256
|
|
|
@@ -260,6 +284,18 @@ export class SourceCode
|
|
|
260
284
|
|
|
261
285
|
getTokensAfter: SourceCode.UnaryCursorWithCountOptions;
|
|
262
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
|
+
|
|
263
299
|
getFirstTokenBetween: SourceCode.BinaryCursorWithSkipOptions;
|
|
264
300
|
|
|
265
301
|
getFirstTokensBetween: SourceCode.BinaryCursorWithCountOptions;
|
|
@@ -306,9 +342,10 @@ export namespace SourceCode {
|
|
|
306
342
|
interface Config {
|
|
307
343
|
text: string;
|
|
308
344
|
ast: AST.Program;
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
345
|
+
hasBOM?: boolean | undefined;
|
|
346
|
+
parserServices?: ParserServices | null | undefined;
|
|
347
|
+
scopeManager?: Scope.ScopeManager | null | undefined;
|
|
348
|
+
visitorKeys?: VisitorKeys | null | undefined;
|
|
312
349
|
}
|
|
313
350
|
|
|
314
351
|
type ParserServices = any;
|
|
@@ -1130,60 +1167,7 @@ export namespace Rule {
|
|
|
1130
1167
|
reachable: boolean;
|
|
1131
1168
|
}
|
|
1132
1169
|
|
|
1133
|
-
|
|
1134
|
-
/** Properties often used for documentation generation and tooling. */
|
|
1135
|
-
docs?:
|
|
1136
|
-
| {
|
|
1137
|
-
/** Provides a short description of the rule. Commonly used when generating lists of rules. */
|
|
1138
|
-
description?: string | undefined;
|
|
1139
|
-
/** Historically used by some plugins that divide rules into categories in their documentation. */
|
|
1140
|
-
category?: string | undefined;
|
|
1141
|
-
/** Historically used by some plugins to indicate a rule belongs in their `recommended` configuration. */
|
|
1142
|
-
recommended?: boolean | undefined;
|
|
1143
|
-
/** 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. */
|
|
1144
|
-
url?: string | undefined;
|
|
1145
|
-
}
|
|
1146
|
-
| undefined;
|
|
1147
|
-
/** Violation and suggestion messages. */
|
|
1148
|
-
messages?: { [messageId: string]: string } | undefined;
|
|
1149
|
-
/**
|
|
1150
|
-
* Specifies if the `--fix` option on the command line automatically fixes problems reported by the rule.
|
|
1151
|
-
* Mandatory for fixable rules.
|
|
1152
|
-
*/
|
|
1153
|
-
fixable?: "code" | "whitespace" | undefined;
|
|
1154
|
-
/**
|
|
1155
|
-
* Specifies the [options](https://eslint.org/docs/latest/extend/custom-rules#options-schemas)
|
|
1156
|
-
* so ESLint can prevent invalid [rule configurations](https://eslint.org/docs/latest/use/configure/rules#configuring-rules).
|
|
1157
|
-
* Mandatory for rules with options.
|
|
1158
|
-
*/
|
|
1159
|
-
schema?: JSONSchema4 | JSONSchema4[] | false | undefined;
|
|
1160
|
-
|
|
1161
|
-
/** Any default options to be recursively merged on top of any user-provided options. */
|
|
1162
|
-
defaultOptions?: unknown[];
|
|
1163
|
-
|
|
1164
|
-
/** Indicates whether the rule has been deprecated or provides additional metadata about the deprecation. Omit if not deprecated. */
|
|
1165
|
-
deprecated?: boolean | DeprecatedInfo | undefined;
|
|
1166
|
-
/**
|
|
1167
|
-
* @deprecated Use deprecated.replacedBy instead.
|
|
1168
|
-
* The name of the rule(s) this rule was replaced by, if it was deprecated.
|
|
1169
|
-
*/
|
|
1170
|
-
replacedBy?: readonly string[];
|
|
1171
|
-
|
|
1172
|
-
/**
|
|
1173
|
-
* Indicates the type of rule:
|
|
1174
|
-
* - `"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.
|
|
1175
|
-
* - `"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.
|
|
1176
|
-
* - `"layout"` means the rule cares primarily about whitespace, semicolons, commas, and parentheses,
|
|
1177
|
-
* all the parts of the program that determine how the code looks rather than how it executes.
|
|
1178
|
-
* These rules work on parts of the code that aren't specified in the AST.
|
|
1179
|
-
*/
|
|
1180
|
-
type?: "problem" | "suggestion" | "layout" | undefined;
|
|
1181
|
-
/**
|
|
1182
|
-
* Specifies whether the rule can return suggestions (defaults to `false` if omitted).
|
|
1183
|
-
* Mandatory for rules that provide suggestions.
|
|
1184
|
-
*/
|
|
1185
|
-
hasSuggestions?: boolean | undefined;
|
|
1186
|
-
}
|
|
1170
|
+
type RuleMetaData = RulesMeta;
|
|
1187
1171
|
|
|
1188
1172
|
interface RuleContext
|
|
1189
1173
|
extends CoreRuleContext<{
|
|
@@ -1226,34 +1210,8 @@ export namespace Rule {
|
|
|
1226
1210
|
| { node: ESTree.Node }
|
|
1227
1211
|
| { loc: AST.SourceLocation | { line: number; column: number } };
|
|
1228
1212
|
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
nodeOrToken: ESTree.Node | AST.Token,
|
|
1232
|
-
text: string,
|
|
1233
|
-
): Fix;
|
|
1234
|
-
|
|
1235
|
-
insertTextAfterRange(range: AST.Range, text: string): Fix;
|
|
1236
|
-
|
|
1237
|
-
insertTextBefore(
|
|
1238
|
-
nodeOrToken: ESTree.Node | AST.Token,
|
|
1239
|
-
text: string,
|
|
1240
|
-
): Fix;
|
|
1241
|
-
|
|
1242
|
-
insertTextBeforeRange(range: AST.Range, text: string): Fix;
|
|
1243
|
-
|
|
1244
|
-
remove(nodeOrToken: ESTree.Node | AST.Token): Fix;
|
|
1245
|
-
|
|
1246
|
-
removeRange(range: AST.Range): Fix;
|
|
1247
|
-
|
|
1248
|
-
replaceText(nodeOrToken: ESTree.Node | AST.Token, text: string): Fix;
|
|
1249
|
-
|
|
1250
|
-
replaceTextRange(range: AST.Range, text: string): Fix;
|
|
1251
|
-
}
|
|
1252
|
-
|
|
1253
|
-
interface Fix {
|
|
1254
|
-
range: AST.Range;
|
|
1255
|
-
text: string;
|
|
1256
|
-
}
|
|
1213
|
+
type RuleFixer = RuleTextEditor<ESTree.Node | AST.Token>;
|
|
1214
|
+
type Fix = RuleTextEdit;
|
|
1257
1215
|
}
|
|
1258
1216
|
|
|
1259
1217
|
export type JSRuleDefinitionTypeOptions = CustomRuleTypeDefinitions;
|
|
@@ -1329,21 +1287,21 @@ export namespace Linter {
|
|
|
1329
1287
|
*
|
|
1330
1288
|
* @see [Rule Severities](https://eslint.org/docs/latest/use/configure/rules#rule-severities)
|
|
1331
1289
|
*/
|
|
1332
|
-
type Severity =
|
|
1290
|
+
type Severity = SeverityLevel;
|
|
1333
1291
|
|
|
1334
1292
|
/**
|
|
1335
1293
|
* The human readable severity level for a rule.
|
|
1336
1294
|
*
|
|
1337
1295
|
* @see [Rule Severities](https://eslint.org/docs/latest/use/configure/rules#rule-severities)
|
|
1338
1296
|
*/
|
|
1339
|
-
type StringSeverity =
|
|
1297
|
+
type StringSeverity = SeverityName;
|
|
1340
1298
|
|
|
1341
1299
|
/**
|
|
1342
1300
|
* The numeric or human readable severity level for a rule.
|
|
1343
1301
|
*
|
|
1344
1302
|
* @see [Rule Severities](https://eslint.org/docs/latest/use/configure/rules#rule-severities)
|
|
1345
1303
|
*/
|
|
1346
|
-
type RuleSeverity =
|
|
1304
|
+
type RuleSeverity = CoreSeverity;
|
|
1347
1305
|
|
|
1348
1306
|
/**
|
|
1349
1307
|
* An array containing the rule severity level, followed by the rule options.
|
|
@@ -1367,52 +1325,24 @@ export namespace Linter {
|
|
|
1367
1325
|
/**
|
|
1368
1326
|
* The rules config object is a key/value map of rule names and their severity and options.
|
|
1369
1327
|
*/
|
|
1370
|
-
|
|
1371
|
-
[rule: string]: RuleEntry;
|
|
1372
|
-
}
|
|
1328
|
+
type RulesRecord = RulesConfig;
|
|
1373
1329
|
|
|
1374
1330
|
/**
|
|
1375
1331
|
* A configuration object that may have a `rules` block.
|
|
1376
1332
|
*/
|
|
1377
|
-
interface HasRules<Rules extends
|
|
1333
|
+
interface HasRules<Rules extends RulesConfig = RulesConfig> {
|
|
1378
1334
|
rules?: Partial<Rules> | undefined;
|
|
1379
1335
|
}
|
|
1380
1336
|
|
|
1381
1337
|
/**
|
|
1382
1338
|
* The ECMAScript version of the code being linted.
|
|
1383
1339
|
*/
|
|
1384
|
-
type EcmaVersion =
|
|
1385
|
-
| 3
|
|
1386
|
-
| 5
|
|
1387
|
-
| 6
|
|
1388
|
-
| 7
|
|
1389
|
-
| 8
|
|
1390
|
-
| 9
|
|
1391
|
-
| 10
|
|
1392
|
-
| 11
|
|
1393
|
-
| 12
|
|
1394
|
-
| 13
|
|
1395
|
-
| 14
|
|
1396
|
-
| 15
|
|
1397
|
-
| 16
|
|
1398
|
-
| 17
|
|
1399
|
-
| 2015
|
|
1400
|
-
| 2016
|
|
1401
|
-
| 2017
|
|
1402
|
-
| 2018
|
|
1403
|
-
| 2019
|
|
1404
|
-
| 2020
|
|
1405
|
-
| 2021
|
|
1406
|
-
| 2022
|
|
1407
|
-
| 2023
|
|
1408
|
-
| 2024
|
|
1409
|
-
| 2025
|
|
1410
|
-
| 2026
|
|
1411
|
-
| "latest";
|
|
1340
|
+
type EcmaVersion = CoreEcmaVersion;
|
|
1412
1341
|
|
|
1413
1342
|
/**
|
|
1414
1343
|
* The type of JavaScript source code.
|
|
1415
1344
|
*/
|
|
1345
|
+
// TODO: Refactor to JavaScriptSourceType when exported from @eslint/core.
|
|
1416
1346
|
type SourceType = "script" | "module" | "commonjs";
|
|
1417
1347
|
|
|
1418
1348
|
/**
|
|
@@ -1421,8 +1351,8 @@ export namespace Linter {
|
|
|
1421
1351
|
* @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
|
|
1422
1352
|
*/
|
|
1423
1353
|
interface BaseConfig<
|
|
1424
|
-
Rules extends
|
|
1425
|
-
OverrideRules extends
|
|
1354
|
+
Rules extends RulesConfig = RulesConfig,
|
|
1355
|
+
OverrideRules extends RulesConfig = Rules,
|
|
1426
1356
|
> extends HasRules<Rules> {
|
|
1427
1357
|
$schema?: string | undefined;
|
|
1428
1358
|
|
|
@@ -1475,7 +1405,7 @@ export namespace Linter {
|
|
|
1475
1405
|
* @see [Working with Custom Parsers](https://eslint.org/docs/latest/extend/custom-parsers)
|
|
1476
1406
|
* @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options)
|
|
1477
1407
|
*/
|
|
1478
|
-
parserOptions?:
|
|
1408
|
+
parserOptions?: JavaScriptParserOptionsConfig | undefined;
|
|
1479
1409
|
|
|
1480
1410
|
/**
|
|
1481
1411
|
* Which third-party plugins define additional rules, environments, configs, etc. for ESLint to use.
|
|
@@ -1509,18 +1439,8 @@ export namespace Linter {
|
|
|
1509
1439
|
/**
|
|
1510
1440
|
* The overwrites that apply more differing configuration to specific files or directories.
|
|
1511
1441
|
*/
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
/**
|
|
1515
|
-
* The glob patterns for excluded files.
|
|
1516
|
-
*/
|
|
1517
|
-
excludedFiles?: string | string[] | undefined;
|
|
1518
|
-
|
|
1519
|
-
/**
|
|
1520
|
-
* The glob patterns for target files.
|
|
1521
|
-
*/
|
|
1522
|
-
files: string | string[];
|
|
1523
|
-
}
|
|
1442
|
+
type ConfigOverride<Rules extends RulesConfig = RulesConfig> =
|
|
1443
|
+
CoreConfigOverride<Rules>;
|
|
1524
1444
|
|
|
1525
1445
|
/**
|
|
1526
1446
|
* ESLint legacy configuration.
|
|
@@ -1528,78 +1448,21 @@ export namespace Linter {
|
|
|
1528
1448
|
* @see [ESLint Legacy Configuration](https://eslint.org/docs/latest/use/configure/)
|
|
1529
1449
|
*/
|
|
1530
1450
|
// https://github.com/eslint/eslint/blob/v8.57.0/conf/config-schema.js
|
|
1531
|
-
|
|
1532
|
-
Rules extends
|
|
1533
|
-
OverrideRules extends
|
|
1534
|
-
>
|
|
1535
|
-
/**
|
|
1536
|
-
* Tell ESLint to ignore specific files and directories.
|
|
1537
|
-
*
|
|
1538
|
-
* @see [Ignore Patterns](https://eslint.org/docs/latest/use/configure/ignore-deprecated#ignorepatterns-in-config-files)
|
|
1539
|
-
*/
|
|
1540
|
-
ignorePatterns?: string | string[] | undefined;
|
|
1541
|
-
|
|
1542
|
-
/**
|
|
1543
|
-
* @see [Using Configuration Files](https://eslint.org/docs/latest/use/configure/configuration-files-deprecated#using-configuration-files)
|
|
1544
|
-
*/
|
|
1545
|
-
root?: boolean | undefined;
|
|
1546
|
-
}
|
|
1451
|
+
type LegacyConfig<
|
|
1452
|
+
Rules extends RulesConfig = RulesConfig,
|
|
1453
|
+
OverrideRules extends RulesConfig = Rules,
|
|
1454
|
+
> = LegacyConfigObject<Rules, OverrideRules>;
|
|
1547
1455
|
|
|
1548
1456
|
/**
|
|
1549
1457
|
* Parser options.
|
|
1550
1458
|
*
|
|
1551
1459
|
* @see [Specifying Parser Options](https://eslint.org/docs/latest/use/configure/language-options#specifying-parser-options)
|
|
1552
1460
|
*/
|
|
1553
|
-
|
|
1554
|
-
/**
|
|
1555
|
-
* Allow the use of reserved words as identifiers (if `ecmaVersion` is 3).
|
|
1556
|
-
*
|
|
1557
|
-
* @default false
|
|
1558
|
-
*/
|
|
1559
|
-
allowReserved?: boolean | undefined;
|
|
1560
|
-
|
|
1561
|
-
/**
|
|
1562
|
-
* Accepts any valid ECMAScript version number or `'latest'`:
|
|
1563
|
-
*
|
|
1564
|
-
* - A version: es3, es5, es6, es7, es8, es9, es10, es11, es12, es13, es14, ..., or
|
|
1565
|
-
* - A year: es2015, es2016, es2017, es2018, es2019, es2020, es2021, es2022, es2023, ..., or
|
|
1566
|
-
* - `'latest'`
|
|
1567
|
-
*
|
|
1568
|
-
* When it's a version or a year, the value must be a number - so do not include the `es` prefix.
|
|
1569
|
-
*
|
|
1570
|
-
* 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
|
|
1571
|
-
*
|
|
1572
|
-
* @default 5
|
|
1573
|
-
*/
|
|
1574
|
-
ecmaVersion?: EcmaVersion | undefined;
|
|
1575
|
-
|
|
1576
|
-
/**
|
|
1577
|
-
* The type of JavaScript source code. Possible values are "script" for
|
|
1578
|
-
* traditional script files, "module" for ECMAScript modules (ESM), and
|
|
1579
|
-
* "commonjs" for CommonJS files.
|
|
1580
|
-
*
|
|
1581
|
-
* @default 'script'
|
|
1582
|
-
*
|
|
1583
|
-
* @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
|
|
1584
|
-
*/
|
|
1585
|
-
sourceType?: SourceType | undefined;
|
|
1586
|
-
|
|
1587
|
-
/**
|
|
1588
|
-
* An object indicating which additional language features you'd like to use.
|
|
1589
|
-
*
|
|
1590
|
-
* @see https://eslint.org/docs/latest/use/configure/language-options-deprecated#specifying-parser-options
|
|
1591
|
-
*/
|
|
1592
|
-
ecmaFeatures?:
|
|
1593
|
-
| {
|
|
1594
|
-
globalReturn?: boolean | undefined;
|
|
1595
|
-
impliedStrict?: boolean | undefined;
|
|
1596
|
-
jsx?: boolean | undefined;
|
|
1597
|
-
[key: string]: any;
|
|
1598
|
-
}
|
|
1599
|
-
| undefined;
|
|
1600
|
-
[key: string]: any;
|
|
1601
|
-
}
|
|
1461
|
+
type ParserOptions = JavaScriptParserOptionsConfig;
|
|
1602
1462
|
|
|
1463
|
+
/**
|
|
1464
|
+
* Options used for linting code with `Linter#verify` and `Linter#verifyAndFix`.
|
|
1465
|
+
*/
|
|
1603
1466
|
interface LintOptions {
|
|
1604
1467
|
filename?: string | undefined;
|
|
1605
1468
|
preprocess?: ((code: string) => string[]) | undefined;
|
|
@@ -1614,6 +1477,7 @@ export namespace Linter {
|
|
|
1614
1477
|
reportUnusedDisableDirectives?: boolean | undefined;
|
|
1615
1478
|
}
|
|
1616
1479
|
|
|
1480
|
+
// TODO: Once exported from @eslint/core, remove this and use that instead
|
|
1617
1481
|
interface LintSuggestion {
|
|
1618
1482
|
/** A short description. */
|
|
1619
1483
|
desc: string;
|
|
@@ -1625,46 +1489,7 @@ export namespace Linter {
|
|
|
1625
1489
|
messageId?: string | undefined;
|
|
1626
1490
|
}
|
|
1627
1491
|
|
|
1628
|
-
|
|
1629
|
-
/** The 1-based column number. */
|
|
1630
|
-
column: number;
|
|
1631
|
-
|
|
1632
|
-
/** The 1-based line number. */
|
|
1633
|
-
line: number;
|
|
1634
|
-
|
|
1635
|
-
/** The 1-based column number of the end location. */
|
|
1636
|
-
endColumn?: number | undefined;
|
|
1637
|
-
|
|
1638
|
-
/** The 1-based line number of the end location. */
|
|
1639
|
-
endLine?: number | undefined;
|
|
1640
|
-
|
|
1641
|
-
/** The ID of the rule which makes this message. */
|
|
1642
|
-
ruleId: string | null;
|
|
1643
|
-
|
|
1644
|
-
/** The reported message. */
|
|
1645
|
-
message: string;
|
|
1646
|
-
|
|
1647
|
-
/** The ID of the message in the rule's meta. */
|
|
1648
|
-
messageId?: string | undefined;
|
|
1649
|
-
|
|
1650
|
-
/**
|
|
1651
|
-
* Type of node.
|
|
1652
|
-
* @deprecated `nodeType` is deprecated and will be removed in the next major version.
|
|
1653
|
-
*/
|
|
1654
|
-
nodeType?: string | undefined;
|
|
1655
|
-
|
|
1656
|
-
/** If `true` then this is a fatal error. */
|
|
1657
|
-
fatal?: true | undefined;
|
|
1658
|
-
|
|
1659
|
-
/** The severity of this message. */
|
|
1660
|
-
severity: Exclude<Severity, 0>;
|
|
1661
|
-
|
|
1662
|
-
/** Information for autofix. */
|
|
1663
|
-
fix?: Rule.Fix | undefined;
|
|
1664
|
-
|
|
1665
|
-
/** Information for suggestions. */
|
|
1666
|
-
suggestions?: LintSuggestion[] | undefined;
|
|
1667
|
-
}
|
|
1492
|
+
type LintMessage = CoreLintMessage;
|
|
1668
1493
|
|
|
1669
1494
|
interface LintSuppression {
|
|
1670
1495
|
kind: string;
|
|
@@ -1725,114 +1550,19 @@ export namespace Linter {
|
|
|
1725
1550
|
visitorKeys?: SourceCode.VisitorKeys | undefined;
|
|
1726
1551
|
}
|
|
1727
1552
|
|
|
1728
|
-
|
|
1729
|
-
text: string;
|
|
1730
|
-
filename: string;
|
|
1731
|
-
}
|
|
1553
|
+
type ProcessorFile = CoreProcessorFile;
|
|
1732
1554
|
|
|
1733
1555
|
// https://eslint.org/docs/latest/extend/plugins#processors-in-plugins
|
|
1734
|
-
|
|
1735
|
-
T
|
|
1736
|
-
> extends ESLint.ObjectMetaProperties {
|
|
1737
|
-
/** If `true` then it means the processor supports autofix. */
|
|
1738
|
-
supportsAutofix?: boolean | undefined;
|
|
1739
|
-
|
|
1740
|
-
/** The function to extract code blocks. */
|
|
1741
|
-
preprocess?(text: string, filename: string): T[];
|
|
1742
|
-
|
|
1743
|
-
/** The function to merge messages. */
|
|
1744
|
-
postprocess?(
|
|
1745
|
-
messages: LintMessage[][],
|
|
1746
|
-
filename: string,
|
|
1747
|
-
): LintMessage[];
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
interface Config<Rules extends RulesRecord = RulesRecord> {
|
|
1751
|
-
/**
|
|
1752
|
-
* An string to identify the configuration object. Used in error messages and
|
|
1753
|
-
* inspection tools.
|
|
1754
|
-
*/
|
|
1755
|
-
name?: string;
|
|
1756
|
-
|
|
1757
|
-
/**
|
|
1758
|
-
* Path to the directory where the configuration object should apply.
|
|
1759
|
-
* `files` and `ignores` patterns in the configuration object are
|
|
1760
|
-
* interpreted as relative to this path.
|
|
1761
|
-
*/
|
|
1762
|
-
basePath?: string;
|
|
1763
|
-
|
|
1764
|
-
/**
|
|
1765
|
-
* An array of glob patterns indicating the files that the configuration
|
|
1766
|
-
* object should apply to. If not specified, the configuration object applies
|
|
1767
|
-
* to all files
|
|
1768
|
-
*/
|
|
1769
|
-
files?: Array<string | string[]>;
|
|
1770
|
-
|
|
1771
|
-
/**
|
|
1772
|
-
* An array of glob patterns indicating the files that the configuration
|
|
1773
|
-
* object should not apply to. If not specified, the configuration object
|
|
1774
|
-
* applies to all files matched by files
|
|
1775
|
-
*/
|
|
1776
|
-
ignores?: string[];
|
|
1777
|
-
|
|
1778
|
-
/**
|
|
1779
|
-
* The name of the language used for linting. This is used to determine the
|
|
1780
|
-
* parser and other language-specific settings.
|
|
1781
|
-
* @since 9.7.0
|
|
1782
|
-
*/
|
|
1783
|
-
language?: string;
|
|
1784
|
-
|
|
1785
|
-
/**
|
|
1786
|
-
* An object containing settings related to how JavaScript is configured for
|
|
1787
|
-
* linting.
|
|
1788
|
-
*/
|
|
1789
|
-
languageOptions?: LanguageOptions;
|
|
1556
|
+
type Processor<T extends string | ProcessorFile = string | ProcessorFile> =
|
|
1557
|
+
CoreProcessor<T>;
|
|
1790
1558
|
|
|
1791
|
-
|
|
1792
|
-
* An object containing settings related to the linting process
|
|
1793
|
-
*/
|
|
1794
|
-
linterOptions?: LinterOptions;
|
|
1795
|
-
|
|
1796
|
-
/**
|
|
1797
|
-
* Either an object containing preprocess() and postprocess() methods or a
|
|
1798
|
-
* string indicating the name of a processor inside of a plugin
|
|
1799
|
-
* (i.e., "pluginName/processorName").
|
|
1800
|
-
*/
|
|
1801
|
-
processor?: string | Processor;
|
|
1802
|
-
|
|
1803
|
-
/**
|
|
1804
|
-
* An object containing a name-value mapping of plugin names to plugin objects.
|
|
1805
|
-
* When files is specified, these plugins are only available to the matching files.
|
|
1806
|
-
*/
|
|
1807
|
-
plugins?: Record<string, ESLint.Plugin>;
|
|
1808
|
-
|
|
1809
|
-
/**
|
|
1810
|
-
* An object containing the configured rules. When files or ignores are specified,
|
|
1811
|
-
* these rule configurations are only available to the matching files.
|
|
1812
|
-
*/
|
|
1813
|
-
rules?: Partial<Rules>;
|
|
1814
|
-
|
|
1815
|
-
/**
|
|
1816
|
-
* An object containing name-value pairs of information that should be
|
|
1817
|
-
* available to all rules.
|
|
1818
|
-
*/
|
|
1819
|
-
settings?: Record<string, unknown>;
|
|
1820
|
-
}
|
|
1559
|
+
type Config<Rules extends RulesConfig = RulesConfig> = ConfigObject<Rules>;
|
|
1821
1560
|
|
|
1822
1561
|
/** @deprecated Use `Config` instead of `FlatConfig` */
|
|
1823
|
-
type FlatConfig<Rules extends
|
|
1824
|
-
|
|
1825
|
-
type GlobalConf =
|
|
1826
|
-
|
|
1827
|
-
| "off"
|
|
1828
|
-
| "readable"
|
|
1829
|
-
| "readonly"
|
|
1830
|
-
| "writable"
|
|
1831
|
-
| "writeable";
|
|
1832
|
-
|
|
1833
|
-
interface Globals {
|
|
1834
|
-
[name: string]: GlobalConf;
|
|
1835
|
-
}
|
|
1562
|
+
type FlatConfig<Rules extends RulesConfig = RulesConfig> = Config<Rules>;
|
|
1563
|
+
|
|
1564
|
+
type GlobalConf = GlobalAccess;
|
|
1565
|
+
type Globals = GlobalsConfig;
|
|
1836
1566
|
|
|
1837
1567
|
interface LanguageOptions extends GenericLanguageOptions {
|
|
1838
1568
|
/**
|
|
@@ -1869,24 +1599,7 @@ export namespace Linter {
|
|
|
1869
1599
|
parserOptions?: Linter.ParserOptions | undefined;
|
|
1870
1600
|
}
|
|
1871
1601
|
|
|
1872
|
-
|
|
1873
|
-
/**
|
|
1874
|
-
* A boolean value indicating if inline configuration is allowed.
|
|
1875
|
-
*/
|
|
1876
|
-
noInlineConfig?: boolean;
|
|
1877
|
-
|
|
1878
|
-
/**
|
|
1879
|
-
* A severity value indicating if and how unused disable directives should be
|
|
1880
|
-
* tracked and reported.
|
|
1881
|
-
*/
|
|
1882
|
-
reportUnusedDisableDirectives?: Severity | StringSeverity | boolean;
|
|
1883
|
-
|
|
1884
|
-
/**
|
|
1885
|
-
* A severity value indicating if and how unused inline configs should be
|
|
1886
|
-
* tracked and reported.
|
|
1887
|
-
*/
|
|
1888
|
-
reportUnusedInlineConfigs?: Severity | StringSeverity;
|
|
1889
|
-
}
|
|
1602
|
+
type LinterOptions = LinterOptionsConfig;
|
|
1890
1603
|
|
|
1891
1604
|
/**
|
|
1892
1605
|
* Performance statistics.
|
|
@@ -1977,45 +1690,14 @@ export class ESLint {
|
|
|
1977
1690
|
}
|
|
1978
1691
|
|
|
1979
1692
|
export namespace ESLint {
|
|
1980
|
-
type ConfigData<Rules extends Linter.RulesRecord =
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
parserOptions?: Linter.ParserOptions | undefined;
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
interface ObjectMetaProperties {
|
|
1992
|
-
/** @deprecated Use `meta.name` instead. */
|
|
1993
|
-
name?: string | undefined;
|
|
1994
|
-
|
|
1995
|
-
/** @deprecated Use `meta.version` instead. */
|
|
1996
|
-
version?: string | undefined;
|
|
1997
|
-
|
|
1998
|
-
meta?: {
|
|
1999
|
-
name?: string | undefined;
|
|
2000
|
-
version?: string | undefined;
|
|
2001
|
-
};
|
|
2002
|
-
}
|
|
2003
|
-
|
|
2004
|
-
interface Plugin extends ObjectMetaProperties {
|
|
2005
|
-
meta?: ObjectMetaProperties["meta"] & {
|
|
2006
|
-
namespace?: string | undefined;
|
|
2007
|
-
};
|
|
2008
|
-
configs?:
|
|
2009
|
-
| Record<
|
|
2010
|
-
string,
|
|
2011
|
-
Linter.LegacyConfig | Linter.Config | Linter.Config[]
|
|
2012
|
-
>
|
|
2013
|
-
| undefined;
|
|
2014
|
-
environments?: Record<string, Environment> | undefined;
|
|
2015
|
-
languages?: Record<string, Language> | undefined;
|
|
2016
|
-
processors?: Record<string, Linter.Processor> | undefined;
|
|
2017
|
-
rules?: Record<string, RuleDefinition> | undefined;
|
|
2018
|
-
}
|
|
1693
|
+
type ConfigData<Rules extends Linter.RulesRecord = RulesConfig> = Omit<
|
|
1694
|
+
Linter.LegacyConfig<Rules>,
|
|
1695
|
+
"$schema"
|
|
1696
|
+
>;
|
|
1697
|
+
|
|
1698
|
+
type Environment = EnvironmentConfig;
|
|
1699
|
+
type ObjectMetaProperties = CoreObjectMetaProperties;
|
|
1700
|
+
type Plugin = CorePlugin;
|
|
2019
1701
|
|
|
2020
1702
|
type FixType = "directive" | "problem" | "suggestion" | "layout";
|
|
2021
1703
|
|