eslint 5.2.0 → 5.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/CHANGELOG.md +63 -0
- package/conf/eslint-recommended.js +4 -0
- package/lib/cli-engine.js +13 -14
- package/lib/code-path-analysis/code-path-analyzer.js +1 -1
- package/lib/config/config-initializer.js +7 -7
- package/lib/config.js +1 -1
- package/lib/formatters/codeframe.js +2 -2
- package/lib/ignored-paths.js +125 -37
- package/lib/linter.js +1 -1
- package/lib/rules/array-bracket-newline.js +1 -1
- package/lib/rules/array-bracket-spacing.js +1 -1
- package/lib/rules/array-callback-return.js +1 -1
- package/lib/rules/array-element-newline.js +1 -1
- package/lib/rules/arrow-body-style.js +1 -1
- package/lib/rules/arrow-parens.js +1 -1
- package/lib/rules/arrow-spacing.js +1 -1
- package/lib/rules/block-spacing.js +1 -1
- package/lib/rules/brace-style.js +1 -1
- package/lib/rules/camelcase.js +1 -1
- package/lib/rules/capitalized-comments.js +1 -1
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/comma-style.js +2 -2
- package/lib/rules/complexity.js +3 -3
- package/lib/rules/computed-property-spacing.js +1 -1
- package/lib/rules/consistent-return.js +1 -1
- package/lib/rules/curly.js +1 -1
- package/lib/rules/dot-location.js +1 -1
- package/lib/rules/dot-notation.js +1 -1
- package/lib/rules/eqeqeq.js +1 -1
- package/lib/rules/for-direction.js +5 -2
- package/lib/rules/func-call-spacing.js +8 -4
- package/lib/rules/func-name-matching.js +13 -7
- package/lib/rules/func-names.js +82 -21
- package/lib/rules/func-style.js +8 -4
- package/lib/rules/function-paren-newline.js +12 -6
- package/lib/rules/generator-star-spacing.js +18 -9
- package/lib/rules/getter-return.js +8 -6
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +43 -7
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/key-spacing.js +2 -2
- package/lib/rules/keyword-spacing.js +1 -1
- package/lib/rules/line-comment-position.js +3 -3
- package/lib/rules/linebreak-style.js +1 -1
- package/lib/rules/lines-around-comment.js +1 -1
- package/lib/rules/lines-around-directive.js +1 -1
- package/lib/rules/lines-between-class-members.js +1 -1
- package/lib/rules/max-depth.js +2 -2
- package/lib/rules/max-len.js +1 -1
- package/lib/rules/max-lines-per-function.js +1 -1
- package/lib/rules/max-lines.js +2 -2
- package/lib/rules/max-nested-callbacks.js +2 -2
- package/lib/rules/max-params.js +5 -4
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/max-statements.js +3 -3
- package/lib/rules/multiline-comment-style.js +1 -1
- package/lib/rules/multiline-ternary.js +1 -1
- package/lib/rules/new-parens.js +1 -1
- package/lib/rules/newline-after-var.js +1 -1
- package/lib/rules/newline-per-chained-call.js +1 -1
- package/lib/rules/no-alert.js +1 -1
- package/lib/rules/no-async-promise-executor.js +33 -0
- package/lib/rules/no-catch-shadow.js +1 -1
- package/lib/rules/no-class-assign.js +1 -1
- package/lib/rules/no-cond-assign.js +1 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-console.js +1 -1
- package/lib/rules/no-const-assign.js +1 -1
- package/lib/rules/no-constant-condition.js +2 -0
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-else-return.js +1 -1
- package/lib/rules/no-empty-function.js +1 -1
- package/lib/rules/no-empty.js +1 -1
- package/lib/rules/no-eval.js +1 -1
- package/lib/rules/no-ex-assign.js +1 -1
- package/lib/rules/no-extend-native.js +1 -1
- package/lib/rules/no-extra-bind.js +1 -1
- package/lib/rules/no-extra-boolean-cast.js +1 -1
- package/lib/rules/no-extra-label.js +1 -1
- package/lib/rules/no-extra-parens.js +2 -2
- package/lib/rules/no-extra-semi.js +1 -1
- package/lib/rules/no-floating-decimal.js +1 -1
- package/lib/rules/no-func-assign.js +1 -1
- package/lib/rules/no-implicit-coercion.js +1 -1
- package/lib/rules/no-inline-comments.js +1 -1
- package/lib/rules/no-invalid-this.js +1 -1
- package/lib/rules/no-irregular-whitespace.js +1 -1
- package/lib/rules/no-label-var.js +1 -1
- package/lib/rules/no-labels.js +1 -1
- package/lib/rules/no-magic-numbers.js +7 -3
- package/lib/rules/no-misleading-character-class.js +189 -0
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/no-multi-spaces.js +1 -1
- package/lib/rules/no-multi-str.js +1 -1
- package/lib/rules/no-regex-spaces.js +1 -1
- package/lib/rules/no-restricted-globals.js +1 -1
- package/lib/rules/no-restricted-imports.js +1 -1
- package/lib/rules/no-restricted-modules.js +1 -1
- package/lib/rules/no-restricted-properties.js +1 -1
- package/lib/rules/no-return-assign.js +1 -1
- package/lib/rules/no-return-await.js +1 -1
- package/lib/rules/no-self-assign.js +1 -1
- package/lib/rules/no-sequences.js +1 -1
- package/lib/rules/no-shadow.js +1 -1
- package/lib/rules/no-this-before-super.js +1 -1
- package/lib/rules/no-throw-literal.js +1 -1
- package/lib/rules/no-trailing-spaces.js +1 -1
- package/lib/rules/no-undef-init.js +1 -1
- package/lib/rules/no-unexpected-multiline.js +1 -1
- package/lib/rules/no-unmodified-loop-condition.js +2 -3
- package/lib/rules/no-unneeded-ternary.js +1 -1
- package/lib/rules/no-unsafe-negation.js +1 -1
- package/lib/rules/no-unused-vars.js +1 -1
- package/lib/rules/no-useless-call.js +1 -1
- package/lib/rules/no-useless-computed-key.js +1 -1
- package/lib/rules/no-useless-concat.js +1 -1
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-useless-return.js +2 -11
- package/lib/rules/no-var.js +1 -1
- package/lib/rules/no-warning-comments.js +1 -1
- package/lib/rules/no-whitespace-before-property.js +1 -1
- package/lib/rules/object-curly-newline.js +1 -1
- package/lib/rules/object-curly-spacing.js +1 -1
- package/lib/rules/object-shorthand.js +1 -1
- package/lib/rules/one-var.js +6 -6
- package/lib/rules/operator-assignment.js +1 -1
- package/lib/rules/operator-linebreak.js +1 -1
- package/lib/rules/padded-blocks.js +6 -6
- package/lib/rules/padding-line-between-statements.js +2 -2
- package/lib/rules/prefer-const.js +2 -11
- package/lib/rules/prefer-object-spread.js +9 -3
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-reflect.js +1 -1
- package/lib/rules/prefer-spread.js +1 -1
- package/lib/rules/prefer-template.js +1 -1
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/radix.js +1 -1
- package/lib/rules/require-atomic-updates.js +239 -0
- package/lib/rules/require-await.js +1 -1
- package/lib/rules/require-unicode-regexp.js +65 -0
- package/lib/rules/semi-spacing.js +3 -3
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/semi.js +1 -1
- package/lib/rules/sort-keys.js +1 -1
- package/lib/rules/space-before-blocks.js +1 -1
- package/lib/rules/space-before-function-paren.js +1 -1
- package/lib/rules/space-in-parens.js +1 -1
- package/lib/rules/space-unary-ops.js +2 -2
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/strict.js +1 -1
- package/lib/rules/switch-colon-spacing.js +1 -1
- package/lib/rules/symbol-description.js +1 -1
- package/lib/rules/template-curly-spacing.js +1 -1
- package/lib/rules/valid-jsdoc.js +1 -1
- package/lib/rules/wrap-iife.js +1 -1
- package/lib/rules/yoda.js +1 -1
- package/lib/testers/rule-tester.js +7 -7
- package/lib/token-store/index.js +1 -1
- package/lib/{ast-utils.js → util/ast-utils.js} +0 -0
- package/lib/{file-finder.js → util/file-finder.js} +2 -2
- package/lib/util/fix-tracker.js +1 -1
- package/lib/util/{glob-util.js → glob-utils.js} +4 -4
- package/lib/util/lint-result-cache.js +2 -2
- package/lib/util/naming.js +2 -2
- package/lib/util/node-event-generator.js +3 -3
- package/lib/util/{npm-util.js → npm-utils.js} +0 -0
- package/lib/util/{path-util.js → path-utils.js} +1 -1
- package/lib/util/source-code-fixer.js +1 -1
- package/lib/util/{source-code-util.js → source-code-utils.js} +3 -3
- package/lib/util/source-code.js +1 -1
- package/lib/util/unicode/index.js +11 -0
- package/lib/util/unicode/is-combining-character.js +13 -0
- package/lib/util/unicode/is-emoji-modifier.js +13 -0
- package/lib/util/unicode/is-regional-indicator-symbol.js +13 -0
- package/lib/util/unicode/is-surrogate-pair.js +14 -0
- package/package.json +13 -14
- package/lib/rules/.eslintrc.yml +0 -4
package/lib/rules/indent.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
/**
|
2
|
-
* @fileoverview This
|
2
|
+
* @fileoverview This rule sets a specific indentation style and width for your code
|
3
3
|
*
|
4
4
|
* @author Teddy Katz
|
5
5
|
* @author Vitaly Puzrin
|
@@ -13,7 +13,7 @@
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
|
15
15
|
const lodash = require("lodash");
|
16
|
-
const astUtils = require("../ast-utils");
|
16
|
+
const astUtils = require("../util/ast-utils");
|
17
17
|
const createTree = require("functional-red-black-tree");
|
18
18
|
|
19
19
|
//------------------------------------------------------------------------------
|
@@ -855,7 +855,11 @@ module.exports = {
|
|
855
855
|
previousElement &&
|
856
856
|
previousElementLastToken.loc.end.line - countTrailingLinebreaks(previousElementLastToken.value) > startToken.loc.end.line
|
857
857
|
) {
|
858
|
-
offsets.setDesiredOffsets(
|
858
|
+
offsets.setDesiredOffsets(
|
859
|
+
[previousElement.range[1], element.range[1]],
|
860
|
+
firstTokenOfPreviousElement,
|
861
|
+
0
|
862
|
+
);
|
859
863
|
}
|
860
864
|
}
|
861
865
|
});
|
@@ -997,6 +1001,31 @@ module.exports = {
|
|
997
1001
|
return !node || node.loc.start.line === token.loc.start.line;
|
998
1002
|
}
|
999
1003
|
|
1004
|
+
/**
|
1005
|
+
* Check whether there are any blank (whitespace-only) lines between
|
1006
|
+
* two tokens on separate lines.
|
1007
|
+
* @param {Token} firstToken The first token.
|
1008
|
+
* @param {Token} secondToken The second token.
|
1009
|
+
* @returns {boolean} `true` if the tokens are on separate lines and
|
1010
|
+
* there exists a blank line between them, `false` otherwise.
|
1011
|
+
*/
|
1012
|
+
function hasBlankLinesBetween(firstToken, secondToken) {
|
1013
|
+
const firstTokenLine = firstToken.loc.end.line;
|
1014
|
+
const secondTokenLine = secondToken.loc.start.line;
|
1015
|
+
|
1016
|
+
if (firstTokenLine === secondTokenLine || firstTokenLine === secondTokenLine - 1) {
|
1017
|
+
return false;
|
1018
|
+
}
|
1019
|
+
|
1020
|
+
for (let line = firstTokenLine + 1; line < secondTokenLine; ++line) {
|
1021
|
+
if (!tokenInfo.firstTokensByLineNumber.has(line)) {
|
1022
|
+
return true;
|
1023
|
+
}
|
1024
|
+
}
|
1025
|
+
|
1026
|
+
return false;
|
1027
|
+
}
|
1028
|
+
|
1000
1029
|
const ignoredNodeFirstTokens = new Set();
|
1001
1030
|
|
1002
1031
|
const baseOffsetListeners = {
|
@@ -1304,7 +1333,9 @@ module.exports = {
|
|
1304
1333
|
node.expressions.forEach((expression, index) => {
|
1305
1334
|
const previousQuasi = node.quasis[index];
|
1306
1335
|
const nextQuasi = node.quasis[index + 1];
|
1307
|
-
const tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line
|
1336
|
+
const tokenToAlignFrom = previousQuasi.loc.start.line === previousQuasi.loc.end.line
|
1337
|
+
? sourceCode.getFirstToken(previousQuasi)
|
1338
|
+
: null;
|
1308
1339
|
|
1309
1340
|
offsets.setDesiredOffsets([previousQuasi.range[1], nextQuasi.range[0]], tokenToAlignFrom, 1);
|
1310
1341
|
offsets.setDesiredOffset(sourceCode.getFirstToken(nextQuasi), tokenToAlignFrom, 0);
|
@@ -1312,7 +1343,9 @@ module.exports = {
|
|
1312
1343
|
},
|
1313
1344
|
|
1314
1345
|
VariableDeclaration(node) {
|
1315
|
-
const variableIndent =
|
1346
|
+
const variableIndent = Object.prototype.hasOwnProperty.call(options.VariableDeclarator, node.kind)
|
1347
|
+
? options.VariableDeclarator[node.kind]
|
1348
|
+
: DEFAULT_VARIABLE_INDENT;
|
1316
1349
|
|
1317
1350
|
if (node.declarations[node.declarations.length - 1].loc.start.line > node.loc.start.line) {
|
1318
1351
|
|
@@ -1536,10 +1569,13 @@ module.exports = {
|
|
1536
1569
|
const tokenBefore = precedingTokens.get(firstTokenOfLine);
|
1537
1570
|
const tokenAfter = tokenBefore ? sourceCode.getTokenAfter(tokenBefore) : sourceCode.ast.tokens[0];
|
1538
1571
|
|
1572
|
+
const mayAlignWithBefore = tokenBefore && !hasBlankLinesBetween(tokenBefore, firstTokenOfLine);
|
1573
|
+
const mayAlignWithAfter = tokenAfter && !hasBlankLinesBetween(firstTokenOfLine, tokenAfter);
|
1574
|
+
|
1539
1575
|
// If a comment matches the expected indentation of the token immediately before or after, don't report it.
|
1540
1576
|
if (
|
1541
|
-
|
1542
|
-
|
1577
|
+
mayAlignWithBefore && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenBefore)) ||
|
1578
|
+
mayAlignWithAfter && validateTokenIndent(firstTokenOfLine, offsets.getDesiredIndent(tokenAfter))
|
1543
1579
|
) {
|
1544
1580
|
return;
|
1545
1581
|
}
|
package/lib/rules/jsx-quotes.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Constants
|
package/lib/rules/key-spacing.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Helpers
|
@@ -540,7 +540,7 @@ module.exports = {
|
|
540
540
|
const length = properties.length,
|
541
541
|
widths = properties.map(getKeyWidth), // Width of keys, including quotes
|
542
542
|
align = alignmentOptions.on; // "value" or "colon"
|
543
|
-
let targetWidth = Math.max
|
543
|
+
let targetWidth = Math.max(...widths),
|
544
544
|
beforeColon, afterColon, mode;
|
545
545
|
|
546
546
|
if (alignmentOptions && length > 1) { // When aligning values within a group, use the alignment configuration.
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils"),
|
12
|
+
const astUtils = require("../util/ast-utils"),
|
13
13
|
keywords = require("../util/keywords");
|
14
14
|
|
15
15
|
//------------------------------------------------------------------------------
|
@@ -4,7 +4,7 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
const astUtils = require("../ast-utils");
|
7
|
+
const astUtils = require("../util/ast-utils");
|
8
8
|
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
// Rule Definition
|
@@ -59,10 +59,10 @@ module.exports = {
|
|
59
59
|
above = !options || options === "above";
|
60
60
|
|
61
61
|
} else {
|
62
|
-
above = options.position === "above";
|
62
|
+
above = !options.position || options.position === "above";
|
63
63
|
ignorePattern = options.ignorePattern;
|
64
64
|
|
65
|
-
if (
|
65
|
+
if (Object.prototype.hasOwnProperty.call(options, "applyDefaultIgnorePatterns")) {
|
66
66
|
applyDefaultIgnorePatterns = options.applyDefaultIgnorePatterns !== false;
|
67
67
|
} else {
|
68
68
|
applyDefaultIgnorePatterns = options.applyDefaultPatterns !== false;
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Rule Definition
|
@@ -9,7 +9,7 @@
|
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
11
|
const lodash = require("lodash"),
|
12
|
-
astUtils = require("../ast-utils");
|
12
|
+
astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Helpers
|
package/lib/rules/max-depth.js
CHANGED
@@ -54,10 +54,10 @@ module.exports = {
|
|
54
54
|
option = context.options[0];
|
55
55
|
let maxDepth = 4;
|
56
56
|
|
57
|
-
if (typeof option === "object" &&
|
57
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
58
58
|
maxDepth = option.maximum;
|
59
59
|
}
|
60
|
-
if (typeof option === "object" &&
|
60
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
61
61
|
maxDepth = option.max;
|
62
62
|
}
|
63
63
|
if (typeof option === "number") {
|
package/lib/rules/max-len.js
CHANGED
@@ -266,7 +266,7 @@ module.exports = {
|
|
266
266
|
// list of comments to ignore
|
267
267
|
comments = ignoreComments || maxCommentLength || ignoreTrailingComments ? sourceCode.getAllComments() : [];
|
268
268
|
|
269
|
-
|
269
|
+
// we iterate over comments in parallel with the lines
|
270
270
|
let commentsIndex = 0;
|
271
271
|
|
272
272
|
const strings = getAllStrings();
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Constants
|
package/lib/rules/max-lines.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
11
|
const lodash = require("lodash");
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Rule Definition
|
@@ -56,7 +56,7 @@ module.exports = {
|
|
56
56
|
const option = context.options[0];
|
57
57
|
let max = 300;
|
58
58
|
|
59
|
-
if (typeof option === "object" &&
|
59
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
60
60
|
max = option.max;
|
61
61
|
}
|
62
62
|
|
@@ -52,10 +52,10 @@ module.exports = {
|
|
52
52
|
const option = context.options[0];
|
53
53
|
let THRESHOLD = 10;
|
54
54
|
|
55
|
-
if (typeof option === "object" &&
|
55
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
56
56
|
THRESHOLD = option.maximum;
|
57
57
|
}
|
58
|
-
if (typeof option === "object" &&
|
58
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
59
59
|
THRESHOLD = option.max;
|
60
60
|
}
|
61
61
|
if (typeof option === "number") {
|
package/lib/rules/max-params.js
CHANGED
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
const lodash = require("lodash");
|
13
13
|
|
14
|
-
const astUtils = require("../ast-utils");
|
14
|
+
const astUtils = require("../util/ast-utils");
|
15
15
|
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
// Rule Definition
|
@@ -53,14 +53,14 @@ module.exports = {
|
|
53
53
|
},
|
54
54
|
|
55
55
|
create(context) {
|
56
|
-
|
56
|
+
const sourceCode = context.getSourceCode();
|
57
57
|
const option = context.options[0];
|
58
58
|
let numParams = 3;
|
59
59
|
|
60
|
-
if (typeof option === "object" &&
|
60
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
61
61
|
numParams = option.maximum;
|
62
62
|
}
|
63
|
-
if (typeof option === "object" &&
|
63
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
64
64
|
numParams = option.max;
|
65
65
|
}
|
66
66
|
if (typeof option === "number") {
|
@@ -76,6 +76,7 @@ module.exports = {
|
|
76
76
|
function checkFunction(node) {
|
77
77
|
if (node.params.length > numParams) {
|
78
78
|
context.report({
|
79
|
+
loc: astUtils.getFunctionHeadLoc(node, sourceCode),
|
79
80
|
node,
|
80
81
|
message: "{{name}} has too many parameters ({{count}}). Maximum allowed is {{max}}.",
|
81
82
|
data: {
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Rule Definition
|
@@ -11,7 +11,7 @@
|
|
11
11
|
|
12
12
|
const lodash = require("lodash");
|
13
13
|
|
14
|
-
const astUtils = require("../ast-utils");
|
14
|
+
const astUtils = require("../util/ast-utils");
|
15
15
|
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
// Rule Definition
|
@@ -73,10 +73,10 @@ module.exports = {
|
|
73
73
|
topLevelFunctions = [];
|
74
74
|
let maxStatements = 10;
|
75
75
|
|
76
|
-
if (typeof option === "object" &&
|
76
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "maximum") && typeof option.maximum === "number") {
|
77
77
|
maxStatements = option.maximum;
|
78
78
|
}
|
79
|
-
if (typeof option === "object" &&
|
79
|
+
if (typeof option === "object" && Object.prototype.hasOwnProperty.call(option, "max") && typeof option.max === "number") {
|
80
80
|
maxStatements = option.max;
|
81
81
|
}
|
82
82
|
if (typeof option === "number") {
|
package/lib/rules/new-parens.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Helpers
|
@@ -10,7 +10,7 @@
|
|
10
10
|
// Requirements
|
11
11
|
//------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
const astUtils = require("../ast-utils");
|
13
|
+
const astUtils = require("../util/ast-utils");
|
14
14
|
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
// Rule Definition
|
package/lib/rules/no-alert.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const getPropertyName = require("../ast-utils").getStaticPropertyName;
|
11
|
+
const getPropertyName = require("../util/ast-utils").getStaticPropertyName;
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Helpers
|
@@ -0,0 +1,33 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview disallow using an async function as a Promise executor
|
3
|
+
* @author Teddy Katz
|
4
|
+
*/
|
5
|
+
"use strict";
|
6
|
+
|
7
|
+
//------------------------------------------------------------------------------
|
8
|
+
// Rule Definition
|
9
|
+
//------------------------------------------------------------------------------
|
10
|
+
|
11
|
+
module.exports = {
|
12
|
+
meta: {
|
13
|
+
docs: {
|
14
|
+
description: "disallow using an async function as a Promise executor",
|
15
|
+
category: "Possible Errors",
|
16
|
+
recommended: false,
|
17
|
+
url: "https://eslint.org/docs/rules/no-async-promise-executor"
|
18
|
+
},
|
19
|
+
fixable: null,
|
20
|
+
schema: []
|
21
|
+
},
|
22
|
+
|
23
|
+
create(context) {
|
24
|
+
return {
|
25
|
+
"NewExpression[callee.name='Promise'][arguments.0.async=true]"(node) {
|
26
|
+
context.report({
|
27
|
+
node: context.getSourceCode().getFirstToken(node.arguments[0], token => token.value === "async"),
|
28
|
+
message: "Promise executor functions should not be async."
|
29
|
+
});
|
30
|
+
}
|
31
|
+
};
|
32
|
+
}
|
33
|
+
};
|
@@ -10,7 +10,7 @@
|
|
10
10
|
// Requirements
|
11
11
|
//------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
const astUtils = require("../ast-utils");
|
13
|
+
const astUtils = require("../util/ast-utils");
|
14
14
|
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
// Rule Definition
|
package/lib/rules/no-console.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Rule Definition
|
@@ -207,6 +207,8 @@ module.exports = {
|
|
207
207
|
"ForStatement:exit": checkConstantConditionLoopInSet,
|
208
208
|
FunctionDeclaration: enterFunction,
|
209
209
|
"FunctionDeclaration:exit": exitFunction,
|
210
|
+
FunctionExpression: enterFunction,
|
211
|
+
"FunctionExpression:exit": exitFunction,
|
210
212
|
YieldExpression: () => loopsInCurrentScope.clear()
|
211
213
|
};
|
212
214
|
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Helpers
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
const FixTracker = require("../util/fix-tracker");
|
14
14
|
|
15
15
|
//------------------------------------------------------------------------------
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Helpers
|
package/lib/rules/no-empty.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Rule Definition
|
package/lib/rules/no-eval.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Helpers
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
const globals = require("globals");
|
14
14
|
|
15
15
|
//------------------------------------------------------------------------------
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Requirements
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils");
|
11
|
+
const astUtils = require("../util/ast-utils");
|
12
12
|
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
// Rule Definition
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Rule Definition
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
const astUtils = require("../ast-utils");
|
12
|
+
const astUtils = require("../util/ast-utils");
|
13
13
|
|
14
14
|
//------------------------------------------------------------------------------
|
15
15
|
// Rule Definition
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Rule Definition
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
const astUtils = require("../ast-utils.js");
|
11
|
+
const astUtils = require("../util/ast-utils.js");
|
12
12
|
|
13
13
|
module.exports = {
|
14
14
|
meta: {
|
@@ -58,7 +58,7 @@ module.exports = {
|
|
58
58
|
},
|
59
59
|
|
60
60
|
messages: {
|
61
|
-
unexpected: "
|
61
|
+
unexpected: "Unnecessary parentheses around expression."
|
62
62
|
}
|
63
63
|
},
|
64
64
|
|
@@ -10,7 +10,7 @@
|
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
12
|
const FixTracker = require("../util/fix-tracker");
|
13
|
-
const astUtils = require("../ast-utils");
|
13
|
+
const astUtils = require("../util/ast-utils");
|
14
14
|
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
// Rule Definition
|