eslint 8.41.0 → 8.42.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
CHANGED
@@ -284,7 +284,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
284
284
|
<p><a href="#"><img src="https://images.opencollective.com/2021-frameworks-fund/logo.png" alt="Chrome Frameworks Fund" height="undefined"></a> <a href="https://automattic.com"><img src="https://images.opencollective.com/automattic/d0ef3e1/logo.png" alt="Automattic" height="undefined"></a></p><h3>Gold Sponsors</h3>
|
285
285
|
<p><a href="https://engineering.salesforce.com"><img src="https://images.opencollective.com/salesforce/ca8f997/logo.png" alt="Salesforce" height="96"></a> <a href="https://www.airbnb.com/"><img src="https://images.opencollective.com/airbnb/d327d66/logo.png" alt="Airbnb" height="96"></a></p><h3>Silver Sponsors</h3>
|
286
286
|
<p><a href="https://sentry.io"><img src="https://avatars.githubusercontent.com/u/1396951?v=4" alt="Sentry" 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?v=4" alt="American Express" height="64"></a></p><h3>Bronze Sponsors</h3>
|
287
|
-
<p><a href="
|
287
|
+
<p><a href="#"><img src="https://images.opencollective.com/king-billy-slots1/c30c2aa/avatar.png" alt="King Billy Slots" height="32"></a> <a href="https://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" 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: free icons, photos, illustrations, and music" 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://transloadit.com/"><img src="https://avatars.githubusercontent.com/u/125754?v=4" alt="Transloadit" height="32"></a> <a href="https://www.ignitionapp.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Ignition" height="32"></a> <a href="https://herocoders.com"><img src="https://avatars.githubusercontent.com/u/37549774?v=4" alt="HeroCoders" height="32"></a> <a href="https://quickbookstoolhub.com"><img src="https://avatars.githubusercontent.com/u/95090305?u=e5bc398ef775c9ed19f955c675cdc1fb6abf01df&v=4" alt="QuickBooks Tool hub" height="32"></a></p>
|
288
288
|
<!--sponsorsend-->
|
289
289
|
|
290
290
|
## Technology Sponsors
|
@@ -591,7 +591,7 @@ function isErrorMessage(message) {
|
|
591
591
|
*/
|
592
592
|
function createIgnoreResult(filePath, baseDir) {
|
593
593
|
let message;
|
594
|
-
const isInNodeModules = baseDir && path.relative(baseDir, filePath).
|
594
|
+
const isInNodeModules = baseDir && path.dirname(path.relative(baseDir, filePath)).split(path.sep).includes("node_modules");
|
595
595
|
|
596
596
|
if (isInNodeModules) {
|
597
597
|
message = "File ignored by default because it is located under the node_modules directory. Use ignore pattern \"!**/node_modules/\" to override.";
|
@@ -109,7 +109,7 @@ module.exports = {
|
|
109
109
|
text += "final[label=\"\",shape=doublecircle,style=filled,fillcolor=black,width=0.25,height=0.25];\n";
|
110
110
|
}
|
111
111
|
if (codePath.thrownSegments.length > 0) {
|
112
|
-
text += "thrown[label=\"✘\",shape=circle,width=0.3,height=0.3,fixedsize];\n";
|
112
|
+
text += "thrown[label=\"✘\",shape=circle,width=0.3,height=0.3,fixedsize=true];\n";
|
113
113
|
}
|
114
114
|
|
115
115
|
const traceMap = Object.create(null);
|
@@ -100,12 +100,12 @@ module.exports = {
|
|
100
100
|
}
|
101
101
|
|
102
102
|
/**
|
103
|
-
* Checks
|
103
|
+
* Checks literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
|
104
104
|
* @param {ASTNode} node to check for matching errors.
|
105
105
|
* @returns {void}
|
106
106
|
* @private
|
107
107
|
*/
|
108
|
-
function
|
108
|
+
function removeInvalidNodeErrorsInLiteral(node) {
|
109
109
|
const shouldCheckStrings = skipStrings && (typeof node.value === "string");
|
110
110
|
const shouldCheckRegExps = skipRegExps && Boolean(node.regex);
|
111
111
|
|
@@ -237,8 +237,7 @@ module.exports = {
|
|
237
237
|
checkForIrregularLineTerminators(node);
|
238
238
|
};
|
239
239
|
|
240
|
-
nodes.
|
241
|
-
nodes.Literal = removeInvalidNodeErrorsInIdentifierOrLiteral;
|
240
|
+
nodes.Literal = removeInvalidNodeErrorsInLiteral;
|
242
241
|
nodes.TemplateElement = skipTemplates ? removeInvalidNodeErrorsInTemplateLiteral : noop;
|
243
242
|
nodes["Program:exit"] = function() {
|
244
243
|
if (skipComments) {
|
@@ -82,7 +82,6 @@ module.exports = {
|
|
82
82
|
|
83
83
|
create(context) {
|
84
84
|
const segmentInfoMap = new WeakMap();
|
85
|
-
const usedUnreachableSegments = new WeakSet();
|
86
85
|
const sourceCode = context.sourceCode;
|
87
86
|
let scopeInfo = null;
|
88
87
|
|
@@ -152,24 +151,44 @@ module.exports = {
|
|
152
151
|
* This behavior would simulate code paths for the case that the return
|
153
152
|
* statement does not exist.
|
154
153
|
* @param {CodePathSegment} segment The segment to get return statements.
|
154
|
+
* @param {Set<CodePathSegment>} usedUnreachableSegments A set of segments that have already been traversed in this call.
|
155
155
|
* @returns {void}
|
156
156
|
*/
|
157
|
-
function markReturnStatementsOnSegmentAsUsed(segment) {
|
157
|
+
function markReturnStatementsOnSegmentAsUsed(segment, usedUnreachableSegments) {
|
158
158
|
if (!segment.reachable) {
|
159
159
|
usedUnreachableSegments.add(segment);
|
160
160
|
segment.allPrevSegments
|
161
161
|
.filter(isReturned)
|
162
162
|
.filter(prevSegment => !usedUnreachableSegments.has(prevSegment))
|
163
|
-
.forEach(markReturnStatementsOnSegmentAsUsed);
|
163
|
+
.forEach(prevSegment => markReturnStatementsOnSegmentAsUsed(prevSegment, usedUnreachableSegments));
|
164
164
|
return;
|
165
165
|
}
|
166
166
|
|
167
167
|
const info = segmentInfoMap.get(segment);
|
168
168
|
|
169
|
-
|
169
|
+
info.uselessReturns = info.uselessReturns.filter(node => {
|
170
|
+
if (scopeInfo.traversedTryBlockStatements && scopeInfo.traversedTryBlockStatements.length > 0) {
|
171
|
+
const returnInitialRange = node.range[0];
|
172
|
+
const returnFinalRange = node.range[1];
|
173
|
+
|
174
|
+
const areBlocksInRange = scopeInfo.traversedTryBlockStatements.some(tryBlockStatement => {
|
175
|
+
const blockInitialRange = tryBlockStatement.range[0];
|
176
|
+
const blockFinalRange = tryBlockStatement.range[1];
|
177
|
+
|
178
|
+
return (
|
179
|
+
returnInitialRange >= blockInitialRange &&
|
180
|
+
returnFinalRange <= blockFinalRange
|
181
|
+
);
|
182
|
+
});
|
183
|
+
|
184
|
+
if (areBlocksInRange) {
|
185
|
+
return true;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
|
170
189
|
remove(scopeInfo.uselessReturns, node);
|
171
|
-
|
172
|
-
|
190
|
+
return false;
|
191
|
+
});
|
173
192
|
}
|
174
193
|
|
175
194
|
/**
|
@@ -188,7 +207,7 @@ module.exports = {
|
|
188
207
|
scopeInfo
|
189
208
|
.codePath
|
190
209
|
.currentSegments
|
191
|
-
.forEach(markReturnStatementsOnSegmentAsUsed);
|
210
|
+
.forEach(segment => markReturnStatementsOnSegmentAsUsed(segment, new Set()));
|
192
211
|
}
|
193
212
|
|
194
213
|
//----------------------------------------------------------------------
|
@@ -202,6 +221,7 @@ module.exports = {
|
|
202
221
|
scopeInfo = {
|
203
222
|
upper: scopeInfo,
|
204
223
|
uselessReturns: [],
|
224
|
+
traversedTryBlockStatements: [],
|
205
225
|
codePath
|
206
226
|
};
|
207
227
|
},
|
@@ -275,6 +295,14 @@ module.exports = {
|
|
275
295
|
scopeInfo.uselessReturns.push(node);
|
276
296
|
},
|
277
297
|
|
298
|
+
"TryStatement > BlockStatement.block:exit"(node) {
|
299
|
+
scopeInfo.traversedTryBlockStatements.push(node);
|
300
|
+
},
|
301
|
+
|
302
|
+
"TryStatement:exit"() {
|
303
|
+
scopeInfo.traversedTryBlockStatements.pop();
|
304
|
+
},
|
305
|
+
|
278
306
|
/*
|
279
307
|
* Registers for all statement nodes except FunctionDeclaration, BlockStatement, BreakStatement.
|
280
308
|
* Removes return statements of the current segments from the useless return statement list.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.42.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -63,8 +63,8 @@
|
|
63
63
|
"@eslint-community/eslint-utils": "^4.2.0",
|
64
64
|
"@eslint-community/regexpp": "^4.4.0",
|
65
65
|
"@eslint/eslintrc": "^2.0.3",
|
66
|
-
"@eslint/js": "8.
|
67
|
-
"@humanwhocodes/config-array": "^0.11.
|
66
|
+
"@eslint/js": "8.42.0",
|
67
|
+
"@humanwhocodes/config-array": "^0.11.10",
|
68
68
|
"@humanwhocodes/module-importer": "^1.0.1",
|
69
69
|
"@nodelib/fs.walk": "^1.2.8",
|
70
70
|
"ajv": "^6.10.0",
|