eslint-linter-browserify 10.1.0 → 10.2.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/linter.cjs +259 -89
- package/linter.js +259 -89
- package/linter.min.js +3 -3
- package/linter.mjs +259 -89
- package/package.json +3 -3
package/linter.cjs
CHANGED
|
@@ -4216,7 +4216,7 @@ function requireEslintVisitorKeys$2 () {
|
|
|
4216
4216
|
return eslintVisitorKeys$2;
|
|
4217
4217
|
}
|
|
4218
4218
|
|
|
4219
|
-
var version = "10.
|
|
4219
|
+
var version = "10.2.0";
|
|
4220
4220
|
var require$$3$1 = {
|
|
4221
4221
|
version: version};
|
|
4222
4222
|
|
|
@@ -10012,6 +10012,7 @@ function requireGlobals () {
|
|
|
10012
10012
|
AsyncDisposableStack: false,
|
|
10013
10013
|
DisposableStack: false,
|
|
10014
10014
|
SuppressedError: false,
|
|
10015
|
+
Temporal: false,
|
|
10015
10016
|
};
|
|
10016
10017
|
|
|
10017
10018
|
//-----------------------------------------------------------------------------
|
|
@@ -22913,7 +22914,9 @@ function requireCommonjs$1 () {
|
|
|
22913
22914
|
const x = numeric(n[0]);
|
|
22914
22915
|
const y = numeric(n[1]);
|
|
22915
22916
|
const width = Math.max(n[0].length, n[1].length);
|
|
22916
|
-
let incr = n.length === 3 && n[2] !== undefined ?
|
|
22917
|
+
let incr = n.length === 3 && n[2] !== undefined ?
|
|
22918
|
+
Math.max(Math.abs(numeric(n[2])), 1)
|
|
22919
|
+
: 1;
|
|
22917
22920
|
let test = lte;
|
|
22918
22921
|
const reverse = y < x;
|
|
22919
22922
|
if (reverse) {
|
|
@@ -23185,16 +23188,16 @@ function require_unescape () {
|
|
|
23185
23188
|
const unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true, } = {}) => {
|
|
23186
23189
|
if (magicalBraces) {
|
|
23187
23190
|
return windowsPathsNoEscape ?
|
|
23188
|
-
s.replace(/\[([
|
|
23191
|
+
s.replace(/\[([^/\\])\]/g, '$1')
|
|
23189
23192
|
: s
|
|
23190
|
-
.replace(/((?!\\).|^)\[([
|
|
23191
|
-
.replace(/\\([
|
|
23193
|
+
.replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2')
|
|
23194
|
+
.replace(/\\([^/])/g, '$1');
|
|
23192
23195
|
}
|
|
23193
23196
|
return windowsPathsNoEscape ?
|
|
23194
|
-
s.replace(/\[([
|
|
23197
|
+
s.replace(/\[([^/\\{}])\]/g, '$1')
|
|
23195
23198
|
: s
|
|
23196
|
-
.replace(/((?!\\).|^)\[([
|
|
23197
|
-
.replace(/\\([
|
|
23199
|
+
.replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2')
|
|
23200
|
+
.replace(/\\([^/{}])/g, '$1');
|
|
23198
23201
|
};
|
|
23199
23202
|
_unescape.unescape = unescape;
|
|
23200
23203
|
|
|
@@ -23399,15 +23402,14 @@ function requireAst$1 () {
|
|
|
23399
23402
|
}
|
|
23400
23403
|
// reconstructs the pattern
|
|
23401
23404
|
toString() {
|
|
23402
|
-
|
|
23403
|
-
|
|
23404
|
-
|
|
23405
|
-
|
|
23406
|
-
|
|
23407
|
-
|
|
23408
|
-
|
|
23409
|
-
|
|
23410
|
-
}
|
|
23405
|
+
return (this.#toString !== undefined ? this.#toString
|
|
23406
|
+
: !this.type ?
|
|
23407
|
+
(this.#toString = this.#parts.map(p => String(p)).join(''))
|
|
23408
|
+
: (this.#toString =
|
|
23409
|
+
this.type +
|
|
23410
|
+
'(' +
|
|
23411
|
+
this.#parts.map(p => String(p)).join('|') +
|
|
23412
|
+
')'));
|
|
23411
23413
|
}
|
|
23412
23414
|
#fillNegs() {
|
|
23413
23415
|
/* c8 ignore start */
|
|
@@ -23687,7 +23689,7 @@ function requireAst$1 () {
|
|
|
23687
23689
|
}
|
|
23688
23690
|
#canUsurpType(c) {
|
|
23689
23691
|
const m = usurpMap.get(this.type);
|
|
23690
|
-
return !!
|
|
23692
|
+
return !!m?.has(c);
|
|
23691
23693
|
}
|
|
23692
23694
|
#canUsurp(child) {
|
|
23693
23695
|
if (!child ||
|
|
@@ -24116,7 +24118,7 @@ function requireCommonjs () {
|
|
|
24116
24118
|
};
|
|
24117
24119
|
exports$1.minimatch = minimatch;
|
|
24118
24120
|
// Optimized checking for the most common glob patterns.
|
|
24119
|
-
const starDotExtRE = /^\*+([
|
|
24121
|
+
const starDotExtRE = /^\*+([^+@!?*[(]*)$/;
|
|
24120
24122
|
const starDotExtTest = (ext) => (f) => !f.startsWith('.') && f.endsWith(ext);
|
|
24121
24123
|
const starDotExtTestDot = (ext) => (f) => f.endsWith(ext);
|
|
24122
24124
|
const starDotExtTestNocase = (ext) => {
|
|
@@ -24135,7 +24137,7 @@ function requireCommonjs () {
|
|
|
24135
24137
|
const starRE = /^\*+$/;
|
|
24136
24138
|
const starTest = (f) => f.length !== 0 && !f.startsWith('.');
|
|
24137
24139
|
const starTestDot = (f) => f.length !== 0 && f !== '.' && f !== '..';
|
|
24138
|
-
const qmarksRE = /^\?+([
|
|
24140
|
+
const qmarksRE = /^\?+([^+@!?*[(]*)?$/;
|
|
24139
24141
|
const qmarksTestNocase = ([$0, ext = '']) => {
|
|
24140
24142
|
const noext = qmarksTestNoExt([$0]);
|
|
24141
24143
|
if (!ext)
|
|
@@ -24367,6 +24369,7 @@ function requireCommonjs () {
|
|
|
24367
24369
|
// step 2: expand braces
|
|
24368
24370
|
this.globSet = [...new Set(this.braceExpand())];
|
|
24369
24371
|
if (options.debug) {
|
|
24372
|
+
//oxlint-disable-next-line no-console
|
|
24370
24373
|
this.debug = (...args) => console.error(...args);
|
|
24371
24374
|
}
|
|
24372
24375
|
this.debug(this.pattern, this.globSet);
|
|
@@ -24429,10 +24432,10 @@ function requireCommonjs () {
|
|
|
24429
24432
|
preprocess(globParts) {
|
|
24430
24433
|
// if we're not in globstar mode, then turn ** into *
|
|
24431
24434
|
if (this.options.noglobstar) {
|
|
24432
|
-
for (
|
|
24433
|
-
for (let j = 0; j <
|
|
24434
|
-
if (
|
|
24435
|
-
|
|
24435
|
+
for (const partset of globParts) {
|
|
24436
|
+
for (let j = 0; j < partset.length; j++) {
|
|
24437
|
+
if (partset[j] === '**') {
|
|
24438
|
+
partset[j] = '*';
|
|
24436
24439
|
}
|
|
24437
24440
|
}
|
|
24438
24441
|
}
|
|
@@ -24520,7 +24523,11 @@ function requireCommonjs () {
|
|
|
24520
24523
|
let dd = 0;
|
|
24521
24524
|
while (-1 !== (dd = parts.indexOf('..', dd + 1))) {
|
|
24522
24525
|
const p = parts[dd - 1];
|
|
24523
|
-
if (p &&
|
|
24526
|
+
if (p &&
|
|
24527
|
+
p !== '.' &&
|
|
24528
|
+
p !== '..' &&
|
|
24529
|
+
p !== '**' &&
|
|
24530
|
+
!(this.isWindows && /^[a-z]:$/i.test(p))) {
|
|
24524
24531
|
didSomething = true;
|
|
24525
24532
|
parts.splice(dd - 1, 2);
|
|
24526
24533
|
dd -= 2;
|
|
@@ -24769,15 +24776,17 @@ function requireCommonjs () {
|
|
|
24769
24776
|
// split the pattern up into globstar-delimited sections
|
|
24770
24777
|
// the tail has to be at the end, and the others just have
|
|
24771
24778
|
// to be found in order from the head.
|
|
24772
|
-
const [head, body, tail] = partial ?
|
|
24773
|
-
|
|
24774
|
-
|
|
24775
|
-
|
|
24776
|
-
|
|
24777
|
-
|
|
24778
|
-
|
|
24779
|
-
|
|
24780
|
-
|
|
24779
|
+
const [head, body, tail] = partial ?
|
|
24780
|
+
[
|
|
24781
|
+
pattern.slice(patternIndex, firstgs),
|
|
24782
|
+
pattern.slice(firstgs + 1),
|
|
24783
|
+
[],
|
|
24784
|
+
]
|
|
24785
|
+
: [
|
|
24786
|
+
pattern.slice(patternIndex, firstgs),
|
|
24787
|
+
pattern.slice(firstgs + 1, lastgs),
|
|
24788
|
+
pattern.slice(lastgs + 1),
|
|
24789
|
+
];
|
|
24781
24790
|
// check the head, from the current file/pattern index.
|
|
24782
24791
|
if (head.length) {
|
|
24783
24792
|
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
@@ -25123,7 +25132,7 @@ function requireCommonjs () {
|
|
|
25123
25132
|
this.regexp = new RegExp(re, [...flags].join(''));
|
|
25124
25133
|
/* c8 ignore start */
|
|
25125
25134
|
}
|
|
25126
|
-
catch
|
|
25135
|
+
catch {
|
|
25127
25136
|
// should be impossible
|
|
25128
25137
|
this.regexp = false;
|
|
25129
25138
|
}
|
|
@@ -25138,7 +25147,7 @@ function requireCommonjs () {
|
|
|
25138
25147
|
if (this.preserveMultipleSlashes) {
|
|
25139
25148
|
return p.split('/');
|
|
25140
25149
|
}
|
|
25141
|
-
else if (this.isWindows && /^\/\/[
|
|
25150
|
+
else if (this.isWindows && /^\/\/[^/]+/.test(p)) {
|
|
25142
25151
|
// add an extra '' for the one we lose
|
|
25143
25152
|
return ['', ...p.split(/\/+/)];
|
|
25144
25153
|
}
|
|
@@ -25180,8 +25189,7 @@ function requireCommonjs () {
|
|
|
25180
25189
|
filename = ff[i];
|
|
25181
25190
|
}
|
|
25182
25191
|
}
|
|
25183
|
-
for (
|
|
25184
|
-
const pattern = set[i];
|
|
25192
|
+
for (const pattern of set) {
|
|
25185
25193
|
let file = ff;
|
|
25186
25194
|
if (options.matchBase && pattern.length === 1) {
|
|
25187
25195
|
file = [filename];
|
|
@@ -25300,7 +25308,7 @@ function requireCjs$1 () {
|
|
|
25300
25308
|
class ValidationStrategy {
|
|
25301
25309
|
/**
|
|
25302
25310
|
* Validates that a value is an array.
|
|
25303
|
-
* @param {
|
|
25311
|
+
* @param {unknown} value The value to validate.
|
|
25304
25312
|
* @returns {void}
|
|
25305
25313
|
* @throws {TypeError} If the value is invalid.
|
|
25306
25314
|
*/
|
|
@@ -25312,19 +25320,19 @@ function requireCjs$1 () {
|
|
|
25312
25320
|
|
|
25313
25321
|
/**
|
|
25314
25322
|
* Validates that a value is a boolean.
|
|
25315
|
-
* @param {
|
|
25323
|
+
* @param {unknown} value The value to validate.
|
|
25316
25324
|
* @returns {void}
|
|
25317
25325
|
* @throws {TypeError} If the value is invalid.
|
|
25318
25326
|
*/
|
|
25319
25327
|
static boolean(value) {
|
|
25320
25328
|
if (typeof value !== "boolean") {
|
|
25321
|
-
throw new TypeError("Expected a
|
|
25329
|
+
throw new TypeError("Expected a boolean.");
|
|
25322
25330
|
}
|
|
25323
25331
|
}
|
|
25324
25332
|
|
|
25325
25333
|
/**
|
|
25326
25334
|
* Validates that a value is a number.
|
|
25327
|
-
* @param {
|
|
25335
|
+
* @param {unknown} value The value to validate.
|
|
25328
25336
|
* @returns {void}
|
|
25329
25337
|
* @throws {TypeError} If the value is invalid.
|
|
25330
25338
|
*/
|
|
@@ -25335,8 +25343,8 @@ function requireCjs$1 () {
|
|
|
25335
25343
|
}
|
|
25336
25344
|
|
|
25337
25345
|
/**
|
|
25338
|
-
* Validates that a value is
|
|
25339
|
-
* @param {
|
|
25346
|
+
* Validates that a value is an object.
|
|
25347
|
+
* @param {unknown} value The value to validate.
|
|
25340
25348
|
* @returns {void}
|
|
25341
25349
|
* @throws {TypeError} If the value is invalid.
|
|
25342
25350
|
*/
|
|
@@ -25347,8 +25355,8 @@ function requireCjs$1 () {
|
|
|
25347
25355
|
}
|
|
25348
25356
|
|
|
25349
25357
|
/**
|
|
25350
|
-
* Validates that a value is
|
|
25351
|
-
* @param {
|
|
25358
|
+
* Validates that a value is an object or null.
|
|
25359
|
+
* @param {unknown} value The value to validate.
|
|
25352
25360
|
* @returns {void}
|
|
25353
25361
|
* @throws {TypeError} If the value is invalid.
|
|
25354
25362
|
*/
|
|
@@ -25360,7 +25368,7 @@ function requireCjs$1 () {
|
|
|
25360
25368
|
|
|
25361
25369
|
/**
|
|
25362
25370
|
* Validates that a value is a string.
|
|
25363
|
-
* @param {
|
|
25371
|
+
* @param {unknown} value The value to validate.
|
|
25364
25372
|
* @returns {void}
|
|
25365
25373
|
* @throws {TypeError} If the value is invalid.
|
|
25366
25374
|
*/
|
|
@@ -25372,7 +25380,7 @@ function requireCjs$1 () {
|
|
|
25372
25380
|
|
|
25373
25381
|
/**
|
|
25374
25382
|
* Validates that a value is a non-empty string.
|
|
25375
|
-
* @param {
|
|
25383
|
+
* @param {unknown} value The value to validate.
|
|
25376
25384
|
* @returns {void}
|
|
25377
25385
|
* @throws {TypeError} If the value is invalid.
|
|
25378
25386
|
*/
|
|
@@ -25547,13 +25555,17 @@ function requireCjs$1 () {
|
|
|
25547
25555
|
|
|
25548
25556
|
// add in all strategies
|
|
25549
25557
|
for (const key of Object.keys(definitions)) {
|
|
25550
|
-
|
|
25558
|
+
const definition = definitions[key];
|
|
25559
|
+
|
|
25560
|
+
validateDefinition(key, definition);
|
|
25561
|
+
|
|
25562
|
+
let normalizedDefinition = definition;
|
|
25551
25563
|
|
|
25552
25564
|
// normalize merge and validate methods if subschema is present
|
|
25553
|
-
if (typeof
|
|
25554
|
-
const schema = new ObjectSchema(
|
|
25555
|
-
|
|
25556
|
-
...
|
|
25565
|
+
if (typeof normalizedDefinition.schema === "object") {
|
|
25566
|
+
const schema = new ObjectSchema(normalizedDefinition.schema);
|
|
25567
|
+
normalizedDefinition = {
|
|
25568
|
+
...normalizedDefinition,
|
|
25557
25569
|
merge(first = {}, second = {}) {
|
|
25558
25570
|
return schema.merge(first, second);
|
|
25559
25571
|
},
|
|
@@ -25565,30 +25577,25 @@ function requireCjs$1 () {
|
|
|
25565
25577
|
}
|
|
25566
25578
|
|
|
25567
25579
|
// normalize the merge method in case there's a string
|
|
25568
|
-
if (typeof
|
|
25569
|
-
|
|
25570
|
-
...
|
|
25571
|
-
merge: MergeStrategy[
|
|
25572
|
-
/** @type {string} */ (definitions[key].merge)
|
|
25573
|
-
],
|
|
25580
|
+
if (typeof normalizedDefinition.merge === "string") {
|
|
25581
|
+
normalizedDefinition = {
|
|
25582
|
+
...normalizedDefinition,
|
|
25583
|
+
merge: MergeStrategy[normalizedDefinition.merge],
|
|
25574
25584
|
};
|
|
25575
25585
|
}
|
|
25576
25586
|
|
|
25577
25587
|
// normalize the validate method in case there's a string
|
|
25578
|
-
if (typeof
|
|
25579
|
-
|
|
25580
|
-
...
|
|
25581
|
-
validate:
|
|
25582
|
-
ValidationStrategy[
|
|
25583
|
-
/** @type {string} */ (definitions[key].validate)
|
|
25584
|
-
],
|
|
25588
|
+
if (typeof normalizedDefinition.validate === "string") {
|
|
25589
|
+
normalizedDefinition = {
|
|
25590
|
+
...normalizedDefinition,
|
|
25591
|
+
validate: ValidationStrategy[normalizedDefinition.validate],
|
|
25585
25592
|
};
|
|
25586
25593
|
}
|
|
25587
25594
|
|
|
25588
|
-
this.#definitions.set(key,
|
|
25595
|
+
this.#definitions.set(key, normalizedDefinition);
|
|
25589
25596
|
|
|
25590
|
-
if (
|
|
25591
|
-
this.#requiredKeys.set(key,
|
|
25597
|
+
if (normalizedDefinition.required) {
|
|
25598
|
+
this.#requiredKeys.set(key, normalizedDefinition);
|
|
25592
25599
|
}
|
|
25593
25600
|
}
|
|
25594
25601
|
}
|
|
@@ -35343,6 +35350,76 @@ function requireConfig () {
|
|
|
35343
35350
|
};
|
|
35344
35351
|
}
|
|
35345
35352
|
|
|
35353
|
+
/**
|
|
35354
|
+
* Normalizes a language name by replacing the built-in `@/` plugin prefix with `js/`.
|
|
35355
|
+
* @param {string} languageName The language name to normalize.
|
|
35356
|
+
* @returns {string} The normalized language name.
|
|
35357
|
+
*/
|
|
35358
|
+
function normalizeLanguageName(languageName) {
|
|
35359
|
+
return languageName.startsWith("@/")
|
|
35360
|
+
? `js/${languageName.slice(2)}`
|
|
35361
|
+
: languageName;
|
|
35362
|
+
}
|
|
35363
|
+
|
|
35364
|
+
/**
|
|
35365
|
+
* Checks if a rule's `meta.languages` supports the given language.
|
|
35366
|
+
* @param {Array<string>|undefined} ruleLangs The rule's `meta.languages` array.
|
|
35367
|
+
* @param {string} configLanguageName The normalized language name from the config (e.g., "js/js").
|
|
35368
|
+
* @param {Array<string>} validPluginNames The valid plugin name aliases for the config's plugin
|
|
35369
|
+
* (normalized plugin name plus its `meta.namespace` if defined).
|
|
35370
|
+
* @returns {boolean} True if the rule supports the language, false otherwise.
|
|
35371
|
+
*/
|
|
35372
|
+
function doesRuleSupportLanguage(
|
|
35373
|
+
ruleLangs,
|
|
35374
|
+
configLanguageName,
|
|
35375
|
+
validPluginNames,
|
|
35376
|
+
) {
|
|
35377
|
+
// If no languages specified, works with all languages (backward compatible)
|
|
35378
|
+
if (!ruleLangs) {
|
|
35379
|
+
return true;
|
|
35380
|
+
}
|
|
35381
|
+
|
|
35382
|
+
const { objectName: configLangPart } =
|
|
35383
|
+
splitPluginIdentifier(configLanguageName);
|
|
35384
|
+
|
|
35385
|
+
for (const langEntry of ruleLangs) {
|
|
35386
|
+
// Skip non-string entries
|
|
35387
|
+
if (typeof langEntry !== "string") {
|
|
35388
|
+
continue;
|
|
35389
|
+
}
|
|
35390
|
+
|
|
35391
|
+
// "*" matches any language
|
|
35392
|
+
if (langEntry === "*") {
|
|
35393
|
+
return true;
|
|
35394
|
+
}
|
|
35395
|
+
|
|
35396
|
+
// Direct match
|
|
35397
|
+
if (langEntry === configLanguageName) {
|
|
35398
|
+
return true;
|
|
35399
|
+
}
|
|
35400
|
+
|
|
35401
|
+
const { pluginName: rulePluginPart, objectName: ruleLangPart } =
|
|
35402
|
+
splitPluginIdentifier(langEntry);
|
|
35403
|
+
|
|
35404
|
+
// "plugin/*" wildcard - matches any language from that plugin (by name or namespace)
|
|
35405
|
+
if (ruleLangPart === "*") {
|
|
35406
|
+
if (validPluginNames.includes(rulePluginPart)) {
|
|
35407
|
+
return true;
|
|
35408
|
+
}
|
|
35409
|
+
} else {
|
|
35410
|
+
// Match by plugin name or namespace, with exact language part
|
|
35411
|
+
if (
|
|
35412
|
+
validPluginNames.includes(rulePluginPart) &&
|
|
35413
|
+
ruleLangPart === configLangPart
|
|
35414
|
+
) {
|
|
35415
|
+
return true;
|
|
35416
|
+
}
|
|
35417
|
+
}
|
|
35418
|
+
}
|
|
35419
|
+
|
|
35420
|
+
return false;
|
|
35421
|
+
}
|
|
35422
|
+
|
|
35346
35423
|
/**
|
|
35347
35424
|
* Returns the name of an object in the config by reading its `meta` key.
|
|
35348
35425
|
* @param {Object} object The object to check.
|
|
@@ -35687,12 +35764,30 @@ function requireConfig () {
|
|
|
35687
35764
|
* @throws {TypeError} If the rulesConfig is not provided or is invalid.
|
|
35688
35765
|
* @throws {InvalidRuleOptionsSchemaError} If a rule's `meta.schema` is invalid.
|
|
35689
35766
|
* @throws {TypeError} If a rule is not found in the plugins.
|
|
35767
|
+
* @throws {TypeError} If a rule does not support the current language.
|
|
35690
35768
|
*/
|
|
35691
35769
|
validateRulesConfig(rulesConfig) {
|
|
35692
35770
|
if (!rulesConfig) {
|
|
35693
35771
|
throw new TypeError("Config is required for validation.");
|
|
35694
35772
|
}
|
|
35695
35773
|
|
|
35774
|
+
// Normalize "@/" prefix to "js/" for matching and user-facing messages
|
|
35775
|
+
const normalizedLanguageName = normalizeLanguageName(
|
|
35776
|
+
this.#languageName,
|
|
35777
|
+
);
|
|
35778
|
+
|
|
35779
|
+
// Compute valid plugin name aliases for the config's language plugin once
|
|
35780
|
+
const { pluginName: configPluginName } = splitPluginIdentifier(
|
|
35781
|
+
normalizedLanguageName,
|
|
35782
|
+
);
|
|
35783
|
+
const configPlugin =
|
|
35784
|
+
this.plugins[configPluginName] ??
|
|
35785
|
+
(configPluginName === "js" ? this.plugins["@"] : void 0);
|
|
35786
|
+
const validPluginNames = configPlugin?.meta?.namespace
|
|
35787
|
+
? [configPluginName, configPlugin.meta.namespace]
|
|
35788
|
+
: [configPluginName];
|
|
35789
|
+
const unsupportedLanguageRules = [];
|
|
35790
|
+
|
|
35696
35791
|
for (const [ruleId, ruleOptions] of Object.entries(rulesConfig)) {
|
|
35697
35792
|
// check for edge case
|
|
35698
35793
|
if (ruleId === "__proto__") {
|
|
@@ -35718,6 +35813,34 @@ function requireConfig () {
|
|
|
35718
35813
|
throwRuleNotFoundError(parseRuleId(ruleId), this);
|
|
35719
35814
|
}
|
|
35720
35815
|
|
|
35816
|
+
// Validate meta.languages structure if present (only for enabled rules)
|
|
35817
|
+
if (rule.meta?.languages !== void 0) {
|
|
35818
|
+
if (!Array.isArray(rule.meta.languages)) {
|
|
35819
|
+
throw new TypeError(
|
|
35820
|
+
`Key "rules": Key "${ruleId}": Key "meta": Key "languages": Expected an array.`,
|
|
35821
|
+
);
|
|
35822
|
+
}
|
|
35823
|
+
|
|
35824
|
+
for (const lang of rule.meta.languages) {
|
|
35825
|
+
if (typeof lang !== "string") {
|
|
35826
|
+
throw new TypeError(
|
|
35827
|
+
`Key "rules": Key "${ruleId}": Key "meta": Key "languages": Expected each element to be a string.`,
|
|
35828
|
+
);
|
|
35829
|
+
}
|
|
35830
|
+
}
|
|
35831
|
+
}
|
|
35832
|
+
|
|
35833
|
+
// Check if the rule supports the current language
|
|
35834
|
+
if (
|
|
35835
|
+
!doesRuleSupportLanguage(
|
|
35836
|
+
rule.meta?.languages,
|
|
35837
|
+
normalizedLanguageName,
|
|
35838
|
+
validPluginNames,
|
|
35839
|
+
)
|
|
35840
|
+
) {
|
|
35841
|
+
unsupportedLanguageRules.push(ruleId);
|
|
35842
|
+
}
|
|
35843
|
+
|
|
35721
35844
|
const validateRule = getOrCreateValidator(rule, ruleId);
|
|
35722
35845
|
|
|
35723
35846
|
if (validateRule) {
|
|
@@ -35749,6 +35872,19 @@ function requireConfig () {
|
|
|
35749
35872
|
}
|
|
35750
35873
|
}
|
|
35751
35874
|
}
|
|
35875
|
+
|
|
35876
|
+
if (unsupportedLanguageRules.length > 0) {
|
|
35877
|
+
const error = new TypeError(
|
|
35878
|
+
`Key "rules": The following rules do not support the language "${normalizedLanguageName}":\n${unsupportedLanguageRules.map(ruleId => `\t- "${ruleId}"`).join("\n")}`,
|
|
35879
|
+
);
|
|
35880
|
+
|
|
35881
|
+
error.messageTemplate = "rule-unsupported-language";
|
|
35882
|
+
error.messageData = {
|
|
35883
|
+
ruleIds: unsupportedLanguageRules,
|
|
35884
|
+
language: normalizedLanguageName,
|
|
35885
|
+
};
|
|
35886
|
+
throw error;
|
|
35887
|
+
}
|
|
35752
35888
|
}
|
|
35753
35889
|
|
|
35754
35890
|
/**
|
|
@@ -92703,7 +92839,14 @@ function requireNoObjCalls () {
|
|
|
92703
92839
|
// Helpers
|
|
92704
92840
|
//------------------------------------------------------------------------------
|
|
92705
92841
|
|
|
92706
|
-
const nonCallableGlobals = [
|
|
92842
|
+
const nonCallableGlobals = [
|
|
92843
|
+
"Atomics",
|
|
92844
|
+
"JSON",
|
|
92845
|
+
"Math",
|
|
92846
|
+
"Reflect",
|
|
92847
|
+
"Intl",
|
|
92848
|
+
"Temporal",
|
|
92849
|
+
];
|
|
92707
92850
|
|
|
92708
92851
|
/**
|
|
92709
92852
|
* Returns the name of the node to report
|
|
@@ -101251,6 +101394,35 @@ function requireNoUnmodifiedLoopCondition () {
|
|
|
101251
101394
|
return null;
|
|
101252
101395
|
}
|
|
101253
101396
|
|
|
101397
|
+
/**
|
|
101398
|
+
* Checks whether a given modifier is in a loop.
|
|
101399
|
+
*
|
|
101400
|
+
* Besides checking for the condition being in the loop, this also checks
|
|
101401
|
+
* whether the function that this modifier is belonging to is called
|
|
101402
|
+
* in the loop.
|
|
101403
|
+
* @param {LoopConditionInfo} condition The condition to check.
|
|
101404
|
+
* @param {Reference} modifier The modifier to check.
|
|
101405
|
+
* @returns {boolean} `true` if the modifier is in a loop.
|
|
101406
|
+
*/
|
|
101407
|
+
function hasModifierInLoop(condition, modifier) {
|
|
101408
|
+
if (condition.isInLoop(modifier)) {
|
|
101409
|
+
return true;
|
|
101410
|
+
}
|
|
101411
|
+
|
|
101412
|
+
const funcNode = getEncloseFunctionDeclaration(modifier);
|
|
101413
|
+
|
|
101414
|
+
if (!funcNode) {
|
|
101415
|
+
return false;
|
|
101416
|
+
}
|
|
101417
|
+
|
|
101418
|
+
const funcVar = astUtils.getVariableByName(
|
|
101419
|
+
modifier.from.upper,
|
|
101420
|
+
funcNode.id.name,
|
|
101421
|
+
);
|
|
101422
|
+
|
|
101423
|
+
return Boolean(funcVar && funcVar.references.some(condition.isInLoop));
|
|
101424
|
+
}
|
|
101425
|
+
|
|
101254
101426
|
/**
|
|
101255
101427
|
* Updates the "modified" flags of given loop conditions with given modifiers.
|
|
101256
101428
|
* @param {LoopConditionInfo[]} conditions The loop conditions to be updated.
|
|
@@ -101263,26 +101435,8 @@ function requireNoUnmodifiedLoopCondition () {
|
|
|
101263
101435
|
|
|
101264
101436
|
for (let j = 0; !condition.modified && j < modifiers.length; ++j) {
|
|
101265
101437
|
const modifier = modifiers[j];
|
|
101266
|
-
let funcNode, funcVar;
|
|
101267
101438
|
|
|
101268
|
-
|
|
101269
|
-
* Besides checking for the condition being in the loop, we want to
|
|
101270
|
-
* check the function that this modifier is belonging to is called
|
|
101271
|
-
* in the loop.
|
|
101272
|
-
* FIXME: This should probably be extracted to a function.
|
|
101273
|
-
*/
|
|
101274
|
-
const inLoop =
|
|
101275
|
-
condition.isInLoop(modifier) ||
|
|
101276
|
-
Boolean(
|
|
101277
|
-
(funcNode = getEncloseFunctionDeclaration(modifier)) &&
|
|
101278
|
-
(funcVar = astUtils.getVariableByName(
|
|
101279
|
-
modifier.from.upper,
|
|
101280
|
-
funcNode.id.name,
|
|
101281
|
-
)) &&
|
|
101282
|
-
funcVar.references.some(condition.isInLoop),
|
|
101283
|
-
);
|
|
101284
|
-
|
|
101285
|
-
condition.modified = inLoop;
|
|
101439
|
+
condition.modified = hasModifierInLoop(condition, modifier);
|
|
101286
101440
|
}
|
|
101287
101441
|
}
|
|
101288
101442
|
}
|
|
@@ -131044,6 +131198,22 @@ function requireLinter () {
|
|
|
131044
131198
|
throw err;
|
|
131045
131199
|
}
|
|
131046
131200
|
|
|
131201
|
+
/*
|
|
131202
|
+
* If the rule does not support the current language, report a
|
|
131203
|
+
* specific, actionable error message.
|
|
131204
|
+
*/
|
|
131205
|
+
if (
|
|
131206
|
+
err.messageTemplate ===
|
|
131207
|
+
"rule-unsupported-language"
|
|
131208
|
+
) {
|
|
131209
|
+
report.addError({
|
|
131210
|
+
ruleId,
|
|
131211
|
+
message: `Inline configuration for rule "${ruleId}" is invalid:\n\tRule does not support the language "${err.messageData.language}". Use a config block with "files" to apply the rule only to supported files, or disable it.\n`,
|
|
131212
|
+
loc,
|
|
131213
|
+
});
|
|
131214
|
+
return;
|
|
131215
|
+
}
|
|
131216
|
+
|
|
131047
131217
|
let baseMessage = err.message
|
|
131048
131218
|
.slice(
|
|
131049
131219
|
err.message.startsWith('Key "rules":')
|