eslint 9.30.1 → 9.31.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 +1 -1
- package/lib/eslint/eslint.js +8 -1
- package/lib/rule-tester/rule-tester.js +18 -19
- package/lib/rules/init-declarations.js +3 -1
- package/lib/rules/no-const-assign.js +13 -2
- package/lib/rules/no-loop-func.js +4 -2
- package/lib/rules/no-undef-init.js +11 -1
- package/lib/types/index.d.ts +1 -19
- package/lib/types/rules.d.ts +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
@@ -329,7 +329,7 @@ to get your logo on our READMEs and [website](https://eslint.org/sponsors).
|
|
329
329
|
<p><a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="128"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="128"></a></p><h3>Gold Sponsors</h3>
|
330
330
|
<p><a href="https://qlty.sh/"><img src="https://images.opencollective.com/qltysh/33d157d/logo.png" alt="Qlty Software" height="96"></a> <a href="https://trunk.io/"><img src="https://images.opencollective.com/trunkio/fb92d60/avatar.png" alt="trunk.io" height="96"></a> <a href="https://shopify.engineering/"><img src="https://avatars.githubusercontent.com/u/8085" alt="Shopify" height="96"></a></p><h3>Silver Sponsors</h3>
|
331
331
|
<p><a href="https://vite.dev/"><img src="https://images.opencollective.com/vite/e6d15e1/logo.png" alt="Vite" height="64"></a> <a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301" alt="American Express" height="64"></a> <a href="https://stackblitz.com"><img src="https://avatars.githubusercontent.com/u/28635252" alt="StackBlitz" height="64"></a></p><h3>Bronze Sponsors</h3>
|
332
|
-
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
|
332
|
+
<p><a href="https://cybozu.co.jp/"><img src="https://images.opencollective.com/cybozu/933e46d/logo.png" alt="Cybozu" height="32"></a> <a href="https://sentry.io"><img src="https://github.com/getsentry.png" alt="Sentry" height="32"></a> <a href="https://www.crosswordsolver.org/anagram-solver/"><img src="https://images.opencollective.com/anagram-solver/2666271/logo.png" alt="Anagram Solver" height="32"></a> <a href="https://icons8.com/"><img src="https://images.opencollective.com/icons8/7fa1641/logo.png" alt="Icons8" height="32"></a> <a href="https://discord.com"><img src="https://images.opencollective.com/discordapp/f9645d9/logo.png" alt="Discord" height="32"></a> <a href="https://www.gitbook.com"><img src="https://avatars.githubusercontent.com/u/7111340" alt="GitBook" height="32"></a> <a href="https://nx.dev"><img src="https://avatars.githubusercontent.com/u/23692104" alt="Nx" height="32"></a> <a href="https://opensource.mercedes-benz.com/"><img src="https://avatars.githubusercontent.com/u/34240465" alt="Mercedes-Benz Group" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774" alt="HeroCoders" height="32"></a> <a href="https://www.lambdatest.com"><img src="https://avatars.githubusercontent.com/u/171592363" alt="LambdaTest" height="32"></a></p>
|
333
333
|
<h3>Technology Sponsors</h3>
|
334
334
|
Technology sponsors allow us to use their products and services for free as part of a contribution to the open source ecosystem and our work.
|
335
335
|
<p><a href="https://netlify.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/netlify-icon.svg" alt="Netlify" height="32"></a> <a href="https://algolia.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/algolia-icon.svg" alt="Algolia" height="32"></a> <a href="https://1password.com"><img src="https://raw.githubusercontent.com/eslint/eslint.org/main/src/assets/images/techsponsors/1password-icon.svg" alt="1Password" height="32"></a></p>
|
package/lib/eslint/eslint.js
CHANGED
@@ -530,6 +530,11 @@ class ESLint {
|
|
530
530
|
throw new Error("'results' must be an array");
|
531
531
|
}
|
532
532
|
|
533
|
+
const retryCodes = new Set(["ENFILE", "EMFILE"]);
|
534
|
+
const retrier = new Retrier(error => retryCodes.has(error.code), {
|
535
|
+
concurrency: 100,
|
536
|
+
});
|
537
|
+
|
533
538
|
await Promise.all(
|
534
539
|
results
|
535
540
|
.filter(result => {
|
@@ -541,7 +546,9 @@ class ESLint {
|
|
541
546
|
path.isAbsolute(result.filePath)
|
542
547
|
);
|
543
548
|
})
|
544
|
-
.map(r =>
|
549
|
+
.map(r =>
|
550
|
+
retrier.retry(() => fs.writeFile(r.filePath, r.output)),
|
551
|
+
),
|
545
552
|
);
|
546
553
|
}
|
547
554
|
|
@@ -1236,35 +1236,34 @@ class RuleTester {
|
|
1236
1236
|
);
|
1237
1237
|
}
|
1238
1238
|
|
1239
|
+
const actualLocation = {};
|
1240
|
+
const expectedLocation = {};
|
1241
|
+
|
1239
1242
|
if (hasOwnProperty(error, "line")) {
|
1240
|
-
|
1241
|
-
|
1242
|
-
error.line,
|
1243
|
-
`Error line should be ${error.line}`,
|
1244
|
-
);
|
1243
|
+
actualLocation.line = message.line;
|
1244
|
+
expectedLocation.line = error.line;
|
1245
1245
|
}
|
1246
1246
|
|
1247
1247
|
if (hasOwnProperty(error, "column")) {
|
1248
|
-
|
1249
|
-
|
1250
|
-
error.column,
|
1251
|
-
`Error column should be ${error.column}`,
|
1252
|
-
);
|
1248
|
+
actualLocation.column = message.column;
|
1249
|
+
expectedLocation.column = error.column;
|
1253
1250
|
}
|
1254
1251
|
|
1255
1252
|
if (hasOwnProperty(error, "endLine")) {
|
1256
|
-
|
1257
|
-
|
1258
|
-
error.endLine,
|
1259
|
-
`Error endLine should be ${error.endLine}`,
|
1260
|
-
);
|
1253
|
+
actualLocation.endLine = message.endLine;
|
1254
|
+
expectedLocation.endLine = error.endLine;
|
1261
1255
|
}
|
1262
1256
|
|
1263
1257
|
if (hasOwnProperty(error, "endColumn")) {
|
1264
|
-
|
1265
|
-
|
1266
|
-
|
1267
|
-
|
1258
|
+
actualLocation.endColumn = message.endColumn;
|
1259
|
+
expectedLocation.endColumn = error.endColumn;
|
1260
|
+
}
|
1261
|
+
|
1262
|
+
if (Object.keys(expectedLocation).length > 0) {
|
1263
|
+
assert.deepStrictEqual(
|
1264
|
+
actualLocation,
|
1265
|
+
expectedLocation,
|
1266
|
+
"Actual error location does not match expected error location.",
|
1268
1267
|
);
|
1269
1268
|
}
|
1270
1269
|
|
@@ -9,6 +9,8 @@
|
|
9
9
|
// Helpers
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
+
const CONSTANT_BINDINGS = new Set(["const", "using", "await using"]);
|
13
|
+
|
12
14
|
/**
|
13
15
|
* Checks whether or not a given node is a for loop.
|
14
16
|
* @param {ASTNode} block A node to check.
|
@@ -147,7 +149,7 @@ module.exports = {
|
|
147
149
|
messageId = "initialized";
|
148
150
|
} else if (
|
149
151
|
mode === MODE_NEVER &&
|
150
|
-
kind
|
152
|
+
!CONSTANT_BINDINGS.has(kind) &&
|
151
153
|
initialized &&
|
152
154
|
!isIgnoredForLoop
|
153
155
|
) {
|
@@ -5,8 +5,18 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
//------------------------------------------------------------------------------
|
9
|
+
// Requirements
|
10
|
+
//------------------------------------------------------------------------------
|
11
|
+
|
8
12
|
const astUtils = require("./utils/ast-utils");
|
9
13
|
|
14
|
+
//------------------------------------------------------------------------------
|
15
|
+
// Helpers
|
16
|
+
//------------------------------------------------------------------------------
|
17
|
+
|
18
|
+
const CONSTANT_BINDINGS = new Set(["const", "using", "await using"]);
|
19
|
+
|
10
20
|
//------------------------------------------------------------------------------
|
11
21
|
// Rule Definition
|
12
22
|
//------------------------------------------------------------------------------
|
@@ -17,7 +27,8 @@ module.exports = {
|
|
17
27
|
type: "problem",
|
18
28
|
|
19
29
|
docs: {
|
20
|
-
description:
|
30
|
+
description:
|
31
|
+
"Disallow reassigning `const`, `using`, and `await using` variables",
|
21
32
|
recommended: true,
|
22
33
|
url: "https://eslint.org/docs/latest/rules/no-const-assign",
|
23
34
|
},
|
@@ -51,7 +62,7 @@ module.exports = {
|
|
51
62
|
|
52
63
|
return {
|
53
64
|
VariableDeclaration(node) {
|
54
|
-
if (node.kind
|
65
|
+
if (CONSTANT_BINDINGS.has(node.kind)) {
|
55
66
|
sourceCode
|
56
67
|
.getDeclaredVariables(node)
|
57
68
|
.forEach(checkVariable);
|
@@ -9,6 +9,8 @@
|
|
9
9
|
// Helpers
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
+
const CONSTANT_BINDINGS = new Set(["const", "using", "await using"]);
|
13
|
+
|
12
14
|
/**
|
13
15
|
* Identifies is a node is a FunctionExpression which is part of an IIFE
|
14
16
|
* @param {ASTNode} node Node to test
|
@@ -148,8 +150,8 @@ module.exports = {
|
|
148
150
|
? declaration.kind
|
149
151
|
: "";
|
150
152
|
|
151
|
-
//
|
152
|
-
if (kind
|
153
|
+
// Constant variables are safe.
|
154
|
+
if (CONSTANT_BINDINGS.has(kind)) {
|
153
155
|
return true;
|
154
156
|
}
|
155
157
|
|
@@ -5,8 +5,18 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
//------------------------------------------------------------------------------
|
9
|
+
// Requirements
|
10
|
+
//------------------------------------------------------------------------------
|
11
|
+
|
8
12
|
const astUtils = require("./utils/ast-utils");
|
9
13
|
|
14
|
+
//------------------------------------------------------------------------------
|
15
|
+
// Helpers
|
16
|
+
//------------------------------------------------------------------------------
|
17
|
+
|
18
|
+
const CONSTANT_BINDINGS = new Set(["const", "using", "await using"]);
|
19
|
+
|
10
20
|
//------------------------------------------------------------------------------
|
11
21
|
// Rule Definition
|
12
22
|
//------------------------------------------------------------------------------
|
@@ -49,7 +59,7 @@ module.exports = {
|
|
49
59
|
|
50
60
|
if (
|
51
61
|
init === "undefined" &&
|
52
|
-
node.parent.kind
|
62
|
+
!CONSTANT_BINDINGS.has(node.parent.kind) &&
|
53
63
|
!shadowed
|
54
64
|
) {
|
55
65
|
context.report({
|
package/lib/types/index.d.ts
CHANGED
@@ -1186,25 +1186,7 @@ export namespace Rule {
|
|
1186
1186
|
RuleOptions: any[];
|
1187
1187
|
Node: JSSyntaxElement;
|
1188
1188
|
MessageIds: string;
|
1189
|
-
}> {
|
1190
|
-
/*
|
1191
|
-
* Need to extend the `RuleContext` interface to include the
|
1192
|
-
* deprecated methods that have not yet been removed.
|
1193
|
-
* TODO: Remove in v10.0.0.
|
1194
|
-
*/
|
1195
|
-
|
1196
|
-
/** @deprecated Use `sourceCode.getAncestors()` instead */
|
1197
|
-
getAncestors(): ESTree.Node[];
|
1198
|
-
|
1199
|
-
/** @deprecated Use `sourceCode.getDeclaredVariables()` instead */
|
1200
|
-
getDeclaredVariables(node: ESTree.Node): Scope.Variable[];
|
1201
|
-
|
1202
|
-
/** @deprecated Use `sourceCode.getScope()` instead */
|
1203
|
-
getScope(): Scope.Scope;
|
1204
|
-
|
1205
|
-
/** @deprecated Use `sourceCode.markVariableAsUsed()` instead */
|
1206
|
-
markVariableAsUsed(name: string): boolean;
|
1207
|
-
}
|
1189
|
+
}> {}
|
1208
1190
|
|
1209
1191
|
type ReportFixer = (
|
1210
1192
|
fixer: RuleFixer,
|
package/lib/types/rules.d.ts
CHANGED
@@ -2126,7 +2126,7 @@ export interface ESLintRules extends Linter.RulesRecord {
|
|
2126
2126
|
>;
|
2127
2127
|
|
2128
2128
|
/**
|
2129
|
-
* Rule to disallow reassigning `const` variables.
|
2129
|
+
* Rule to disallow reassigning `const`, `using`, and `await using` variables.
|
2130
2130
|
*
|
2131
2131
|
* @remarks
|
2132
2132
|
* Recommended by ESLint, the rule was enabled in `eslint:recommended`.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "9.
|
3
|
+
"version": "9.31.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"type": "commonjs",
|
@@ -108,9 +108,9 @@
|
|
108
108
|
"@eslint-community/regexpp": "^4.12.1",
|
109
109
|
"@eslint/config-array": "^0.21.0",
|
110
110
|
"@eslint/config-helpers": "^0.3.0",
|
111
|
-
"@eslint/core": "^0.
|
111
|
+
"@eslint/core": "^0.15.0",
|
112
112
|
"@eslint/eslintrc": "^3.3.1",
|
113
|
-
"@eslint/js": "9.
|
113
|
+
"@eslint/js": "9.31.0",
|
114
114
|
"@eslint/plugin-kit": "^0.3.1",
|
115
115
|
"@humanfs/node": "^0.16.6",
|
116
116
|
"@humanwhocodes/module-importer": "^1.0.1",
|
@@ -145,7 +145,7 @@
|
|
145
145
|
"@babel/core": "^7.4.3",
|
146
146
|
"@babel/preset-env": "^7.4.3",
|
147
147
|
"@cypress/webpack-preprocessor": "^6.0.2",
|
148
|
-
"@eslint/json": "^0.
|
148
|
+
"@eslint/json": "^0.13.0",
|
149
149
|
"@trunkio/launcher": "^1.3.4",
|
150
150
|
"@types/esquery": "^1.5.4",
|
151
151
|
"@types/node": "^22.13.14",
|
@@ -188,7 +188,7 @@
|
|
188
188
|
"metascraper-logo": "^5.25.7",
|
189
189
|
"metascraper-logo-favicon": "^5.25.7",
|
190
190
|
"metascraper-title": "^5.25.7",
|
191
|
-
"mocha": "^
|
191
|
+
"mocha": "^11.7.1",
|
192
192
|
"node-polyfill-webpack-plugin": "^1.0.3",
|
193
193
|
"npm-license": "^0.3.3",
|
194
194
|
"pirates": "^4.0.5",
|