eslint 9.32.0 → 9.34.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/lib/cli-engine/file-enumerator.js +1 -1
- package/lib/cli.js +62 -266
- package/lib/config/flat-config-schema.js +1 -1
- package/lib/eslint/eslint-helpers.js +426 -6
- package/lib/eslint/eslint.js +376 -312
- package/lib/eslint/worker.js +164 -0
- package/lib/languages/js/source-code/source-code.js +3 -4
- package/lib/linter/interpolate.js +1 -1
- package/lib/linter/linter.js +3 -4
- package/lib/options.js +23 -9
- package/lib/rules/dot-notation.js +1 -1
- package/lib/rules/grouped-accessor-pairs.js +8 -7
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/no-alert.js +1 -1
- package/lib/rules/no-empty-function.js +1 -1
- package/lib/rules/no-irregular-whitespace.js +2 -2
- package/lib/rules/no-loss-of-precision.js +26 -3
- package/lib/rules/no-mixed-spaces-and-tabs.js +1 -0
- package/lib/rules/no-octal.js +1 -4
- package/lib/rules/no-restricted-globals.js +131 -21
- package/lib/rules/no-trailing-spaces.js +2 -1
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/one-var.js +63 -30
- package/lib/rules/prefer-regex-literals.js +1 -1
- package/lib/rules/utils/ast-utils.js +1 -1
- package/lib/rules/utils/char-source.js +1 -1
- package/lib/rules/yoda.js +2 -2
- package/lib/services/warning-service.js +13 -0
- package/lib/shared/naming.js +1 -1
- package/lib/shared/translate-cli-options.js +281 -0
- package/lib/types/index.d.ts +5 -0
- package/lib/types/rules.d.ts +22 -9
- package/package.json +5 -5
package/lib/rules/one-var.js
CHANGED
@@ -64,6 +64,12 @@ module.exports = {
|
|
64
64
|
const: {
|
65
65
|
enum: ["always", "never", "consecutive"],
|
66
66
|
},
|
67
|
+
using: {
|
68
|
+
enum: ["always", "never", "consecutive"],
|
69
|
+
},
|
70
|
+
awaitUsing: {
|
71
|
+
enum: ["always", "never", "consecutive"],
|
72
|
+
},
|
67
73
|
},
|
68
74
|
additionalProperties: false,
|
69
75
|
},
|
@@ -112,6 +118,8 @@ module.exports = {
|
|
112
118
|
options.var = { uninitialized: mode, initialized: mode };
|
113
119
|
options.let = { uninitialized: mode, initialized: mode };
|
114
120
|
options.const = { uninitialized: mode, initialized: mode };
|
121
|
+
options.using = { uninitialized: mode, initialized: mode };
|
122
|
+
options.awaitUsing = { uninitialized: mode, initialized: mode };
|
115
123
|
} else if (typeof mode === "object") {
|
116
124
|
// options configuration is an object
|
117
125
|
options.separateRequires = !!mode.separateRequires;
|
@@ -121,15 +129,27 @@ module.exports = {
|
|
121
129
|
uninitialized: mode.const,
|
122
130
|
initialized: mode.const,
|
123
131
|
};
|
132
|
+
options.using = {
|
133
|
+
uninitialized: mode.using,
|
134
|
+
initialized: mode.using,
|
135
|
+
};
|
136
|
+
options.awaitUsing = {
|
137
|
+
uninitialized: mode.awaitUsing,
|
138
|
+
initialized: mode.awaitUsing,
|
139
|
+
};
|
124
140
|
if (Object.hasOwn(mode, "uninitialized")) {
|
125
141
|
options.var.uninitialized = mode.uninitialized;
|
126
142
|
options.let.uninitialized = mode.uninitialized;
|
127
143
|
options.const.uninitialized = mode.uninitialized;
|
144
|
+
options.using.uninitialized = mode.uninitialized;
|
145
|
+
options.awaitUsing.uninitialized = mode.uninitialized;
|
128
146
|
}
|
129
147
|
if (Object.hasOwn(mode, "initialized")) {
|
130
148
|
options.var.initialized = mode.initialized;
|
131
149
|
options.let.initialized = mode.initialized;
|
132
150
|
options.const.initialized = mode.initialized;
|
151
|
+
options.using.initialized = mode.initialized;
|
152
|
+
options.awaitUsing.initialized = mode.initialized;
|
133
153
|
}
|
134
154
|
}
|
135
155
|
|
@@ -151,6 +171,8 @@ module.exports = {
|
|
151
171
|
blockStack.push({
|
152
172
|
let: { initialized: false, uninitialized: false },
|
153
173
|
const: { initialized: false, uninitialized: false },
|
174
|
+
using: { initialized: false, uninitialized: false },
|
175
|
+
awaitUsing: { initialized: false, uninitialized: false },
|
154
176
|
});
|
155
177
|
}
|
156
178
|
|
@@ -199,7 +221,7 @@ module.exports = {
|
|
199
221
|
|
200
222
|
/**
|
201
223
|
* Records whether initialized/uninitialized/required variables are defined in current scope.
|
202
|
-
* @param {string} statementType
|
224
|
+
* @param {string} statementType one of: "var", "let", "const", "using", or "awaitUsing"
|
203
225
|
* @param {ASTNode[]} declarations List of declarations
|
204
226
|
* @param {Object} currentScope The scope being investigated
|
205
227
|
* @returns {void}
|
@@ -234,7 +256,7 @@ module.exports = {
|
|
234
256
|
|
235
257
|
/**
|
236
258
|
* Determines the current scope (function or block)
|
237
|
-
* @param {string} statementType
|
259
|
+
* @param {string} statementType one of: "var", "let", "const", "using", or "awaitUsing"
|
238
260
|
* @returns {Object} The scope associated with statementType
|
239
261
|
*/
|
240
262
|
function getCurrentScope(statementType) {
|
@@ -246,6 +268,10 @@ module.exports = {
|
|
246
268
|
currentScope = blockStack.at(-1).let;
|
247
269
|
} else if (statementType === "const") {
|
248
270
|
currentScope = blockStack.at(-1).const;
|
271
|
+
} else if (statementType === "using") {
|
272
|
+
currentScope = blockStack.at(-1).using;
|
273
|
+
} else if (statementType === "awaitUsing") {
|
274
|
+
currentScope = blockStack.at(-1).awaitUsing;
|
249
275
|
}
|
250
276
|
return currentScope;
|
251
277
|
}
|
@@ -271,7 +297,7 @@ module.exports = {
|
|
271
297
|
|
272
298
|
/**
|
273
299
|
* Determines if there is more than one var statement in the current scope.
|
274
|
-
* @param {string} statementType
|
300
|
+
* @param {string} statementType one of: "var", "let", "const", "using", or "awaitUsing"
|
275
301
|
* @param {ASTNode[]} declarations List of declarations
|
276
302
|
* @returns {boolean} Returns true if it is the first var declaration, false if not.
|
277
303
|
* @private
|
@@ -333,24 +359,27 @@ module.exports = {
|
|
333
359
|
);
|
334
360
|
const previousNode = body[currentIndex - 1];
|
335
361
|
|
336
|
-
return fixer
|
337
|
-
const type = sourceCode.
|
338
|
-
const
|
339
|
-
const res = [];
|
362
|
+
return function* joinDeclarationsFixer(fixer) {
|
363
|
+
const type = sourceCode.getFirstToken(declaration.parent);
|
364
|
+
const beforeType = sourceCode.getTokenBefore(type);
|
340
365
|
|
341
366
|
if (
|
342
367
|
previousNode &&
|
343
|
-
previousNode.kind ===
|
368
|
+
previousNode.kind === declaration.parent.kind
|
344
369
|
) {
|
345
|
-
if (
|
346
|
-
|
370
|
+
if (beforeType.value === ";") {
|
371
|
+
yield fixer.replaceText(beforeType, ",");
|
347
372
|
} else {
|
348
|
-
|
373
|
+
yield fixer.insertTextAfter(beforeType, ",");
|
374
|
+
}
|
375
|
+
|
376
|
+
if (declaration.parent.kind === "await using") {
|
377
|
+
const usingToken = sourceCode.getTokenAfter(type);
|
378
|
+
yield fixer.remove(usingToken);
|
349
379
|
}
|
350
|
-
res.push(fixer.replaceText(type, ""));
|
351
|
-
}
|
352
380
|
|
353
|
-
|
381
|
+
yield fixer.replaceText(type, "");
|
382
|
+
}
|
354
383
|
};
|
355
384
|
}
|
356
385
|
|
@@ -440,7 +469,10 @@ module.exports = {
|
|
440
469
|
tokenAfterDeclarator.range[0],
|
441
470
|
lastComment.range[0],
|
442
471
|
],
|
443
|
-
`;${sourceCode.text.slice(
|
472
|
+
`;${sourceCode.text.slice(
|
473
|
+
tokenAfterDeclarator.range[1],
|
474
|
+
lastComment.range[0],
|
475
|
+
)}${exportPlacement}${declaration.kind} `,
|
444
476
|
);
|
445
477
|
}
|
446
478
|
|
@@ -461,8 +493,9 @@ module.exports = {
|
|
461
493
|
function checkVariableDeclaration(node) {
|
462
494
|
const parent = node.parent;
|
463
495
|
const type = node.kind;
|
496
|
+
const key = type === "await using" ? "awaitUsing" : type;
|
464
497
|
|
465
|
-
if (!options[
|
498
|
+
if (!options[key]) {
|
466
499
|
return;
|
467
500
|
}
|
468
501
|
|
@@ -471,7 +504,7 @@ module.exports = {
|
|
471
504
|
const mixedRequires =
|
472
505
|
declarations.some(isRequire) && !declarations.every(isRequire);
|
473
506
|
|
474
|
-
if (options[
|
507
|
+
if (options[key].initialized === MODE_ALWAYS) {
|
475
508
|
if (options.separateRequires && mixedRequires) {
|
476
509
|
context.report({
|
477
510
|
node,
|
@@ -508,8 +541,8 @@ module.exports = {
|
|
508
541
|
);
|
509
542
|
|
510
543
|
if (
|
511
|
-
options[
|
512
|
-
options[
|
544
|
+
options[key].initialized === MODE_CONSECUTIVE &&
|
545
|
+
options[key].uninitialized === MODE_CONSECUTIVE
|
513
546
|
) {
|
514
547
|
context.report({
|
515
548
|
node,
|
@@ -520,7 +553,7 @@ module.exports = {
|
|
520
553
|
fix: joinDeclarations(declarations),
|
521
554
|
});
|
522
555
|
} else if (
|
523
|
-
options[
|
556
|
+
options[key].initialized === MODE_CONSECUTIVE &&
|
524
557
|
declarationCounts.initialized > 0 &&
|
525
558
|
previousDeclCounts.initialized > 0
|
526
559
|
) {
|
@@ -533,7 +566,7 @@ module.exports = {
|
|
533
566
|
fix: joinDeclarations(declarations),
|
534
567
|
});
|
535
568
|
} else if (
|
536
|
-
options[
|
569
|
+
options[key].uninitialized === MODE_CONSECUTIVE &&
|
537
570
|
declarationCounts.uninitialized > 0 &&
|
538
571
|
previousDeclCounts.uninitialized > 0
|
539
572
|
) {
|
@@ -550,10 +583,10 @@ module.exports = {
|
|
550
583
|
}
|
551
584
|
|
552
585
|
// always
|
553
|
-
if (!hasOnlyOneStatement(
|
586
|
+
if (!hasOnlyOneStatement(key, declarations)) {
|
554
587
|
if (
|
555
|
-
options[
|
556
|
-
options[
|
588
|
+
options[key].initialized === MODE_ALWAYS &&
|
589
|
+
options[key].uninitialized === MODE_ALWAYS
|
557
590
|
) {
|
558
591
|
context.report({
|
559
592
|
node,
|
@@ -565,7 +598,7 @@ module.exports = {
|
|
565
598
|
});
|
566
599
|
} else {
|
567
600
|
if (
|
568
|
-
options[
|
601
|
+
options[key].initialized === MODE_ALWAYS &&
|
569
602
|
declarationCounts.initialized > 0
|
570
603
|
) {
|
571
604
|
context.report({
|
@@ -578,7 +611,7 @@ module.exports = {
|
|
578
611
|
});
|
579
612
|
}
|
580
613
|
if (
|
581
|
-
options[
|
614
|
+
options[key].uninitialized === MODE_ALWAYS &&
|
582
615
|
declarationCounts.uninitialized > 0
|
583
616
|
) {
|
584
617
|
if (
|
@@ -608,8 +641,8 @@ module.exports = {
|
|
608
641
|
|
609
642
|
if (totalDeclarations > 1) {
|
610
643
|
if (
|
611
|
-
options[
|
612
|
-
options[
|
644
|
+
options[key].initialized === MODE_NEVER &&
|
645
|
+
options[key].uninitialized === MODE_NEVER
|
613
646
|
) {
|
614
647
|
// both initialized and uninitialized
|
615
648
|
context.report({
|
@@ -621,7 +654,7 @@ module.exports = {
|
|
621
654
|
fix: splitDeclarations(node),
|
622
655
|
});
|
623
656
|
} else if (
|
624
|
-
options[
|
657
|
+
options[key].initialized === MODE_NEVER &&
|
625
658
|
declarationCounts.initialized > 0
|
626
659
|
) {
|
627
660
|
// initialized
|
@@ -634,7 +667,7 @@ module.exports = {
|
|
634
667
|
fix: splitDeclarations(node),
|
635
668
|
});
|
636
669
|
} else if (
|
637
|
-
options[
|
670
|
+
options[key].uninitialized === MODE_NEVER &&
|
638
671
|
declarationCounts.uninitialized > 0
|
639
672
|
) {
|
640
673
|
// uninitialized
|
@@ -58,7 +58,7 @@ const DECIMAL_INTEGER_PATTERN = /^(?:0|0[0-7]*[89]\d*|[1-9](?:_?\d)*)$/u;
|
|
58
58
|
|
59
59
|
// Tests the presence of at least one LegacyOctalEscapeSequence or NonOctalDecimalEscapeSequence in a raw string
|
60
60
|
const OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN =
|
61
|
-
/^(?:[^\\]|\\.)*\\(?:[1-9]|0
|
61
|
+
/^(?:[^\\]|\\.)*\\(?:[1-9]|0\d)/su;
|
62
62
|
|
63
63
|
const LOGICAL_ASSIGNMENT_OPERATORS = new Set(["&&=", "||=", "??="]);
|
64
64
|
|
@@ -85,7 +85,7 @@ function readHexSequence(reader, length) {
|
|
85
85
|
* @returns {string} A code unit.
|
86
86
|
*/
|
87
87
|
function readUnicodeSequence(reader) {
|
88
|
-
const regExp = /\{(?<hexDigits>[\dA-
|
88
|
+
const regExp = /\{(?<hexDigits>[\dA-F]+)\}/iuy;
|
89
89
|
|
90
90
|
regExp.lastIndex = reader.pos;
|
91
91
|
const match = regExp.exec(reader.source);
|
package/lib/rules/yoda.js
CHANGED
@@ -20,7 +20,7 @@ const astUtils = require("./utils/ast-utils");
|
|
20
20
|
* @returns {boolean} Whether or not it is a comparison operator.
|
21
21
|
*/
|
22
22
|
function isComparisonOperator(operator) {
|
23
|
-
return /^(
|
23
|
+
return /^(?:==|===|!=|!==|<|>|<=|>=)$/u.test(operator);
|
24
24
|
}
|
25
25
|
|
26
26
|
/**
|
@@ -29,7 +29,7 @@ function isComparisonOperator(operator) {
|
|
29
29
|
* @returns {boolean} Whether or not it is an equality operator.
|
30
30
|
*/
|
31
31
|
function isEqualityOperator(operator) {
|
32
|
-
return /^(
|
32
|
+
return /^(?:==|===)$/u.test(operator);
|
33
33
|
}
|
34
34
|
|
35
35
|
/**
|
@@ -80,6 +80,19 @@ class WarningService {
|
|
80
80
|
emitInactiveFlagWarning(flag, message) {
|
81
81
|
this.emitWarning(message, `ESLintInactiveFlag_${flag}`);
|
82
82
|
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Emits a warning when a suboptimal concurrency setting is detected.
|
86
|
+
* Currently, this is only used to warn when the net linting ratio is low.
|
87
|
+
* @param {string} notice A notice about how to improve performance.
|
88
|
+
* @returns {void}
|
89
|
+
*/
|
90
|
+
emitPoorConcurrencyWarning(notice) {
|
91
|
+
this.emitWarning(
|
92
|
+
`You may ${notice} to improve performance.`,
|
93
|
+
"ESLintPoorConcurrencyWarning",
|
94
|
+
);
|
95
|
+
}
|
83
96
|
}
|
84
97
|
|
85
98
|
module.exports = { WarningService };
|
package/lib/shared/naming.js
CHANGED
@@ -0,0 +1,281 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Translates CLI options into ESLint constructor options.
|
3
|
+
* @author Nicholas C. Zakas
|
4
|
+
* @author Francesco Trotta
|
5
|
+
*/
|
6
|
+
|
7
|
+
"use strict";
|
8
|
+
|
9
|
+
//------------------------------------------------------------------------------
|
10
|
+
// Requirements
|
11
|
+
//------------------------------------------------------------------------------
|
12
|
+
|
13
|
+
const { normalizeSeverityToString } = require("./severity");
|
14
|
+
const { getShorthandName, normalizePackageName } = require("./naming");
|
15
|
+
const { ModuleImporter } = require("@humanwhocodes/module-importer");
|
16
|
+
|
17
|
+
//------------------------------------------------------------------------------
|
18
|
+
// Types
|
19
|
+
//------------------------------------------------------------------------------
|
20
|
+
|
21
|
+
/** @typedef {import("../types").ESLint.Options} ESLintOptions */
|
22
|
+
/** @typedef {import("../types").ESLint.LegacyOptions} LegacyESLintOptions */
|
23
|
+
/** @typedef {import("../types").Linter.LintMessage} LintMessage */
|
24
|
+
/** @typedef {import("../options").ParsedCLIOptions} ParsedCLIOptions */
|
25
|
+
/** @typedef {import("../types").ESLint.Plugin} Plugin */
|
26
|
+
|
27
|
+
//------------------------------------------------------------------------------
|
28
|
+
// Helpers
|
29
|
+
//------------------------------------------------------------------------------
|
30
|
+
|
31
|
+
/**
|
32
|
+
* Loads plugins with the specified names.
|
33
|
+
* @param {{ "import": (name: string) => Promise<any> }} importer An object with an `import` method called once for each plugin.
|
34
|
+
* @param {string[]} pluginNames The names of the plugins to be loaded, with or without the "eslint-plugin-" prefix.
|
35
|
+
* @returns {Promise<Record<string, Plugin>>} A mapping of plugin short names to implementations.
|
36
|
+
*/
|
37
|
+
async function loadPlugins(importer, pluginNames) {
|
38
|
+
const plugins = {};
|
39
|
+
|
40
|
+
await Promise.all(
|
41
|
+
pluginNames.map(async pluginName => {
|
42
|
+
const longName = normalizePackageName(pluginName, "eslint-plugin");
|
43
|
+
const module = await importer.import(longName);
|
44
|
+
|
45
|
+
if (!("default" in module)) {
|
46
|
+
throw new Error(
|
47
|
+
`"${longName}" cannot be used with the \`--plugin\` option because its default module does not provide a \`default\` export`,
|
48
|
+
);
|
49
|
+
}
|
50
|
+
|
51
|
+
const shortName = getShorthandName(pluginName, "eslint-plugin");
|
52
|
+
|
53
|
+
plugins[shortName] = module.default;
|
54
|
+
}),
|
55
|
+
);
|
56
|
+
|
57
|
+
return plugins;
|
58
|
+
}
|
59
|
+
|
60
|
+
/**
|
61
|
+
* Predicate function for whether or not to apply fixes in quiet mode.
|
62
|
+
* If a message is a warning, do not apply a fix.
|
63
|
+
* @param {LintMessage} message The lint result.
|
64
|
+
* @returns {boolean} True if the lint message is an error (and thus should be
|
65
|
+
* autofixed), false otherwise.
|
66
|
+
*/
|
67
|
+
function quietFixPredicate(message) {
|
68
|
+
return message.severity === 2;
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Predicate function for whether or not to run a rule in quiet mode.
|
73
|
+
* If a rule is set to warning, do not run it.
|
74
|
+
* @param {{ ruleId: string; severity: number; }} rule The rule id and severity.
|
75
|
+
* @returns {boolean} True if the lint rule should run, false otherwise.
|
76
|
+
*/
|
77
|
+
function quietRuleFilter(rule) {
|
78
|
+
return rule.severity === 2;
|
79
|
+
}
|
80
|
+
|
81
|
+
//------------------------------------------------------------------------------
|
82
|
+
// Public Interface
|
83
|
+
//------------------------------------------------------------------------------
|
84
|
+
|
85
|
+
/**
|
86
|
+
* Translates the CLI options into the options expected by the ESLint constructor.
|
87
|
+
* @param {ParsedCLIOptions} cliOptions The CLI options to translate.
|
88
|
+
* @param {"flat"|"eslintrc"} [configType="eslintrc"] The format of the config to generate.
|
89
|
+
* @returns {Promise<ESLintOptions | LegacyESLintOptions>} The options object for the ESLint constructor.
|
90
|
+
*/
|
91
|
+
async function translateOptions(
|
92
|
+
{
|
93
|
+
cache,
|
94
|
+
cacheFile,
|
95
|
+
cacheLocation,
|
96
|
+
cacheStrategy,
|
97
|
+
concurrency,
|
98
|
+
config,
|
99
|
+
configLookup,
|
100
|
+
env,
|
101
|
+
errorOnUnmatchedPattern,
|
102
|
+
eslintrc,
|
103
|
+
ext,
|
104
|
+
fix,
|
105
|
+
fixDryRun,
|
106
|
+
fixType,
|
107
|
+
flag,
|
108
|
+
global,
|
109
|
+
ignore,
|
110
|
+
ignorePath,
|
111
|
+
ignorePattern,
|
112
|
+
inlineConfig,
|
113
|
+
parser,
|
114
|
+
parserOptions,
|
115
|
+
plugin,
|
116
|
+
quiet,
|
117
|
+
reportUnusedDisableDirectives,
|
118
|
+
reportUnusedDisableDirectivesSeverity,
|
119
|
+
reportUnusedInlineConfigs,
|
120
|
+
resolvePluginsRelativeTo,
|
121
|
+
rule,
|
122
|
+
rulesdir,
|
123
|
+
stats,
|
124
|
+
warnIgnored,
|
125
|
+
passOnNoPatterns,
|
126
|
+
maxWarnings,
|
127
|
+
},
|
128
|
+
configType,
|
129
|
+
) {
|
130
|
+
let overrideConfig, overrideConfigFile;
|
131
|
+
const importer = new ModuleImporter();
|
132
|
+
|
133
|
+
if (configType === "flat") {
|
134
|
+
overrideConfigFile =
|
135
|
+
typeof config === "string" ? config : !configLookup;
|
136
|
+
if (overrideConfigFile === false) {
|
137
|
+
overrideConfigFile = void 0;
|
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
|
+
}
|
152
|
+
|
153
|
+
if (parserOptions) {
|
154
|
+
languageOptions.parserOptions = parserOptions;
|
155
|
+
}
|
156
|
+
|
157
|
+
if (parser) {
|
158
|
+
languageOptions.parser = await importer.import(parser);
|
159
|
+
}
|
160
|
+
|
161
|
+
overrideConfig = [
|
162
|
+
{
|
163
|
+
...(Object.keys(languageOptions).length > 0
|
164
|
+
? { languageOptions }
|
165
|
+
: {}),
|
166
|
+
rules: rule ? rule : {},
|
167
|
+
},
|
168
|
+
];
|
169
|
+
|
170
|
+
if (
|
171
|
+
reportUnusedDisableDirectives ||
|
172
|
+
reportUnusedDisableDirectivesSeverity !== void 0
|
173
|
+
) {
|
174
|
+
overrideConfig[0].linterOptions = {
|
175
|
+
reportUnusedDisableDirectives: reportUnusedDisableDirectives
|
176
|
+
? "error"
|
177
|
+
: normalizeSeverityToString(
|
178
|
+
reportUnusedDisableDirectivesSeverity,
|
179
|
+
),
|
180
|
+
};
|
181
|
+
}
|
182
|
+
|
183
|
+
if (reportUnusedInlineConfigs !== void 0) {
|
184
|
+
overrideConfig[0].linterOptions = {
|
185
|
+
...overrideConfig[0].linterOptions,
|
186
|
+
reportUnusedInlineConfigs: normalizeSeverityToString(
|
187
|
+
reportUnusedInlineConfigs,
|
188
|
+
),
|
189
|
+
};
|
190
|
+
}
|
191
|
+
|
192
|
+
if (plugin) {
|
193
|
+
overrideConfig[0].plugins = await loadPlugins(importer, plugin);
|
194
|
+
}
|
195
|
+
|
196
|
+
if (ext) {
|
197
|
+
overrideConfig.push({
|
198
|
+
files: ext.map(
|
199
|
+
extension =>
|
200
|
+
`**/*${extension.startsWith(".") ? "" : "."}${extension}`,
|
201
|
+
),
|
202
|
+
});
|
203
|
+
}
|
204
|
+
} else {
|
205
|
+
overrideConfigFile = config;
|
206
|
+
|
207
|
+
overrideConfig = {
|
208
|
+
env:
|
209
|
+
env &&
|
210
|
+
env.reduce((obj, name) => {
|
211
|
+
obj[name] = true;
|
212
|
+
return obj;
|
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
|
+
};
|
230
|
+
}
|
231
|
+
|
232
|
+
const options = {
|
233
|
+
allowInlineConfig: inlineConfig,
|
234
|
+
cache,
|
235
|
+
cacheLocation: cacheLocation || cacheFile,
|
236
|
+
cacheStrategy,
|
237
|
+
errorOnUnmatchedPattern,
|
238
|
+
fix: (fix || fixDryRun) && (quiet ? quietFixPredicate : true),
|
239
|
+
fixTypes: fixType,
|
240
|
+
ignore,
|
241
|
+
overrideConfig,
|
242
|
+
overrideConfigFile,
|
243
|
+
passOnNoPatterns,
|
244
|
+
};
|
245
|
+
|
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
|
+
return options;
|
279
|
+
}
|
280
|
+
|
281
|
+
module.exports = translateOptions;
|
package/lib/types/index.d.ts
CHANGED
@@ -1966,6 +1966,10 @@ export class ESLint {
|
|
1966
1966
|
isPathIgnored(filePath: string): Promise<boolean>;
|
1967
1967
|
|
1968
1968
|
loadFormatter(nameOrPath?: string): Promise<ESLint.LoadedFormatter>;
|
1969
|
+
|
1970
|
+
static fromOptionsModule(optionsURL: {
|
1971
|
+
readonly href: string;
|
1972
|
+
}): Promise<ESLint>;
|
1969
1973
|
}
|
1970
1974
|
|
1971
1975
|
export namespace ESLint {
|
@@ -2047,6 +2051,7 @@ export namespace ESLint {
|
|
2047
2051
|
cacheStrategy?: CacheStrategy | undefined;
|
2048
2052
|
|
2049
2053
|
// Other Options
|
2054
|
+
concurrency?: number | "auto" | "off" | undefined;
|
2050
2055
|
flags?: string[] | undefined;
|
2051
2056
|
}
|
2052
2057
|
|
package/lib/types/rules.d.ts
CHANGED
@@ -117,7 +117,7 @@ export interface ESLintRules extends Linter.RulesRecord {
|
|
117
117
|
*/
|
118
118
|
enforceForClassMembers: boolean;
|
119
119
|
/**
|
120
|
-
* @default
|
120
|
+
* @default false
|
121
121
|
*/
|
122
122
|
enforceForTSTypes: boolean;
|
123
123
|
}>,
|
@@ -3403,13 +3403,26 @@ export interface ESLintRules extends Linter.RulesRecord {
|
|
3403
3403
|
*/
|
3404
3404
|
"no-restricted-globals": Linter.RuleEntry<
|
3405
3405
|
[
|
3406
|
-
...
|
3407
|
-
|
|
3408
|
-
|
3409
|
-
|
3410
|
-
|
3411
|
-
|
3412
|
-
|
3406
|
+
...(
|
3407
|
+
| Array<
|
3408
|
+
| string
|
3409
|
+
| {
|
3410
|
+
name: string;
|
3411
|
+
message?: string | undefined;
|
3412
|
+
}
|
3413
|
+
>
|
3414
|
+
| Array<{
|
3415
|
+
globals: Array<
|
3416
|
+
| string
|
3417
|
+
| {
|
3418
|
+
name: string;
|
3419
|
+
message?: string | undefined;
|
3420
|
+
}
|
3421
|
+
>;
|
3422
|
+
checkGlobalObject?: boolean;
|
3423
|
+
globalObjects?: string[];
|
3424
|
+
}>
|
3425
|
+
),
|
3413
3426
|
]
|
3414
3427
|
>;
|
3415
3428
|
|
@@ -4509,7 +4522,7 @@ export interface ESLintRules extends Linter.RulesRecord {
|
|
4509
4522
|
*/
|
4510
4523
|
separateRequires: boolean;
|
4511
4524
|
} & Record<
|
4512
|
-
"var" | "let" | "const",
|
4525
|
+
"var" | "let" | "const" | "using" | "awaitUsing",
|
4513
4526
|
"always" | "never" | "consecutive"
|
4514
4527
|
>
|
4515
4528
|
>
|