eslint 7.23.0 → 7.24.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/CHANGELOG.md +16 -0
- package/lib/rules/no-implicit-coercion.js +37 -0
- package/lib/rules/no-multi-assign.js +15 -2
- package/lib/rules/no-unused-vars.js +15 -10
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
v7.24.0 - April 9, 2021
|
2
|
+
|
3
|
+
* [`0c346c8`](https://github.com/eslint/eslint/commit/0c346c87fa83c6d1184fdafb9c0748c2e15a423d) Chore: ignore `pnpm-lock.yaml` (#14303) (Nitin Kumar)
|
4
|
+
* [`f06ecdf`](https://github.com/eslint/eslint/commit/f06ecdf78b6d6f366434d73a6acfe7041d575223) Update: Add disallowTemplateShorthand option in no-implicit-coercion (#13579) (Remco Haszing)
|
5
|
+
* [`71a80e3`](https://github.com/eslint/eslint/commit/71a80e38aab2dada01b808ed43d9b0e806d863c4) Docs: fix broken links in Node.js API docs toc (#14296) (u-sho (Shouhei Uechi))
|
6
|
+
* [`bd46dc4`](https://github.com/eslint/eslint/commit/bd46dc4647faa4c3bbb5f60d4c00616a64081398) Docs: Fix incorrect reference to "braces" in arrow-parens (#14300) (emclain)
|
7
|
+
* [`0d6235e`](https://github.com/eslint/eslint/commit/0d6235ea201b8b90761ee69bb4d46ae18899c28d) Docs: update header in max-lines (#14273) (Shinigami)
|
8
|
+
* [`70c9216`](https://github.com/eslint/eslint/commit/70c92164017238e329e3a2d1654a0227b8f953f7) Docs: Update issue triage to include blocked column (#14275) (Nicholas C. Zakas)
|
9
|
+
* [`abca186`](https://github.com/eslint/eslint/commit/abca186a845200fd7728c4e5f220973e640054f9) Docs: Fix typo in suggestions section (#14293) (Kevin Partington)
|
10
|
+
* [`c4d8b0d`](https://github.com/eslint/eslint/commit/c4d8b0db62b859e721105d4bc0f4044ce346995e) Fix: no-unused-vars ignoreRestSiblings check assignments (fixes #14163) (#14264) (YeonJuan)
|
11
|
+
* [`b51d077`](https://github.com/eslint/eslint/commit/b51d0778d76c2aa27578caca3ea82c867dced3e4) Update: add ignoreNonDeclaration to no-multi-assign rule (fixes #12545) (#14185) (t-mangoe)
|
12
|
+
* [`c981fb1`](https://github.com/eslint/eslint/commit/c981fb1994cd04914042ced1980aa86b68ba7be9) Chore: Upgrade mocha to 8.3.2 (#14278) (Stephen Wade)
|
13
|
+
* [`147fc04`](https://github.com/eslint/eslint/commit/147fc045e699811fab33dddf77498324ddf7e9d6) Docs: Fix `repro:needed` label in bug report template (#14285) (Milos Djermanovic)
|
14
|
+
* [`e1cfde9`](https://github.com/eslint/eslint/commit/e1cfde93eec71a15c2df1ad660a7a6171204ba80) Docs: Update bug report template (#14276) (Nicholas C. Zakas)
|
15
|
+
* [`c85c2f1`](https://github.com/eslint/eslint/commit/c85c2f1138a9e952655f19ee780ab0c8e35431a8) Docs: Add fatal to Node.js API LintMessage type (#14251) (Brandon Mills)
|
16
|
+
|
1
17
|
v7.23.0 - March 26, 2021
|
2
18
|
|
3
19
|
* [`687ccae`](https://github.com/eslint/eslint/commit/687ccae517b8b815cf21e948f80d22e2bf118a99) Update: add option "allowInParentheses" to no-sequences (fixes #14197) (#14199) (Daniel Rentz)
|
@@ -24,6 +24,7 @@ function parseOptions(options) {
|
|
24
24
|
boolean: "boolean" in options ? options.boolean : true,
|
25
25
|
number: "number" in options ? options.number : true,
|
26
26
|
string: "string" in options ? options.string : true,
|
27
|
+
disallowTemplateShorthand: "disallowTemplateShorthand" in options ? options.disallowTemplateShorthand : false,
|
27
28
|
allow: options.allow || []
|
28
29
|
};
|
29
30
|
}
|
@@ -180,6 +181,10 @@ module.exports = {
|
|
180
181
|
type: "boolean",
|
181
182
|
default: true
|
182
183
|
},
|
184
|
+
disallowTemplateShorthand: {
|
185
|
+
type: "boolean",
|
186
|
+
default: false
|
187
|
+
},
|
183
188
|
allow: {
|
184
189
|
type: "array",
|
185
190
|
items: {
|
@@ -299,6 +304,38 @@ module.exports = {
|
|
299
304
|
|
300
305
|
report(node, recommendation, true);
|
301
306
|
}
|
307
|
+
},
|
308
|
+
|
309
|
+
TemplateLiteral(node) {
|
310
|
+
if (!options.disallowTemplateShorthand) {
|
311
|
+
return;
|
312
|
+
}
|
313
|
+
|
314
|
+
// tag`${foo}`
|
315
|
+
if (node.parent.type === "TaggedTemplateExpression") {
|
316
|
+
return;
|
317
|
+
}
|
318
|
+
|
319
|
+
// `` or `${foo}${bar}`
|
320
|
+
if (node.expressions.length !== 1) {
|
321
|
+
return;
|
322
|
+
}
|
323
|
+
|
324
|
+
|
325
|
+
// `prefix${foo}`
|
326
|
+
if (node.quasis[0].value.cooked !== "") {
|
327
|
+
return;
|
328
|
+
}
|
329
|
+
|
330
|
+
// `${foo}postfix`
|
331
|
+
if (node.quasis[1].value.cooked !== "") {
|
332
|
+
return;
|
333
|
+
}
|
334
|
+
|
335
|
+
const code = sourceCode.getText(node.expressions[0]);
|
336
|
+
const recommendation = `String(${code})`;
|
337
|
+
|
338
|
+
report(node, recommendation, true);
|
302
339
|
}
|
303
340
|
};
|
304
341
|
}
|
@@ -21,7 +21,16 @@ module.exports = {
|
|
21
21
|
url: "https://eslint.org/docs/rules/no-multi-assign"
|
22
22
|
},
|
23
23
|
|
24
|
-
schema: [
|
24
|
+
schema: [{
|
25
|
+
type: "object",
|
26
|
+
properties: {
|
27
|
+
ignoreNonDeclaration: {
|
28
|
+
type: "boolean",
|
29
|
+
default: false
|
30
|
+
}
|
31
|
+
},
|
32
|
+
additionalProperties: false
|
33
|
+
}],
|
25
34
|
|
26
35
|
messages: {
|
27
36
|
unexpectedChain: "Unexpected chained assignment."
|
@@ -33,10 +42,14 @@ module.exports = {
|
|
33
42
|
//--------------------------------------------------------------------------
|
34
43
|
// Public
|
35
44
|
//--------------------------------------------------------------------------
|
45
|
+
const options = context.options[0] || {
|
46
|
+
ignoreNonDeclaration: false
|
47
|
+
};
|
48
|
+
const targetParent = options.ignoreNonDeclaration ? ["VariableDeclarator"] : ["AssignmentExpression", "VariableDeclarator"];
|
36
49
|
|
37
50
|
return {
|
38
51
|
AssignmentExpression(node) {
|
39
|
-
if (
|
52
|
+
if (targetParent.indexOf(node.parent.type) !== -1) {
|
40
53
|
context.report({
|
41
54
|
node,
|
42
55
|
messageId: "unexpectedChain"
|
@@ -196,6 +196,17 @@ module.exports = {
|
|
196
196
|
|
197
197
|
}
|
198
198
|
|
199
|
+
/**
|
200
|
+
* Checks whether a node is a sibling of the rest property or not.
|
201
|
+
* @param {ASTNode} node a node to check
|
202
|
+
* @returns {boolean} True if the node is a sibling of the rest property, otherwise false.
|
203
|
+
*/
|
204
|
+
function hasRestSibling(node) {
|
205
|
+
return node.type === "Property" &&
|
206
|
+
node.parent.type === "ObjectPattern" &&
|
207
|
+
REST_PROPERTY_TYPE.test(node.parent.properties[node.parent.properties.length - 1].type);
|
208
|
+
}
|
209
|
+
|
199
210
|
/**
|
200
211
|
* Determines if a variable has a sibling rest property
|
201
212
|
* @param {Variable} variable eslint-scope variable object.
|
@@ -204,16 +215,10 @@ module.exports = {
|
|
204
215
|
*/
|
205
216
|
function hasRestSpreadSibling(variable) {
|
206
217
|
if (config.ignoreRestSiblings) {
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
return (
|
212
|
-
propertyNode.type === "Property" &&
|
213
|
-
patternNode.type === "ObjectPattern" &&
|
214
|
-
REST_PROPERTY_TYPE.test(patternNode.properties[patternNode.properties.length - 1].type)
|
215
|
-
);
|
216
|
-
});
|
218
|
+
const hasRestSiblingDefinition = variable.defs.some(def => hasRestSibling(def.name.parent));
|
219
|
+
const hasRestSiblingReference = variable.references.some(ref => hasRestSibling(ref.identifier.parent));
|
220
|
+
|
221
|
+
return hasRestSiblingDefinition || hasRestSiblingReference;
|
217
222
|
}
|
218
223
|
|
219
224
|
return false;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.24.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -118,8 +118,8 @@
|
|
118
118
|
"markdownlint": "^0.19.0",
|
119
119
|
"markdownlint-cli": "^0.22.0",
|
120
120
|
"memfs": "^3.0.1",
|
121
|
-
"mocha": "^
|
122
|
-
"mocha-junit-reporter": "^
|
121
|
+
"mocha": "^8.3.2",
|
122
|
+
"mocha-junit-reporter": "^2.0.0",
|
123
123
|
"node-polyfill-webpack-plugin": "^1.0.3",
|
124
124
|
"npm-license": "^0.3.3",
|
125
125
|
"nyc": "^15.0.1",
|