eslint 8.5.0 → 8.6.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/linter/apply-disable-directives.js +20 -16
- package/lib/linter/linter.js +8 -6
- package/lib/rules/id-match.js +11 -0
- package/lib/rules/no-self-assign.js +1 -1
- package/package.json +3 -2
package/README.md
CHANGED
@@ -294,7 +294,7 @@ The following companies, organizations, and individuals support ESLint's ongoing
|
|
294
294
|
<p><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>
|
295
295
|
<p><a href="https://contra.com"><img src="https://images.opencollective.com/contra1/c70f93f/logo.png" alt="Contra" height="96"></a> <a href="https://nx.dev"><img src="https://images.opencollective.com/nx/0efbe42/logo.png" alt="Nx (by Nrwl)" height="96"></a> <a href="https://google.com/chrome"><img src="https://images.opencollective.com/chrome/dc55bd4/logo.png" alt="Chrome's Web Framework & Tools Performance Fund" height="96"></a> <a href="https://www.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> <a href="https://coinbase.com"><img src="https://avatars.githubusercontent.com/u/1885080?v=4" alt="Coinbase" height="96"></a> <a href="https://americanexpress.io"><img src="https://avatars.githubusercontent.com/u/3853301?v=4" alt="American Express" height="96"></a> <a href="https://substack.com/"><img src="https://avatars.githubusercontent.com/u/53023767?v=4" alt="Substack" height="96"></a></p><h3>Silver Sponsors</h3>
|
296
296
|
<p><a href="https://liftoff.io/"><img src="https://images.opencollective.com/liftoff/5c4fa84/logo.png" alt="Liftoff" height="64"></a></p><h3>Bronze Sponsors</h3>
|
297
|
-
<p><a href="https://
|
297
|
+
<p><a href="https://launchdarkly.com"><img src="https://images.opencollective.com/launchdarkly/574bb9e/logo.png" alt="launchdarkly" 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://www.vpsserver.com"><img src="https://images.opencollective.com/vpsservercom/logo.png" alt="VPS Server" 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://themeisle.com"><img src="https://images.opencollective.com/themeisle/d5592fe/logo.png" alt="ThemeIsle" height="32"></a> <a href="https://www.firesticktricks.com"><img src="https://images.opencollective.com/fire-stick-tricks/b8fbe2c/logo.png" alt="Fire Stick Tricks" height="32"></a> <a href="https://www.practiceignition.com"><img src="https://avatars.githubusercontent.com/u/5753491?v=4" alt="Practice Ignition" height="32"></a></p>
|
298
298
|
<!--sponsorsend-->
|
299
299
|
|
300
300
|
## <a name="technology-sponsors"></a>Technology Sponsors
|
@@ -43,7 +43,7 @@ function groupByParentComment(directives) {
|
|
43
43
|
* Creates removal details for a set of directives within the same comment.
|
44
44
|
* @param {Directive[]} directives Unused directives to be removed.
|
45
45
|
* @param {Token} commentToken The backing Comment token.
|
46
|
-
* @returns {{ description, fix,
|
46
|
+
* @returns {{ description, fix, unprocessedDirective }[]} Details for later creation of output Problems.
|
47
47
|
*/
|
48
48
|
function createIndividualDirectivesRemoval(directives, commentToken) {
|
49
49
|
|
@@ -138,7 +138,7 @@ function createIndividualDirectivesRemoval(directives, commentToken) {
|
|
138
138
|
],
|
139
139
|
text: ""
|
140
140
|
},
|
141
|
-
|
141
|
+
unprocessedDirective: directive.unprocessedDirective
|
142
142
|
};
|
143
143
|
});
|
144
144
|
}
|
@@ -147,7 +147,7 @@ function createIndividualDirectivesRemoval(directives, commentToken) {
|
|
147
147
|
* Creates a description of deleting an entire unused disable comment.
|
148
148
|
* @param {Directive[]} directives Unused directives to be removed.
|
149
149
|
* @param {Token} commentToken The backing Comment token.
|
150
|
-
* @returns {{ description, fix,
|
150
|
+
* @returns {{ description, fix, unprocessedDirective }} Details for later creation of an output Problem.
|
151
151
|
*/
|
152
152
|
function createCommentRemoval(directives, commentToken) {
|
153
153
|
const { range } = commentToken;
|
@@ -161,14 +161,14 @@ function createCommentRemoval(directives, commentToken) {
|
|
161
161
|
range,
|
162
162
|
text: " "
|
163
163
|
},
|
164
|
-
|
164
|
+
unprocessedDirective: directives[0].unprocessedDirective
|
165
165
|
};
|
166
166
|
}
|
167
167
|
|
168
168
|
/**
|
169
169
|
* Parses details from directives to create output Problems.
|
170
170
|
* @param {Directive[]} allDirectives Unused directives to be removed.
|
171
|
-
* @returns {{ description, fix,
|
171
|
+
* @returns {{ description, fix, unprocessedDirective }[]} Details for later creation of output Problems.
|
172
172
|
*/
|
173
173
|
function processUnusedDisableDirectives(allDirectives) {
|
174
174
|
const directiveGroups = groupByParentComment(allDirectives);
|
@@ -261,17 +261,21 @@ function applyDirectives(options) {
|
|
261
261
|
const processed = processUnusedDisableDirectives(unusedDisableDirectivesToReport);
|
262
262
|
|
263
263
|
const unusedDisableDirectives = processed
|
264
|
-
.map(({ description, fix,
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
:
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
264
|
+
.map(({ description, fix, unprocessedDirective }) => {
|
265
|
+
const { parentComment, type, line, column } = unprocessedDirective;
|
266
|
+
|
267
|
+
return {
|
268
|
+
ruleId: null,
|
269
|
+
message: description
|
270
|
+
? `Unused eslint-disable directive (no problems were reported from ${description}).`
|
271
|
+
: "Unused eslint-disable directive (no problems were reported).",
|
272
|
+
line: type === "disable-next-line" ? parentComment.commentToken.loc.start.line : line,
|
273
|
+
column: type === "disable-next-line" ? parentComment.commentToken.loc.start.column + 1 : column,
|
274
|
+
severity: options.reportUnusedDisableDirectives === "warn" ? 1 : 2,
|
275
|
+
nodeType: null,
|
276
|
+
...options.disableFixes ? {} : { fix }
|
277
|
+
};
|
278
|
+
});
|
275
279
|
|
276
280
|
return { problems, unusedDisableDirectives };
|
277
281
|
}
|
package/lib/linter/linter.js
CHANGED
@@ -305,7 +305,11 @@ function createDisableDirectives(options) {
|
|
305
305
|
|
306
306
|
// push to directives, if the rule is defined(including null, e.g. /*eslint enable*/)
|
307
307
|
if (ruleId === null || !!ruleMapper(ruleId)) {
|
308
|
-
|
308
|
+
if (type === "disable-next-line") {
|
309
|
+
result.directives.push({ parentComment, type, line: commentToken.loc.end.line, column: commentToken.loc.end.column + 1, ruleId });
|
310
|
+
} else {
|
311
|
+
result.directives.push({ parentComment, type, line: commentToken.loc.start.line, column: commentToken.loc.start.column + 1, ruleId });
|
312
|
+
}
|
309
313
|
} else {
|
310
314
|
result.directiveProblems.push(createLintingProblem({ ruleId, loc: commentToken.loc }));
|
311
315
|
}
|
@@ -326,14 +330,13 @@ function stripDirectiveComment(value) {
|
|
326
330
|
* Parses comments in file to extract file-specific config of rules, globals
|
327
331
|
* and environments and merges them with global config; also code blocks
|
328
332
|
* where reporting is disabled or enabled and merges them with reporting config.
|
329
|
-
* @param {string} filename The file being checked.
|
330
333
|
* @param {ASTNode} ast The top node of the AST.
|
331
334
|
* @param {function(string): {create: Function}} ruleMapper A map from rule IDs to defined rules
|
332
335
|
* @param {string|null} warnInlineConfig If a string then it should warn directive comments as disabled. The string value is the config name what the setting came from.
|
333
336
|
* @returns {{configuredRules: Object, enabledGlobals: {value:string,comment:Token}[], exportedVariables: Object, problems: Problem[], disableDirectives: DisableDirective[]}}
|
334
337
|
* A collection of the directive comments that were found, along with any problems that occurred when parsing
|
335
338
|
*/
|
336
|
-
function getDirectiveComments(
|
339
|
+
function getDirectiveComments(ast, ruleMapper, warnInlineConfig) {
|
337
340
|
const configuredRules = {};
|
338
341
|
const enabledGlobals = Object.create(null);
|
339
342
|
const exportedVariables = {};
|
@@ -369,7 +372,7 @@ function getDirectiveComments(filename, ast, ruleMapper, warnInlineConfig) {
|
|
369
372
|
return;
|
370
373
|
}
|
371
374
|
|
372
|
-
if (
|
375
|
+
if (directiveText === "eslint-disable-line" && comment.loc.start.line !== comment.loc.end.line) {
|
373
376
|
const message = `${directiveText} comment should not span multiple lines.`;
|
374
377
|
|
375
378
|
problems.push(createLintingProblem({
|
@@ -1332,7 +1335,7 @@ class Linter {
|
|
1332
1335
|
|
1333
1336
|
const sourceCode = slots.lastSourceCode;
|
1334
1337
|
const commentDirectives = options.allowInlineConfig
|
1335
|
-
? getDirectiveComments(
|
1338
|
+
? getDirectiveComments(sourceCode.ast, ruleId => getRule(slots, ruleId), options.warnInlineConfig)
|
1336
1339
|
: { configuredRules: {}, enabledGlobals: {}, exportedVariables: {}, problems: [], disableDirectives: [] };
|
1337
1340
|
|
1338
1341
|
// augment global scope with declared global variables
|
@@ -1593,7 +1596,6 @@ class Linter {
|
|
1593
1596
|
const sourceCode = slots.lastSourceCode;
|
1594
1597
|
const commentDirectives = options.allowInlineConfig
|
1595
1598
|
? getDirectiveComments(
|
1596
|
-
options.filename,
|
1597
1599
|
sourceCode.ast,
|
1598
1600
|
ruleId => getRuleFromConfig(ruleId, config),
|
1599
1601
|
options.warnInlineConfig
|
package/lib/rules/id-match.js
CHANGED
@@ -211,6 +211,17 @@ module.exports = {
|
|
211
211
|
}
|
212
212
|
}
|
213
213
|
|
214
|
+
// For https://github.com/eslint/eslint/issues/15123
|
215
|
+
} else if (
|
216
|
+
parent.type === "Property" &&
|
217
|
+
parent.parent.type === "ObjectExpression" &&
|
218
|
+
parent.key === node &&
|
219
|
+
!parent.computed
|
220
|
+
) {
|
221
|
+
if (checkProperties && isInvalid(name)) {
|
222
|
+
report(node);
|
223
|
+
}
|
224
|
+
|
214
225
|
/*
|
215
226
|
* Properties have their own rules, and
|
216
227
|
* AssignmentPattern nodes can be treated like Properties:
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.6.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -59,7 +59,7 @@
|
|
59
59
|
"eslint-scope": "^7.1.0",
|
60
60
|
"eslint-utils": "^3.0.0",
|
61
61
|
"eslint-visitor-keys": "^3.1.0",
|
62
|
-
"espree": "^9.
|
62
|
+
"espree": "^9.3.0",
|
63
63
|
"esquery": "^1.4.0",
|
64
64
|
"esutils": "^2.0.2",
|
65
65
|
"fast-deep-equal": "^3.1.3",
|
@@ -118,6 +118,7 @@
|
|
118
118
|
"load-perf": "^0.2.0",
|
119
119
|
"markdownlint": "^0.24.0",
|
120
120
|
"markdownlint-cli": "^0.30.0",
|
121
|
+
"marked": "^4.0.8",
|
121
122
|
"memfs": "^3.0.1",
|
122
123
|
"mocha": "^8.3.2",
|
123
124
|
"mocha-junit-reporter": "^2.0.0",
|