eslint 7.0.0-alpha.3 → 7.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/CHANGELOG.md +303 -0
- package/README.md +10 -11
- package/bin/eslint.js +115 -77
- package/conf/category-list.json +0 -1
- package/lib/api.js +2 -0
- package/lib/cli-engine/cascading-config-array-factory.js +12 -0
- package/lib/cli-engine/cli-engine.js +53 -48
- package/lib/cli-engine/config-array/config-array.js +1 -1
- package/lib/cli-engine/config-array/ignore-pattern.js +7 -1
- package/lib/cli-engine/config-array-factory.js +3 -3
- package/lib/cli.js +181 -95
- package/lib/eslint/eslint.js +656 -0
- package/lib/eslint/index.js +7 -0
- package/lib/init/autoconfig.js +4 -4
- package/lib/init/config-initializer.js +5 -10
- package/lib/init/source-code-utils.js +2 -2
- package/lib/linter/code-path-analysis/code-path-analyzer.js +2 -2
- package/lib/linter/code-path-analysis/code-path-state.js +34 -12
- package/lib/linter/config-comment-parser.js +1 -1
- package/lib/linter/linter.js +2 -1
- package/lib/options.js +0 -1
- package/lib/rule-tester/rule-tester.js +6 -1
- package/lib/rules/accessor-pairs.js +1 -1
- package/lib/rules/array-callback-return.js +3 -18
- package/lib/rules/arrow-parens.js +19 -3
- package/lib/rules/block-spacing.js +19 -2
- package/lib/rules/callback-return.js +4 -0
- package/lib/rules/comma-style.js +3 -8
- package/lib/rules/func-call-spacing.js +22 -6
- package/lib/rules/getter-return.js +2 -12
- package/lib/rules/global-require.js +4 -0
- package/lib/rules/handle-callback-err.js +4 -0
- package/lib/rules/index.js +1 -0
- package/lib/rules/key-spacing.js +1 -1
- package/lib/rules/keyword-spacing.js +9 -2
- package/lib/rules/linebreak-style.js +8 -2
- package/lib/rules/max-lines-per-function.js +1 -1
- package/lib/rules/multiline-ternary.js +44 -25
- package/lib/rules/new-cap.js +1 -1
- package/lib/rules/newline-per-chained-call.js +6 -3
- package/lib/rules/no-buffer-constructor.js +4 -0
- package/lib/rules/no-control-regex.js +1 -1
- package/lib/rules/no-empty-function.js +1 -1
- package/lib/rules/no-extra-boolean-cast.js +3 -0
- package/lib/rules/no-extra-parens.js +35 -3
- package/lib/rules/no-inner-declarations.js +31 -39
- package/lib/rules/no-invalid-regexp.js +1 -1
- package/lib/rules/no-lone-blocks.js +1 -1
- package/lib/rules/no-loss-of-precision.js +198 -0
- package/lib/rules/no-misleading-character-class.js +1 -1
- package/lib/rules/no-mixed-operators.js +3 -2
- package/lib/rules/no-mixed-requires.js +4 -0
- package/lib/rules/no-mixed-spaces-and-tabs.js +14 -6
- package/lib/rules/no-new-func.js +22 -19
- package/lib/rules/no-new-object.js +15 -3
- package/lib/rules/no-new-require.js +4 -0
- package/lib/rules/no-new-symbol.js +2 -1
- package/lib/rules/no-path-concat.js +4 -0
- package/lib/rules/no-process-env.js +4 -0
- package/lib/rules/no-process-exit.js +4 -0
- package/lib/rules/no-regex-spaces.js +1 -1
- package/lib/rules/no-restricted-exports.js +6 -0
- package/lib/rules/no-restricted-modules.js +4 -0
- package/lib/rules/no-sync.js +4 -0
- package/lib/rules/no-unexpected-multiline.js +22 -12
- package/lib/rules/no-unneeded-ternary.js +6 -4
- package/lib/rules/no-unused-expressions.js +1 -1
- package/lib/rules/no-unused-vars.js +3 -1
- package/lib/rules/no-useless-backreference.js +1 -1
- package/lib/rules/no-useless-concat.js +1 -1
- package/lib/rules/one-var-declaration-per-line.js +1 -1
- package/lib/rules/padded-blocks.js +17 -4
- package/lib/rules/prefer-named-capture-group.js +1 -1
- package/lib/rules/quote-props.js +2 -2
- package/lib/rules/rest-spread-spacing.js +3 -6
- package/lib/rules/semi-spacing.js +32 -8
- package/lib/rules/space-before-function-paren.js +5 -2
- package/lib/rules/template-tag-spacing.js +8 -2
- package/lib/rules/utils/ast-utils.js +106 -9
- package/lib/rules/yoda.js +101 -51
- package/lib/shared/relative-module-resolver.js +1 -0
- package/lib/shared/types.js +7 -0
- package/lib/source-code/source-code.js +1 -0
- package/messages/extend-config-missing.txt +1 -1
- package/messages/no-config-found.txt +1 -1
- package/messages/plugin-conflict.txt +1 -1
- package/messages/plugin-missing.txt +1 -1
- package/messages/whitespace-found.txt +1 -1
- package/package.json +27 -26
@@ -416,6 +416,53 @@ function equalTokens(left, right, sourceCode) {
|
|
416
416
|
return true;
|
417
417
|
}
|
418
418
|
|
419
|
+
/**
|
420
|
+
* Check if the given node is a true logical expression or not.
|
421
|
+
*
|
422
|
+
* The three binary expressions logical-or (`||`), logical-and (`&&`), and
|
423
|
+
* coalesce (`??`) are known as `ShortCircuitExpression`.
|
424
|
+
* But ESTree represents those by `LogicalExpression` node.
|
425
|
+
*
|
426
|
+
* This function rejects coalesce expressions of `LogicalExpression` node.
|
427
|
+
* @param {ASTNode} node The node to check.
|
428
|
+
* @returns {boolean} `true` if the node is `&&` or `||`.
|
429
|
+
* @see https://tc39.es/ecma262/#prod-ShortCircuitExpression
|
430
|
+
*/
|
431
|
+
function isLogicalExpression(node) {
|
432
|
+
return (
|
433
|
+
node.type === "LogicalExpression" &&
|
434
|
+
(node.operator === "&&" || node.operator === "||")
|
435
|
+
);
|
436
|
+
}
|
437
|
+
|
438
|
+
/**
|
439
|
+
* Check if the given node is a nullish coalescing expression or not.
|
440
|
+
*
|
441
|
+
* The three binary expressions logical-or (`||`), logical-and (`&&`), and
|
442
|
+
* coalesce (`??`) are known as `ShortCircuitExpression`.
|
443
|
+
* But ESTree represents those by `LogicalExpression` node.
|
444
|
+
*
|
445
|
+
* This function finds only coalesce expressions of `LogicalExpression` node.
|
446
|
+
* @param {ASTNode} node The node to check.
|
447
|
+
* @returns {boolean} `true` if the node is `??`.
|
448
|
+
*/
|
449
|
+
function isCoalesceExpression(node) {
|
450
|
+
return node.type === "LogicalExpression" && node.operator === "??";
|
451
|
+
}
|
452
|
+
|
453
|
+
/**
|
454
|
+
* Check if given two nodes are the pair of a logical expression and a coalesce expression.
|
455
|
+
* @param {ASTNode} left A node to check.
|
456
|
+
* @param {ASTNode} right Another node to check.
|
457
|
+
* @returns {boolean} `true` if the two nodes are the pair of a logical expression and a coalesce expression.
|
458
|
+
*/
|
459
|
+
function isMixedLogicalAndCoalesceExpressions(left, right) {
|
460
|
+
return (
|
461
|
+
(isLogicalExpression(left) && isCoalesceExpression(right)) ||
|
462
|
+
(isCoalesceExpression(left) && isLogicalExpression(right))
|
463
|
+
);
|
464
|
+
}
|
465
|
+
|
419
466
|
//------------------------------------------------------------------------------
|
420
467
|
// Public Interface
|
421
468
|
//------------------------------------------------------------------------------
|
@@ -779,6 +826,7 @@ module.exports = {
|
|
779
826
|
case "LogicalExpression":
|
780
827
|
switch (node.operator) {
|
781
828
|
case "||":
|
829
|
+
case "??":
|
782
830
|
return 4;
|
783
831
|
case "&&":
|
784
832
|
return 5;
|
@@ -1243,19 +1291,64 @@ module.exports = {
|
|
1243
1291
|
|
1244
1292
|
/**
|
1245
1293
|
* Gets next location when the result is not out of bound, otherwise returns null.
|
1294
|
+
*
|
1295
|
+
* Assumptions:
|
1296
|
+
*
|
1297
|
+
* - The given location represents a valid location in the given source code.
|
1298
|
+
* - Columns are 0-based.
|
1299
|
+
* - Lines are 1-based.
|
1300
|
+
* - Column immediately after the last character in a line (not incl. linebreaks) is considered to be a valid location.
|
1301
|
+
* - If the source code ends with a linebreak, `sourceCode.lines` array will have an extra element (empty string) at the end.
|
1302
|
+
* The start (column 0) of that extra line is considered to be a valid location.
|
1303
|
+
*
|
1304
|
+
* Examples of successive locations (line, column):
|
1305
|
+
*
|
1306
|
+
* code: foo
|
1307
|
+
* locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> null
|
1308
|
+
*
|
1309
|
+
* code: foo<LF>
|
1310
|
+
* locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
|
1311
|
+
*
|
1312
|
+
* code: foo<CR><LF>
|
1313
|
+
* locations: (1, 0) -> (1, 1) -> (1, 2) -> (1, 3) -> (2, 0) -> null
|
1314
|
+
*
|
1315
|
+
* code: a<LF>b
|
1316
|
+
* locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> null
|
1317
|
+
*
|
1318
|
+
* code: a<LF>b<LF>
|
1319
|
+
* locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
|
1320
|
+
*
|
1321
|
+
* code: a<CR><LF>b<CR><LF>
|
1322
|
+
* locations: (1, 0) -> (1, 1) -> (2, 0) -> (2, 1) -> (3, 0) -> null
|
1323
|
+
*
|
1324
|
+
* code: a<LF><LF>
|
1325
|
+
* locations: (1, 0) -> (1, 1) -> (2, 0) -> (3, 0) -> null
|
1326
|
+
*
|
1327
|
+
* code: <LF>
|
1328
|
+
* locations: (1, 0) -> (2, 0) -> null
|
1329
|
+
*
|
1330
|
+
* code:
|
1331
|
+
* locations: (1, 0) -> null
|
1246
1332
|
* @param {SourceCode} sourceCode The sourceCode
|
1247
1333
|
* @param {{line: number, column: number}} location The location
|
1248
1334
|
* @returns {{line: number, column: number} | null} Next location
|
1249
1335
|
*/
|
1250
|
-
getNextLocation(sourceCode,
|
1251
|
-
|
1336
|
+
getNextLocation(sourceCode, { line, column }) {
|
1337
|
+
if (column < sourceCode.lines[line - 1].length) {
|
1338
|
+
return {
|
1339
|
+
line,
|
1340
|
+
column: column + 1
|
1341
|
+
};
|
1342
|
+
}
|
1252
1343
|
|
1253
|
-
|
1254
|
-
|
1255
|
-
|
1344
|
+
if (line < sourceCode.lines.length) {
|
1345
|
+
return {
|
1346
|
+
line: line + 1,
|
1347
|
+
column: 0
|
1348
|
+
};
|
1256
1349
|
}
|
1257
1350
|
|
1258
|
-
return
|
1351
|
+
return null;
|
1259
1352
|
},
|
1260
1353
|
|
1261
1354
|
/**
|
@@ -1370,7 +1463,7 @@ module.exports = {
|
|
1370
1463
|
|
1371
1464
|
try {
|
1372
1465
|
tokens = espree.tokenize(leftValue, espreeOptions);
|
1373
|
-
} catch
|
1466
|
+
} catch {
|
1374
1467
|
return false;
|
1375
1468
|
}
|
1376
1469
|
|
@@ -1399,7 +1492,7 @@ module.exports = {
|
|
1399
1492
|
|
1400
1493
|
try {
|
1401
1494
|
tokens = espree.tokenize(rightValue, espreeOptions);
|
1402
|
-
} catch
|
1495
|
+
} catch {
|
1403
1496
|
return false;
|
1404
1497
|
}
|
1405
1498
|
|
@@ -1493,5 +1586,9 @@ module.exports = {
|
|
1493
1586
|
*/
|
1494
1587
|
hasOctalEscapeSequence(rawString) {
|
1495
1588
|
return OCTAL_ESCAPE_PATTERN.test(rawString);
|
1496
|
-
}
|
1589
|
+
},
|
1590
|
+
|
1591
|
+
isLogicalExpression,
|
1592
|
+
isCoalesceExpression,
|
1593
|
+
isMixedLogicalAndCoalesceExpressions
|
1497
1594
|
};
|
package/lib/rules/yoda.js
CHANGED
@@ -20,7 +20,7 @@ const astUtils = require("./utils/ast-utils");
|
|
20
20
|
* @returns {boolean} Whether or not it is a comparison operator.
|
21
21
|
*/
|
22
22
|
function isComparisonOperator(operator) {
|
23
|
-
return
|
23
|
+
return /^(==|===|!=|!==|<|>|<=|>=)$/u.test(operator);
|
24
24
|
}
|
25
25
|
|
26
26
|
/**
|
@@ -29,7 +29,7 @@ function isComparisonOperator(operator) {
|
|
29
29
|
* @returns {boolean} Whether or not it is an equality operator.
|
30
30
|
*/
|
31
31
|
function isEqualityOperator(operator) {
|
32
|
-
return
|
32
|
+
return /^(==|===)$/u.test(operator);
|
33
33
|
}
|
34
34
|
|
35
35
|
/**
|
@@ -50,10 +50,12 @@ function isRangeTestOperator(operator) {
|
|
50
50
|
* real literal and should be treated as such.
|
51
51
|
*/
|
52
52
|
function isNegativeNumericLiteral(node) {
|
53
|
-
return (
|
53
|
+
return (
|
54
|
+
node.type === "UnaryExpression" &&
|
54
55
|
node.operator === "-" &&
|
55
56
|
node.prefix &&
|
56
|
-
astUtils.isNumericLiteral(node.argument)
|
57
|
+
astUtils.isNumericLiteral(node.argument)
|
58
|
+
);
|
57
59
|
}
|
58
60
|
|
59
61
|
/**
|
@@ -71,25 +73,21 @@ function isStaticTemplateLiteral(node) {
|
|
71
73
|
* @returns {boolean} True if the node should be treated as a single Literal node.
|
72
74
|
*/
|
73
75
|
function looksLikeLiteral(node) {
|
74
|
-
return isNegativeNumericLiteral(node) ||
|
75
|
-
isStaticTemplateLiteral(node);
|
76
|
+
return isNegativeNumericLiteral(node) || isStaticTemplateLiteral(node);
|
76
77
|
}
|
77
78
|
|
78
79
|
/**
|
79
80
|
* Attempts to derive a Literal node from nodes that are treated like literals.
|
80
81
|
* @param {ASTNode} node Node to normalize.
|
81
|
-
* @param {number} [defaultValue] The default value to be returned if the node
|
82
|
-
* is not a Literal.
|
83
82
|
* @returns {ASTNode} One of the following options.
|
84
83
|
* 1. The original node if the node is already a Literal
|
85
84
|
* 2. A normalized Literal node with the negative number as the value if the
|
86
85
|
* node represents a negative number literal.
|
87
86
|
* 3. A normalized Literal node with the string as the value if the node is
|
88
87
|
* a Template Literal without expression.
|
89
|
-
* 4.
|
90
|
-
* 5. Otherwise `null`.
|
88
|
+
* 4. Otherwise `null`.
|
91
89
|
*/
|
92
|
-
function getNormalizedLiteral(node
|
90
|
+
function getNormalizedLiteral(node) {
|
93
91
|
if (node.type === "Literal") {
|
94
92
|
return node;
|
95
93
|
}
|
@@ -110,14 +108,6 @@ function getNormalizedLiteral(node, defaultValue) {
|
|
110
108
|
};
|
111
109
|
}
|
112
110
|
|
113
|
-
if (defaultValue) {
|
114
|
-
return {
|
115
|
-
type: "Literal",
|
116
|
-
value: defaultValue,
|
117
|
-
raw: String(defaultValue)
|
118
|
-
};
|
119
|
-
}
|
120
|
-
|
121
111
|
return null;
|
122
112
|
}
|
123
113
|
|
@@ -183,7 +173,7 @@ module.exports = {
|
|
183
173
|
type: "suggestion",
|
184
174
|
|
185
175
|
docs: {
|
186
|
-
description:
|
176
|
+
description: 'require or disallow "Yoda" conditions',
|
187
177
|
category: "Best Practices",
|
188
178
|
recommended: false,
|
189
179
|
url: "https://eslint.org/docs/rules/yoda"
|
@@ -211,16 +201,19 @@ module.exports = {
|
|
211
201
|
|
212
202
|
fixable: "code",
|
213
203
|
messages: {
|
214
|
-
expected:
|
204
|
+
expected:
|
205
|
+
"Expected literal to be on the {{expectedSide}} side of {{operator}}."
|
215
206
|
}
|
216
207
|
},
|
217
208
|
|
218
209
|
create(context) {
|
219
210
|
|
220
211
|
// Default to "never" (!always) if no option
|
221
|
-
const always =
|
222
|
-
const exceptRange =
|
223
|
-
|
212
|
+
const always = context.options[0] === "always";
|
213
|
+
const exceptRange =
|
214
|
+
context.options[1] && context.options[1].exceptRange;
|
215
|
+
const onlyEquality =
|
216
|
+
context.options[1] && context.options[1].onlyEquality;
|
224
217
|
|
225
218
|
const sourceCode = context.getSourceCode();
|
226
219
|
|
@@ -243,13 +236,23 @@ module.exports = {
|
|
243
236
|
* @returns {boolean} Whether node is a "between" range test.
|
244
237
|
*/
|
245
238
|
function isBetweenTest() {
|
246
|
-
|
239
|
+
if (node.operator === "&&" && same(left.right, right.left)) {
|
240
|
+
const leftLiteral = getNormalizedLiteral(left.left);
|
241
|
+
const rightLiteral = getNormalizedLiteral(right.right);
|
242
|
+
|
243
|
+
if (leftLiteral === null && rightLiteral === null) {
|
244
|
+
return false;
|
245
|
+
}
|
247
246
|
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
247
|
+
if (rightLiteral === null || leftLiteral === null) {
|
248
|
+
return true;
|
249
|
+
}
|
250
|
+
|
251
|
+
if (leftLiteral.value <= rightLiteral.value) {
|
252
|
+
return true;
|
253
|
+
}
|
254
|
+
}
|
255
|
+
return false;
|
253
256
|
}
|
254
257
|
|
255
258
|
/**
|
@@ -257,13 +260,24 @@ module.exports = {
|
|
257
260
|
* @returns {boolean} Whether node is an "outside" range test.
|
258
261
|
*/
|
259
262
|
function isOutsideTest() {
|
260
|
-
|
263
|
+
if (node.operator === "||" && same(left.left, right.right)) {
|
264
|
+
const leftLiteral = getNormalizedLiteral(left.right);
|
265
|
+
const rightLiteral = getNormalizedLiteral(right.left);
|
266
|
+
|
267
|
+
if (leftLiteral === null && rightLiteral === null) {
|
268
|
+
return false;
|
269
|
+
}
|
270
|
+
|
271
|
+
if (rightLiteral === null || leftLiteral === null) {
|
272
|
+
return true;
|
273
|
+
}
|
274
|
+
|
275
|
+
if (leftLiteral.value <= rightLiteral.value) {
|
276
|
+
return true;
|
277
|
+
}
|
278
|
+
}
|
261
279
|
|
262
|
-
return
|
263
|
-
(leftLiteral = getNormalizedLiteral(left.right, Number.NEGATIVE_INFINITY)) &&
|
264
|
-
(rightLiteral = getNormalizedLiteral(right.left)) &&
|
265
|
-
leftLiteral.value <= rightLiteral.value &&
|
266
|
-
same(left.left, right.right));
|
280
|
+
return false;
|
267
281
|
}
|
268
282
|
|
269
283
|
/**
|
@@ -276,13 +290,15 @@ module.exports = {
|
|
276
290
|
return astUtils.isParenthesised(sourceCode, node);
|
277
291
|
}
|
278
292
|
|
279
|
-
return (
|
293
|
+
return (
|
294
|
+
node.type === "LogicalExpression" &&
|
280
295
|
left.type === "BinaryExpression" &&
|
281
296
|
right.type === "BinaryExpression" &&
|
282
297
|
isRangeTestOperator(left.operator) &&
|
283
298
|
isRangeTestOperator(right.operator) &&
|
284
299
|
(isBetweenTest() || isOutsideTest()) &&
|
285
|
-
isParenWrapped()
|
300
|
+
isParenWrapped()
|
301
|
+
);
|
286
302
|
}
|
287
303
|
|
288
304
|
const OPERATOR_FLIP_MAP = {
|
@@ -303,21 +319,52 @@ module.exports = {
|
|
303
319
|
*/
|
304
320
|
function getFlippedString(node) {
|
305
321
|
const tokenBefore = sourceCode.getTokenBefore(node);
|
306
|
-
const operatorToken = sourceCode.getFirstTokenBetween(
|
307
|
-
|
308
|
-
|
309
|
-
|
322
|
+
const operatorToken = sourceCode.getFirstTokenBetween(
|
323
|
+
node.left,
|
324
|
+
node.right,
|
325
|
+
token => token.value === node.operator
|
326
|
+
);
|
327
|
+
const textBeforeOperator = sourceCode
|
328
|
+
.getText()
|
329
|
+
.slice(
|
330
|
+
sourceCode.getTokenBefore(operatorToken).range[1],
|
331
|
+
operatorToken.range[0]
|
332
|
+
);
|
333
|
+
const textAfterOperator = sourceCode
|
334
|
+
.getText()
|
335
|
+
.slice(
|
336
|
+
operatorToken.range[1],
|
337
|
+
sourceCode.getTokenAfter(operatorToken).range[0]
|
338
|
+
);
|
339
|
+
const leftText = sourceCode
|
340
|
+
.getText()
|
341
|
+
.slice(
|
342
|
+
node.range[0],
|
343
|
+
sourceCode.getTokenBefore(operatorToken).range[1]
|
344
|
+
);
|
310
345
|
const firstRightToken = sourceCode.getTokenAfter(operatorToken);
|
311
|
-
const rightText = sourceCode
|
346
|
+
const rightText = sourceCode
|
347
|
+
.getText()
|
348
|
+
.slice(firstRightToken.range[0], node.range[1]);
|
312
349
|
|
313
350
|
let prefix = "";
|
314
351
|
|
315
|
-
if (
|
316
|
-
|
352
|
+
if (
|
353
|
+
tokenBefore &&
|
354
|
+
tokenBefore.range[1] === node.range[0] &&
|
355
|
+
!astUtils.canTokensBeAdjacent(tokenBefore, firstRightToken)
|
356
|
+
) {
|
317
357
|
prefix = " ";
|
318
358
|
}
|
319
359
|
|
320
|
-
return
|
360
|
+
return (
|
361
|
+
prefix +
|
362
|
+
rightText +
|
363
|
+
textBeforeOperator +
|
364
|
+
OPERATOR_FLIP_MAP[operatorToken.value] +
|
365
|
+
textAfterOperator +
|
366
|
+
leftText
|
367
|
+
);
|
321
368
|
}
|
322
369
|
|
323
370
|
//--------------------------------------------------------------------------
|
@@ -331,8 +378,12 @@ module.exports = {
|
|
331
378
|
|
332
379
|
// If `expectedLiteral` is not a literal, and `expectedNonLiteral` is a literal, raise an error.
|
333
380
|
if (
|
334
|
-
(expectedNonLiteral.type === "Literal" ||
|
335
|
-
|
381
|
+
(expectedNonLiteral.type === "Literal" ||
|
382
|
+
looksLikeLiteral(expectedNonLiteral)) &&
|
383
|
+
!(
|
384
|
+
expectedLiteral.type === "Literal" ||
|
385
|
+
looksLikeLiteral(expectedLiteral)
|
386
|
+
) &&
|
336
387
|
!(!isEqualityOperator(node.operator) && onlyEquality) &&
|
337
388
|
isComparisonOperator(node.operator) &&
|
338
389
|
!(exceptRange && isRangeTest(context.getAncestors().pop()))
|
@@ -344,12 +395,11 @@ module.exports = {
|
|
344
395
|
operator: node.operator,
|
345
396
|
expectedSide: always ? "left" : "right"
|
346
397
|
},
|
347
|
-
fix: fixer =>
|
398
|
+
fix: fixer =>
|
399
|
+
fixer.replaceText(node, getFlippedString(node))
|
348
400
|
});
|
349
401
|
}
|
350
|
-
|
351
402
|
}
|
352
403
|
};
|
353
|
-
|
354
404
|
}
|
355
405
|
};
|
@@ -11,6 +11,7 @@ const Module = require("module");
|
|
11
11
|
* `Module.createRequire` is added in v12.2.0. It supports URL as well.
|
12
12
|
* We only support the case where the argument is a filepath, not a URL.
|
13
13
|
*/
|
14
|
+
// eslint-disable-next-line node/no-unsupported-features/node-builtins, node/no-deprecated-api
|
14
15
|
const createRequire = Module.createRequire || Module.createRequireFromPath;
|
15
16
|
|
16
17
|
module.exports = {
|
package/lib/shared/types.js
CHANGED
@@ -141,3 +141,10 @@ module.exports = {};
|
|
141
141
|
* @property {Record<string, Processor>} [processors] The definition of plugin processors.
|
142
142
|
* @property {Record<string, Function | Rule>} [rules] The definition of plugin rules.
|
143
143
|
*/
|
144
|
+
|
145
|
+
/**
|
146
|
+
* Information of deprecated rules.
|
147
|
+
* @typedef {Object} DeprecatedRuleInfo
|
148
|
+
* @property {string} ruleId The rule ID.
|
149
|
+
* @property {string[]} replacedBy The rule IDs that replace this deprecated rule.
|
150
|
+
*/
|
@@ -305,6 +305,7 @@ class SourceCode extends TokenStore {
|
|
305
305
|
* @returns {Object} An object containing a leading and trailing array
|
306
306
|
* of comments indexed by their position.
|
307
307
|
* @public
|
308
|
+
* @deprecated replaced by getCommentsBefore(), getCommentsAfter(), and getCommentsInside().
|
308
309
|
*/
|
309
310
|
getComments(node) {
|
310
311
|
if (this._commentCache.has(node)) {
|
@@ -2,4 +2,4 @@ ESLint couldn't find the config "<%- configName %>" to extend from. Please check
|
|
2
2
|
|
3
3
|
The config "<%- configName %>" was referenced from the config file in "<%- importerName %>".
|
4
4
|
|
5
|
-
If you still have problems, please stop by https://
|
5
|
+
If you still have problems, please stop by https://eslint.org/chat to chat with the team.
|
@@ -4,4 +4,4 @@ ESLint couldn't find a configuration file. To set up a configuration file for th
|
|
4
4
|
|
5
5
|
ESLint looked for configuration files in <%= directoryPath %> and its ancestors. If it found none, it then looked in your home directory.
|
6
6
|
|
7
|
-
If you think you already have a configuration file or if you need more help, please stop by the ESLint chat room: https://
|
7
|
+
If you think you already have a configuration file or if you need more help, please stop by the ESLint chat room: https://eslint.org/chat
|
@@ -4,4 +4,4 @@ ESLint couldn't determine the plugin "<%- pluginId %>" uniquely.
|
|
4
4
|
|
5
5
|
Please remove the "plugins" setting from either config or remove either plugin installation.
|
6
6
|
|
7
|
-
If you still can't figure out the problem, please stop by https://
|
7
|
+
If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team.
|
@@ -8,4 +8,4 @@ It's likely that the plugin isn't installed correctly. Try reinstalling by runni
|
|
8
8
|
|
9
9
|
The plugin "<%- pluginName %>" was referenced from the config file in "<%- importerName %>".
|
10
10
|
|
11
|
-
If you still can't figure out the problem, please stop by https://
|
11
|
+
If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team.
|
@@ -1,3 +1,3 @@
|
|
1
1
|
ESLint couldn't find the plugin "<%- pluginName %>". because there is whitespace in the name. Please check your configuration and remove all whitespace from the plugin name.
|
2
2
|
|
3
|
-
If you still can't figure out the problem, please stop by https://
|
3
|
+
If you still can't figure out the problem, please stop by https://eslint.org/chat to chat with the team.
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "7.
|
3
|
+
"version": "7.2.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -48,14 +48,14 @@
|
|
48
48
|
"dependencies": {
|
49
49
|
"@babel/code-frame": "^7.0.0",
|
50
50
|
"ajv": "^6.10.0",
|
51
|
-
"chalk": "^
|
52
|
-
"cross-spawn": "^7.0.
|
51
|
+
"chalk": "^4.0.0",
|
52
|
+
"cross-spawn": "^7.0.2",
|
53
53
|
"debug": "^4.0.1",
|
54
54
|
"doctrine": "^3.0.0",
|
55
|
-
"eslint-scope": "^5.
|
55
|
+
"eslint-scope": "^5.1.0",
|
56
56
|
"eslint-utils": "^2.0.0",
|
57
|
-
"eslint-visitor-keys": "^1.
|
58
|
-
"espree": "^
|
57
|
+
"eslint-visitor-keys": "^1.2.0",
|
58
|
+
"espree": "^7.1.0",
|
59
59
|
"esquery": "^1.2.0",
|
60
60
|
"esutils": "^2.0.2",
|
61
61
|
"file-entry-cache": "^5.0.1",
|
@@ -69,16 +69,16 @@
|
|
69
69
|
"is-glob": "^4.0.0",
|
70
70
|
"js-yaml": "^3.13.1",
|
71
71
|
"json-stable-stringify-without-jsonify": "^1.0.1",
|
72
|
-
"levn": "^0.
|
72
|
+
"levn": "^0.4.1",
|
73
73
|
"lodash": "^4.17.14",
|
74
74
|
"minimatch": "^3.0.4",
|
75
75
|
"natural-compare": "^1.4.0",
|
76
|
-
"optionator": "^0.
|
76
|
+
"optionator": "^0.9.1",
|
77
77
|
"progress": "^2.0.0",
|
78
|
-
"regexpp": "^3.
|
79
|
-
"semver": "^7.
|
78
|
+
"regexpp": "^3.1.0",
|
79
|
+
"semver": "^7.2.1",
|
80
80
|
"strip-ansi": "^6.0.0",
|
81
|
-
"strip-json-comments": "^3.0
|
81
|
+
"strip-json-comments": "^3.1.0",
|
82
82
|
"table": "^5.2.3",
|
83
83
|
"text-table": "^0.2.0",
|
84
84
|
"v8-compile-cache": "^2.0.3"
|
@@ -86,46 +86,47 @@
|
|
86
86
|
"devDependencies": {
|
87
87
|
"@babel/core": "^7.4.3",
|
88
88
|
"@babel/preset-env": "^7.4.3",
|
89
|
-
"acorn": "^7.
|
89
|
+
"acorn": "^7.2.0",
|
90
90
|
"babel-loader": "^8.0.5",
|
91
91
|
"chai": "^4.0.1",
|
92
92
|
"cheerio": "^0.22.0",
|
93
93
|
"common-tags": "^1.8.0",
|
94
94
|
"core-js": "^3.1.3",
|
95
95
|
"dateformat": "^3.0.3",
|
96
|
-
"ejs": "^
|
96
|
+
"ejs": "^3.0.2",
|
97
|
+
"escape-string-regexp": "^3.0.0",
|
97
98
|
"eslint": "file:.",
|
98
99
|
"eslint-config-eslint": "file:packages/eslint-config-eslint",
|
99
100
|
"eslint-plugin-eslint-plugin": "^2.2.1",
|
100
101
|
"eslint-plugin-internal-rules": "file:tools/internal-rules",
|
101
|
-
"eslint-plugin-jsdoc": "^
|
102
|
-
"eslint-plugin-node": "^
|
103
|
-
"eslint-release": "^
|
102
|
+
"eslint-plugin-jsdoc": "^22.1.0",
|
103
|
+
"eslint-plugin-node": "^11.1.0",
|
104
|
+
"eslint-release": "^2.0.0",
|
104
105
|
"eslump": "^2.0.0",
|
105
106
|
"esprima": "^4.0.1",
|
106
|
-
"glob": "^7.1.
|
107
|
+
"glob": "^7.1.6",
|
107
108
|
"jsdoc": "^3.5.5",
|
108
109
|
"karma": "^4.0.1",
|
109
|
-
"karma-chrome-launcher": "^
|
110
|
+
"karma-chrome-launcher": "^3.1.0",
|
110
111
|
"karma-mocha": "^1.3.0",
|
111
112
|
"karma-mocha-reporter": "^2.2.3",
|
112
113
|
"karma-webpack": "^4.0.0-rc.6",
|
113
114
|
"leche": "^2.2.3",
|
114
|
-
"lint-staged": "^
|
115
|
+
"lint-staged": "^10.1.2",
|
115
116
|
"load-perf": "^0.2.0",
|
116
|
-
"markdownlint": "^0.
|
117
|
-
"markdownlint-cli": "^0.
|
117
|
+
"markdownlint": "^0.19.0",
|
118
|
+
"markdownlint-cli": "^0.22.0",
|
118
119
|
"memfs": "^3.0.1",
|
119
|
-
"mocha": "^
|
120
|
+
"mocha": "^7.1.1",
|
120
121
|
"mocha-junit-reporter": "^1.23.0",
|
121
122
|
"npm-license": "^0.3.3",
|
122
|
-
"nyc": "^
|
123
|
+
"nyc": "^15.0.1",
|
123
124
|
"proxyquire": "^2.0.1",
|
124
|
-
"puppeteer": "^1.
|
125
|
-
"recast": "^0.
|
125
|
+
"puppeteer": "^2.1.1",
|
126
|
+
"recast": "^0.19.0",
|
126
127
|
"regenerator-runtime": "^0.13.2",
|
127
128
|
"shelljs": "^0.8.2",
|
128
|
-
"sinon": "^
|
129
|
+
"sinon": "^9.0.1",
|
129
130
|
"temp": "^0.9.0",
|
130
131
|
"webpack": "^4.35.0",
|
131
132
|
"webpack-cli": "^3.3.5",
|