eslint 8.0.0-beta.0 → 8.0.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 +4 -4
- package/bin/eslint.js +1 -1
- package/conf/eslint-recommended.js +1 -1
- package/conf/{category-list.json → rule-type-list.json} +4 -7
- package/lib/cli-engine/cli-engine.js +11 -3
- package/lib/cli-engine/file-enumerator.js +4 -3
- package/lib/cli-engine/formatters/html.js +1 -1
- package/lib/cli-engine/hash.js +2 -2
- package/lib/cli-engine/xml-escape.js +1 -1
- package/lib/config/flat-config-array.js +2 -2
- package/lib/config/flat-config-schema.js +1 -1
- package/lib/config/rule-validator.js +25 -8
- package/lib/eslint/eslint.js +4 -0
- package/lib/init/autoconfig.js +17 -18
- package/lib/init/config-file.js +3 -3
- package/lib/init/config-initializer.js +11 -10
- package/lib/init/config-rule.js +15 -16
- package/lib/init/npm-utils.js +16 -15
- package/lib/init/source-code-utils.js +6 -5
- package/lib/linter/apply-disable-directives.js +80 -11
- package/lib/linter/code-path-analysis/code-path-analyzer.js +115 -36
- package/lib/linter/code-path-analysis/code-path-segment.js +0 -1
- package/lib/linter/code-path-analysis/code-path-state.js +4 -1
- package/lib/linter/code-path-analysis/code-path.js +14 -5
- package/lib/linter/code-path-analysis/debug-helpers.js +2 -2
- package/lib/linter/code-path-analysis/fork-context.js +0 -1
- package/lib/linter/code-path-analysis/id-generator.js +0 -1
- package/lib/linter/config-comment-parser.js +1 -1
- package/lib/linter/linter.js +51 -22
- package/lib/linter/node-event-generator.js +0 -1
- package/lib/linter/report-translator.js +12 -12
- package/lib/linter/rules.js +3 -0
- package/lib/linter/safe-emitter.js +2 -2
- package/lib/linter/source-code-fixer.js +2 -2
- package/lib/linter/timing.js +2 -2
- package/lib/rule-tester/rule-tester.js +12 -2
- package/lib/rules/accessor-pairs.js +0 -1
- package/lib/rules/array-bracket-newline.js +0 -1
- package/lib/rules/array-bracket-spacing.js +0 -1
- package/lib/rules/array-callback-return.js +0 -1
- package/lib/rules/array-element-newline.js +0 -1
- package/lib/rules/arrow-body-style.js +0 -1
- package/lib/rules/arrow-parens.js +0 -1
- package/lib/rules/arrow-spacing.js +0 -1
- package/lib/rules/block-scoped-var.js +0 -1
- package/lib/rules/block-spacing.js +0 -1
- package/lib/rules/brace-style.js +0 -1
- package/lib/rules/callback-return.js +1 -1
- package/lib/rules/camelcase.js +17 -19
- package/lib/rules/capitalized-comments.js +0 -1
- package/lib/rules/class-methods-use-this.js +51 -9
- package/lib/rules/comma-dangle.js +0 -1
- package/lib/rules/comma-spacing.js +0 -1
- package/lib/rules/comma-style.js +0 -1
- package/lib/rules/complexity.js +47 -56
- package/lib/rules/computed-property-spacing.js +0 -1
- package/lib/rules/consistent-return.js +0 -1
- package/lib/rules/consistent-this.js +1 -2
- package/lib/rules/constructor-super.js +0 -1
- package/lib/rules/curly.js +0 -1
- package/lib/rules/default-case-last.js +0 -1
- package/lib/rules/default-case.js +2 -3
- package/lib/rules/default-param-last.js +1 -2
- package/lib/rules/dot-location.js +0 -1
- package/lib/rules/dot-notation.js +0 -1
- package/lib/rules/eol-last.js +6 -2
- package/lib/rules/eqeqeq.js +1 -2
- package/lib/rules/for-direction.js +0 -1
- package/lib/rules/func-call-spacing.js +0 -1
- package/lib/rules/func-name-matching.js +9 -6
- package/lib/rules/func-names.js +0 -1
- package/lib/rules/func-style.js +0 -1
- package/lib/rules/function-call-argument-newline.js +0 -1
- package/lib/rules/function-paren-newline.js +1 -1
- package/lib/rules/generator-star-spacing.js +0 -1
- package/lib/rules/getter-return.js +0 -1
- package/lib/rules/global-require.js +1 -1
- package/lib/rules/grouped-accessor-pairs.js +0 -1
- package/lib/rules/guard-for-in.js +0 -1
- package/lib/rules/handle-callback-err.js +1 -1
- package/lib/rules/id-blacklist.js +1 -1
- package/lib/rules/id-denylist.js +0 -1
- package/lib/rules/id-length.js +0 -1
- package/lib/rules/id-match.js +0 -1
- package/lib/rules/implicit-arrow-linebreak.js +0 -1
- package/lib/rules/indent-legacy.js +1 -1
- package/lib/rules/indent.js +7 -10
- package/lib/rules/index.js +1 -1
- package/lib/rules/init-declarations.js +0 -1
- package/lib/rules/jsx-quotes.js +0 -1
- package/lib/rules/key-spacing.js +4 -5
- package/lib/rules/keyword-spacing.js +19 -3
- package/lib/rules/line-comment-position.js +0 -1
- package/lib/rules/linebreak-style.js +0 -1
- package/lib/rules/lines-around-comment.js +0 -1
- package/lib/rules/lines-around-directive.js +1 -2
- package/lib/rules/lines-between-class-members.js +50 -3
- package/lib/rules/max-classes-per-file.js +31 -8
- package/lib/rules/max-depth.js +0 -1
- package/lib/rules/max-len.js +1 -2
- package/lib/rules/max-lines-per-function.js +1 -2
- package/lib/rules/max-lines.js +0 -1
- package/lib/rules/max-nested-callbacks.js +0 -1
- package/lib/rules/max-params.js +0 -1
- package/lib/rules/max-statements-per-line.js +0 -1
- package/lib/rules/max-statements.js +0 -1
- package/lib/rules/multiline-comment-style.js +0 -1
- package/lib/rules/multiline-ternary.js +0 -1
- package/lib/rules/new-cap.js +2 -2
- package/lib/rules/new-parens.js +0 -1
- package/lib/rules/newline-after-var.js +4 -5
- package/lib/rules/newline-before-return.js +2 -3
- package/lib/rules/newline-per-chained-call.js +1 -2
- package/lib/rules/no-alert.js +0 -1
- package/lib/rules/no-array-constructor.js +0 -1
- package/lib/rules/no-async-promise-executor.js +0 -1
- package/lib/rules/no-await-in-loop.js +0 -1
- package/lib/rules/no-bitwise.js +5 -6
- package/lib/rules/no-buffer-constructor.js +1 -1
- package/lib/rules/no-caller.js +0 -1
- package/lib/rules/no-case-declarations.js +0 -1
- package/lib/rules/no-catch-shadow.js +0 -1
- package/lib/rules/no-class-assign.js +0 -1
- package/lib/rules/no-compare-neg-zero.js +0 -1
- package/lib/rules/no-cond-assign.js +0 -1
- package/lib/rules/no-confusing-arrow.js +0 -1
- package/lib/rules/no-console.js +0 -1
- package/lib/rules/no-const-assign.js +0 -1
- package/lib/rules/no-constant-condition.js +0 -1
- package/lib/rules/no-constructor-return.js +0 -1
- package/lib/rules/no-continue.js +0 -1
- package/lib/rules/no-control-regex.js +0 -1
- package/lib/rules/no-debugger.js +0 -1
- package/lib/rules/no-delete-var.js +0 -1
- package/lib/rules/no-div-regex.js +0 -1
- package/lib/rules/no-dupe-args.js +0 -1
- package/lib/rules/no-dupe-class-members.js +0 -1
- package/lib/rules/no-dupe-else-if.js +0 -1
- package/lib/rules/no-dupe-keys.js +0 -2
- package/lib/rules/no-duplicate-case.js +0 -1
- package/lib/rules/no-duplicate-imports.js +0 -1
- package/lib/rules/no-else-return.js +0 -1
- package/lib/rules/no-empty-character-class.js +0 -1
- package/lib/rules/no-empty-function.js +0 -1
- package/lib/rules/no-empty-pattern.js +0 -1
- package/lib/rules/no-empty.js +0 -1
- package/lib/rules/no-eq-null.js +0 -1
- package/lib/rules/no-eval.js +0 -1
- package/lib/rules/no-ex-assign.js +0 -1
- package/lib/rules/no-extend-native.js +0 -1
- package/lib/rules/no-extra-bind.js +0 -1
- package/lib/rules/no-extra-boolean-cast.js +1 -1
- package/lib/rules/no-extra-label.js +0 -1
- package/lib/rules/no-extra-parens.js +0 -1
- package/lib/rules/no-extra-semi.js +0 -1
- package/lib/rules/no-fallthrough.js +0 -1
- package/lib/rules/no-floating-decimal.js +0 -1
- package/lib/rules/no-func-assign.js +0 -1
- package/lib/rules/no-global-assign.js +0 -1
- package/lib/rules/no-implicit-coercion.js +0 -1
- package/lib/rules/no-implicit-globals.js +0 -1
- package/lib/rules/no-implied-eval.js +0 -1
- package/lib/rules/no-import-assign.js +0 -1
- package/lib/rules/no-inline-comments.js +0 -1
- package/lib/rules/no-inner-declarations.js +0 -1
- package/lib/rules/no-invalid-regexp.js +0 -1
- package/lib/rules/no-invalid-this.js +0 -1
- package/lib/rules/no-irregular-whitespace.js +0 -1
- package/lib/rules/no-iterator.js +0 -1
- package/lib/rules/no-label-var.js +0 -1
- package/lib/rules/no-labels.js +0 -1
- package/lib/rules/no-lone-blocks.js +0 -1
- package/lib/rules/no-lonely-if.js +0 -1
- package/lib/rules/no-loop-func.js +1 -2
- package/lib/rules/no-loss-of-precision.js +0 -1
- package/lib/rules/no-magic-numbers.js +0 -1
- package/lib/rules/no-misleading-character-class.js +0 -1
- package/lib/rules/no-mixed-operators.js +1 -2
- package/lib/rules/no-mixed-requires.js +1 -1
- package/lib/rules/no-mixed-spaces-and-tabs.js +0 -1
- package/lib/rules/no-multi-assign.js +0 -1
- package/lib/rules/no-multi-spaces.js +0 -1
- package/lib/rules/no-multi-str.js +0 -1
- package/lib/rules/no-multiple-empty-lines.js +0 -1
- package/lib/rules/no-native-reassign.js +0 -1
- package/lib/rules/no-negated-condition.js +0 -1
- package/lib/rules/no-negated-in-lhs.js +0 -1
- package/lib/rules/no-nested-ternary.js +0 -1
- package/lib/rules/no-new-func.js +34 -7
- package/lib/rules/no-new-object.js +0 -1
- package/lib/rules/no-new-require.js +1 -1
- package/lib/rules/no-new-symbol.js +0 -1
- package/lib/rules/no-new-wrappers.js +0 -1
- package/lib/rules/no-new.js +0 -1
- package/lib/rules/no-nonoctal-decimal-escape.js +0 -1
- package/lib/rules/no-obj-calls.js +0 -1
- package/lib/rules/no-octal-escape.js +0 -1
- package/lib/rules/no-octal.js +0 -1
- package/lib/rules/no-param-reassign.js +0 -1
- package/lib/rules/no-path-concat.js +1 -1
- package/lib/rules/no-plusplus.js +0 -1
- package/lib/rules/no-process-env.js +1 -1
- package/lib/rules/no-process-exit.js +1 -1
- package/lib/rules/no-promise-executor-return.js +0 -1
- package/lib/rules/no-proto.js +0 -1
- package/lib/rules/no-prototype-builtins.js +0 -1
- package/lib/rules/no-redeclare.js +0 -1
- package/lib/rules/no-regex-spaces.js +0 -1
- package/lib/rules/no-restricted-exports.js +0 -1
- package/lib/rules/no-restricted-globals.js +1 -2
- package/lib/rules/no-restricted-imports.js +5 -6
- package/lib/rules/no-restricted-modules.js +3 -3
- package/lib/rules/no-restricted-properties.js +2 -3
- package/lib/rules/no-restricted-syntax.js +1 -2
- package/lib/rules/no-return-assign.js +0 -1
- package/lib/rules/no-return-await.js +0 -1
- package/lib/rules/no-script-url.js +1 -3
- package/lib/rules/no-self-assign.js +0 -1
- package/lib/rules/no-self-compare.js +0 -1
- package/lib/rules/no-sequences.js +0 -1
- package/lib/rules/no-setter-return.js +0 -1
- package/lib/rules/no-shadow-restricted-names.js +0 -1
- package/lib/rules/no-shadow.js +1 -2
- package/lib/rules/no-spaced-func.js +0 -1
- package/lib/rules/no-sparse-arrays.js +0 -1
- package/lib/rules/no-sync.js +1 -3
- package/lib/rules/no-tabs.js +0 -1
- package/lib/rules/no-template-curly-in-string.js +0 -1
- package/lib/rules/no-ternary.js +0 -1
- package/lib/rules/no-this-before-super.js +0 -1
- package/lib/rules/no-throw-literal.js +0 -1
- package/lib/rules/no-trailing-spaces.js +0 -1
- package/lib/rules/no-undef-init.js +9 -61
- package/lib/rules/no-undef.js +0 -1
- package/lib/rules/no-undefined.js +0 -1
- package/lib/rules/no-underscore-dangle.js +0 -1
- package/lib/rules/no-unexpected-multiline.js +0 -1
- package/lib/rules/no-unmodified-loop-condition.js +0 -1
- package/lib/rules/no-unneeded-ternary.js +0 -1
- package/lib/rules/no-unreachable-loop.js +0 -1
- package/lib/rules/no-unreachable.js +26 -25
- package/lib/rules/no-unsafe-finally.js +0 -1
- package/lib/rules/no-unsafe-negation.js +0 -1
- package/lib/rules/no-unsafe-optional-chaining.js +0 -1
- package/lib/rules/no-unused-expressions.js +4 -5
- package/lib/rules/no-unused-labels.js +0 -1
- package/lib/rules/no-unused-vars.js +26 -28
- package/lib/rules/no-use-before-define.js +0 -1
- package/lib/rules/no-useless-backreference.js +0 -1
- package/lib/rules/no-useless-call.js +0 -1
- package/lib/rules/no-useless-catch.js +0 -1
- package/lib/rules/no-useless-computed-key.js +1 -1
- package/lib/rules/no-useless-concat.js +0 -1
- package/lib/rules/no-useless-constructor.js +0 -1
- package/lib/rules/no-useless-escape.js +9 -9
- package/lib/rules/no-useless-rename.js +0 -1
- package/lib/rules/no-useless-return.js +0 -1
- package/lib/rules/no-var.js +0 -1
- package/lib/rules/no-void.js +0 -1
- package/lib/rules/no-warning-comments.js +0 -1
- package/lib/rules/no-whitespace-before-property.js +0 -1
- package/lib/rules/no-with.js +0 -1
- package/lib/rules/nonblock-statement-body-position.js +0 -1
- package/lib/rules/object-curly-newline.js +0 -1
- package/lib/rules/object-curly-spacing.js +0 -1
- package/lib/rules/object-property-newline.js +0 -1
- package/lib/rules/object-shorthand.js +3 -8
- package/lib/rules/one-var-declaration-per-line.js +0 -1
- package/lib/rules/one-var.js +1 -2
- package/lib/rules/operator-assignment.js +6 -7
- package/lib/rules/operator-linebreak.js +0 -1
- package/lib/rules/padded-blocks.js +1 -1
- package/lib/rules/padding-line-between-statements.js +0 -1
- package/lib/rules/prefer-arrow-callback.js +1 -1
- package/lib/rules/prefer-const.js +0 -1
- package/lib/rules/prefer-destructuring.js +1 -2
- package/lib/rules/prefer-exponentiation-operator.js +0 -1
- package/lib/rules/prefer-named-capture-group.js +0 -1
- package/lib/rules/prefer-numeric-literals.js +0 -1
- package/lib/rules/prefer-object-spread.js +0 -1
- package/lib/rules/prefer-promise-reject-errors.js +0 -1
- package/lib/rules/prefer-reflect.js +0 -1
- package/lib/rules/prefer-regex-literals.js +0 -1
- package/lib/rules/prefer-rest-params.js +0 -1
- package/lib/rules/prefer-spread.js +0 -1
- package/lib/rules/prefer-template.js +0 -1
- package/lib/rules/quote-props.js +8 -9
- package/lib/rules/quotes.js +0 -1
- package/lib/rules/radix.js +0 -1
- package/lib/rules/require-atomic-updates.js +24 -9
- package/lib/rules/require-await.js +0 -1
- package/lib/rules/require-jsdoc.js +1 -1
- package/lib/rules/require-unicode-regexp.js +0 -1
- package/lib/rules/require-yield.js +0 -1
- package/lib/rules/rest-spread-spacing.js +0 -1
- package/lib/rules/semi-spacing.js +0 -1
- package/lib/rules/semi-style.js +0 -1
- package/lib/rules/semi.js +66 -6
- package/lib/rules/sort-imports.js +0 -1
- package/lib/rules/sort-keys.js +0 -1
- package/lib/rules/sort-vars.js +0 -1
- package/lib/rules/space-before-blocks.js +14 -3
- package/lib/rules/space-before-function-paren.js +0 -1
- package/lib/rules/space-in-parens.js +0 -1
- package/lib/rules/space-infix-ops.js +0 -1
- package/lib/rules/space-unary-ops.js +0 -1
- package/lib/rules/spaced-comment.js +0 -1
- package/lib/rules/strict.js +0 -1
- package/lib/rules/switch-colon-spacing.js +1 -14
- package/lib/rules/symbol-description.js +0 -1
- package/lib/rules/template-curly-spacing.js +0 -1
- package/lib/rules/template-tag-spacing.js +0 -1
- package/lib/rules/unicode-bom.js +0 -1
- package/lib/rules/use-isnan.js +0 -1
- package/lib/rules/utils/ast-utils.js +29 -7
- package/lib/rules/utils/lazy-loading-rule-map.js +3 -3
- package/lib/rules/valid-jsdoc.js +1 -1
- package/lib/rules/valid-typeof.js +0 -1
- package/lib/rules/vars-on-top.js +1 -2
- package/lib/rules/wrap-iife.js +0 -1
- package/lib/rules/wrap-regex.js +0 -1
- package/lib/rules/yield-star-spacing.js +0 -1
- package/lib/rules/yoda.js +0 -1
- package/lib/shared/ajv.js +1 -1
- package/lib/shared/config-validator.js +10 -5
- package/lib/shared/logging.js +1 -1
- package/lib/shared/relative-module-resolver.js +1 -0
- package/lib/shared/runtime-info.js +3 -0
- package/lib/shared/traverser.js +2 -2
- package/lib/shared/types.js +2 -2
- package/lib/source-code/source-code.js +11 -5
- package/lib/source-code/token-store/cursor.js +1 -1
- package/package.json +5 -5
@@ -40,7 +40,6 @@ module.exports = {
|
|
40
40
|
|
41
41
|
docs: {
|
42
42
|
description: "enforce consistent spacing before blocks",
|
43
|
-
category: "Stylistic Issues",
|
44
43
|
recommended: false,
|
45
44
|
url: "https://eslint.org/docs/rules/space-before-blocks"
|
46
45
|
},
|
@@ -108,13 +107,25 @@ module.exports = {
|
|
108
107
|
* Checks whether the spacing before the given block is already controlled by another rule:
|
109
108
|
* - `arrow-spacing` checks spaces after `=>`.
|
110
109
|
* - `keyword-spacing` checks spaces after keywords in certain contexts.
|
110
|
+
* - `switch-colon-spacing` checks spaces after `:` of switch cases.
|
111
111
|
* @param {Token} precedingToken first token before the block.
|
112
112
|
* @param {ASTNode|Token} node `BlockStatement` node or `{` token of a `SwitchStatement` node.
|
113
113
|
* @returns {boolean} `true` if requiring or disallowing spaces before the given block could produce conflicts with other rules.
|
114
114
|
*/
|
115
115
|
function isConflicted(precedingToken, node) {
|
116
|
-
return
|
117
|
-
astUtils.
|
116
|
+
return (
|
117
|
+
astUtils.isArrowToken(precedingToken) ||
|
118
|
+
(
|
119
|
+
astUtils.isKeywordToken(precedingToken) &&
|
120
|
+
!isFunctionBody(node)
|
121
|
+
) ||
|
122
|
+
(
|
123
|
+
astUtils.isColonToken(precedingToken) &&
|
124
|
+
node.parent &&
|
125
|
+
node.parent.type === "SwitchCase" &&
|
126
|
+
precedingToken === astUtils.getSwitchCaseColonToken(node.parent, sourceCode)
|
127
|
+
)
|
128
|
+
);
|
118
129
|
}
|
119
130
|
|
120
131
|
/**
|
package/lib/rules/strict.js
CHANGED
@@ -21,7 +21,6 @@ module.exports = {
|
|
21
21
|
|
22
22
|
docs: {
|
23
23
|
description: "enforce spacing around colons of switch statements",
|
24
|
-
category: "Stylistic Issues",
|
25
24
|
recommended: false,
|
26
25
|
url: "https://eslint.org/docs/rules/switch-colon-spacing"
|
27
26
|
},
|
@@ -51,18 +50,6 @@ module.exports = {
|
|
51
50
|
const beforeSpacing = options.before === true; // false by default
|
52
51
|
const afterSpacing = options.after !== false; // true by default
|
53
52
|
|
54
|
-
/**
|
55
|
-
* Get the colon token of the given SwitchCase node.
|
56
|
-
* @param {ASTNode} node The SwitchCase node to get.
|
57
|
-
* @returns {Token} The colon token of the node.
|
58
|
-
*/
|
59
|
-
function getColonToken(node) {
|
60
|
-
if (node.test) {
|
61
|
-
return sourceCode.getTokenAfter(node.test, astUtils.isColonToken);
|
62
|
-
}
|
63
|
-
return sourceCode.getFirstToken(node, 1);
|
64
|
-
}
|
65
|
-
|
66
53
|
/**
|
67
54
|
* Check whether the spacing between the given 2 tokens is valid or not.
|
68
55
|
* @param {Token} left The left token to check.
|
@@ -115,7 +102,7 @@ module.exports = {
|
|
115
102
|
|
116
103
|
return {
|
117
104
|
SwitchCase(node) {
|
118
|
-
const colonToken =
|
105
|
+
const colonToken = astUtils.getSwitchCaseColonToken(node, sourceCode);
|
119
106
|
const beforeToken = sourceCode.getTokenBefore(colonToken);
|
120
107
|
const afterToken = sourceCode.getTokenAfter(colonToken);
|
121
108
|
|
package/lib/rules/unicode-bom.js
CHANGED
package/lib/rules/use-isnan.js
CHANGED
@@ -756,6 +756,19 @@ function isLogicalAssignmentOperator(operator) {
|
|
756
756
|
return LOGICAL_ASSIGNMENT_OPERATORS.has(operator);
|
757
757
|
}
|
758
758
|
|
759
|
+
/**
|
760
|
+
* Get the colon token of the given SwitchCase node.
|
761
|
+
* @param {ASTNode} node The SwitchCase node to get.
|
762
|
+
* @param {SourceCode} sourceCode The source code object to get tokens.
|
763
|
+
* @returns {Token} The colon token of the node.
|
764
|
+
*/
|
765
|
+
function getSwitchCaseColonToken(node, sourceCode) {
|
766
|
+
if (node.test) {
|
767
|
+
return sourceCode.getTokenAfter(node.test, isColonToken);
|
768
|
+
}
|
769
|
+
return sourceCode.getFirstToken(node, 1);
|
770
|
+
}
|
771
|
+
|
759
772
|
//------------------------------------------------------------------------------
|
760
773
|
// Public Interface
|
761
774
|
//------------------------------------------------------------------------------
|
@@ -858,8 +871,8 @@ module.exports = {
|
|
858
871
|
|
859
872
|
/**
|
860
873
|
* Validate that a string passed in is surrounded by the specified character
|
861
|
-
* @param
|
862
|
-
* @param
|
874
|
+
* @param {string} val The text to check.
|
875
|
+
* @param {string} character The character to see if it's surrounded by.
|
863
876
|
* @returns {boolean} True if the text is surrounded by the character, false if not.
|
864
877
|
* @private
|
865
878
|
*/
|
@@ -875,7 +888,14 @@ module.exports = {
|
|
875
888
|
isDirectiveComment(node) {
|
876
889
|
const comment = node.value.trim();
|
877
890
|
|
878
|
-
return
|
891
|
+
return (
|
892
|
+
node.type === "Line" && comment.indexOf("eslint-") === 0 ||
|
893
|
+
node.type === "Block" && (
|
894
|
+
comment.indexOf("global ") === 0 ||
|
895
|
+
comment.indexOf("eslint ") === 0 ||
|
896
|
+
comment.indexOf("eslint-") === 0
|
897
|
+
)
|
898
|
+
);
|
879
899
|
},
|
880
900
|
|
881
901
|
/**
|
@@ -1288,7 +1308,8 @@ module.exports = {
|
|
1288
1308
|
* 5e1_000 // false
|
1289
1309
|
* 5n // false
|
1290
1310
|
* 1_000n // false
|
1291
|
-
*
|
1311
|
+
* "5" // false
|
1312
|
+
*
|
1292
1313
|
*/
|
1293
1314
|
isDecimalInteger(node) {
|
1294
1315
|
return node.type === "Literal" && typeof node.value === "number" &&
|
@@ -1632,9 +1653,9 @@ module.exports = {
|
|
1632
1653
|
return sourceCode.getText().slice(leftToken.range[0], rightToken.range[1]);
|
1633
1654
|
},
|
1634
1655
|
|
1635
|
-
|
1656
|
+
/**
|
1636
1657
|
* Determine if a node has a possibility to be an Error object
|
1637
|
-
* @param
|
1658
|
+
* @param {ASTNode} node ASTNode to check
|
1638
1659
|
* @returns {boolean} True if there is a chance it contains an Error obj
|
1639
1660
|
*/
|
1640
1661
|
couldBeError(node) {
|
@@ -1864,5 +1885,6 @@ module.exports = {
|
|
1864
1885
|
isSpecificMemberAccess,
|
1865
1886
|
equalLiteralValue,
|
1866
1887
|
isSameReference,
|
1867
|
-
isLogicalAssignmentOperator
|
1888
|
+
isLogicalAssignmentOperator,
|
1889
|
+
getSwitchCaseColonToken
|
1868
1890
|
};
|
@@ -14,10 +14,10 @@ const debug = require("debug")("eslint:rules");
|
|
14
14
|
* const rules = new LazyLoadingRuleMap([
|
15
15
|
* ["eqeqeq", () => require("eqeqeq")],
|
16
16
|
* ["semi", () => require("semi")],
|
17
|
-
* ["no-unused-vars", () => require("no-unused-vars")]
|
18
|
-
* ])
|
17
|
+
* ["no-unused-vars", () => require("no-unused-vars")]
|
18
|
+
* ]);
|
19
19
|
*
|
20
|
-
* rules.get("semi") // call `() => require("semi")` here.
|
20
|
+
* rules.get("semi"); // call `() => require("semi")` here.
|
21
21
|
*
|
22
22
|
* @extends {Map<string, () => Rule>}
|
23
23
|
*/
|
package/lib/rules/valid-jsdoc.js
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* @fileoverview Validates JSDoc comments are syntactically correct
|
3
3
|
* @author Nicholas C. Zakas
|
4
|
+
* @deprecated in ESLint v5.10.0
|
4
5
|
*/
|
5
6
|
"use strict";
|
6
7
|
|
@@ -20,7 +21,6 @@ module.exports = {
|
|
20
21
|
|
21
22
|
docs: {
|
22
23
|
description: "enforce valid JSDoc comments",
|
23
|
-
category: "Possible Errors",
|
24
24
|
recommended: false,
|
25
25
|
url: "https://eslint.org/docs/rules/valid-jsdoc"
|
26
26
|
},
|
package/lib/rules/vars-on-top.js
CHANGED
@@ -15,7 +15,6 @@ module.exports = {
|
|
15
15
|
|
16
16
|
docs: {
|
17
17
|
description: "require `var` declarations be placed at the top of their containing scope",
|
18
|
-
category: "Best Practices",
|
19
18
|
recommended: false,
|
20
19
|
url: "https://eslint.org/docs/rules/vars-on-top"
|
21
20
|
},
|
@@ -32,8 +31,8 @@ module.exports = {
|
|
32
31
|
// Helpers
|
33
32
|
//--------------------------------------------------------------------------
|
34
33
|
|
35
|
-
// eslint-disable-next-line jsdoc/require-description
|
36
34
|
/**
|
35
|
+
* Has AST suggesting a directive.
|
37
36
|
* @param {ASTNode} node any node
|
38
37
|
* @returns {boolean} whether the given node structurally represents a directive
|
39
38
|
*/
|
package/lib/rules/wrap-iife.js
CHANGED
package/lib/rules/wrap-regex.js
CHANGED
package/lib/rules/yoda.js
CHANGED
package/lib/shared/ajv.js
CHANGED
@@ -27,7 +27,7 @@ module.exports = (additionalOptions = {}) => {
|
|
27
27
|
});
|
28
28
|
|
29
29
|
ajv.addMetaSchema(metaSchema);
|
30
|
-
// eslint-disable-next-line no-underscore-dangle
|
30
|
+
// eslint-disable-next-line no-underscore-dangle -- Ajv's API
|
31
31
|
ajv._opts.defaultMeta = metaSchema.id;
|
32
32
|
|
33
33
|
return ajv;
|
@@ -84,6 +84,7 @@ function getRuleOptionsSchema(rule) {
|
|
84
84
|
/**
|
85
85
|
* Validates a rule's severity and returns the severity value. Throws an error if the severity is invalid.
|
86
86
|
* @param {options} options The given options for the rule.
|
87
|
+
* @throws {Error} Wrong severity value.
|
87
88
|
* @returns {number|string} The rule's severity value
|
88
89
|
*/
|
89
90
|
function validateRuleSeverity(options) {
|
@@ -102,6 +103,7 @@ function validateRuleSeverity(options) {
|
|
102
103
|
* Validates the non-severity options passed to a rule, based on its schema.
|
103
104
|
* @param {{create: Function}} rule The rule to validate
|
104
105
|
* @param {Array} localOptions The options for the rule, excluding severity
|
106
|
+
* @throws {Error} Any rule validation errors.
|
105
107
|
* @returns {void}
|
106
108
|
*/
|
107
109
|
function validateRuleSchema(rule, localOptions) {
|
@@ -132,6 +134,7 @@ function validateRuleSchema(rule, localOptions) {
|
|
132
134
|
* @param {Array|number} options The given options for the rule.
|
133
135
|
* @param {string|null} source The name of the configuration source to report in any errors. If null or undefined,
|
134
136
|
* no source is prepended to the message.
|
137
|
+
* @throws {Error} Upon any bad rule configuration.
|
135
138
|
* @returns {void}
|
136
139
|
*/
|
137
140
|
function validateRuleOptions(rule, ruleId, options, source = null) {
|
@@ -156,7 +159,7 @@ function validateRuleOptions(rule, ruleId, options, source = null) {
|
|
156
159
|
* Validates an environment object
|
157
160
|
* @param {Object} environment The environment config object to validate.
|
158
161
|
* @param {string} source The name of the configuration source to report in any errors.
|
159
|
-
* @param {
|
162
|
+
* @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded environments.
|
160
163
|
* @returns {void}
|
161
164
|
*/
|
162
165
|
function validateEnvironment(
|
@@ -185,7 +188,7 @@ function validateEnvironment(
|
|
185
188
|
* Validates a rules config object
|
186
189
|
* @param {Object} rulesConfig The rules config object to validate.
|
187
190
|
* @param {string} source The name of the configuration source to report in any errors.
|
188
|
-
* @param {
|
191
|
+
* @param {(ruleId:string) => Object} getAdditionalRule A map from strings to loaded rules
|
189
192
|
* @returns {void}
|
190
193
|
*/
|
191
194
|
function validateRules(
|
@@ -229,7 +232,8 @@ function validateGlobals(globalsConfig, source = null) {
|
|
229
232
|
* Validate `processor` configuration.
|
230
233
|
* @param {string|undefined} processorName The processor name.
|
231
234
|
* @param {string} source The name of config file.
|
232
|
-
* @param {
|
235
|
+
* @param {(id:string) => Processor} getProcessor The getter of defined processors.
|
236
|
+
* @throws {Error} For invalid processor configuration.
|
233
237
|
* @returns {void}
|
234
238
|
*/
|
235
239
|
function validateProcessor(processorName, source, getProcessor) {
|
@@ -268,6 +272,7 @@ function formatErrors(errors) {
|
|
268
272
|
* Validates the top level properties of the config object.
|
269
273
|
* @param {Object} config The config object to validate.
|
270
274
|
* @param {string} source The name of the configuration source to report in any errors.
|
275
|
+
* @throws {Error} For any config invalid per the schema.
|
271
276
|
* @returns {void}
|
272
277
|
*/
|
273
278
|
function validateConfigSchema(config, source = null) {
|
@@ -286,8 +291,8 @@ function validateConfigSchema(config, source = null) {
|
|
286
291
|
* Validates an entire config object.
|
287
292
|
* @param {Object} config The config object to validate.
|
288
293
|
* @param {string} source The name of the configuration source to report in any errors.
|
289
|
-
* @param {
|
290
|
-
* @param {
|
294
|
+
* @param {(ruleId:string) => Object} [getAdditionalRule] A map from strings to loaded rules.
|
295
|
+
* @param {(envId:string) => Object} [getAdditionalEnv] A map from strings to loaded envs.
|
291
296
|
* @returns {void}
|
292
297
|
*/
|
293
298
|
function validate(config, source, getAdditionalRule, getAdditionalEnv) {
|
package/lib/shared/logging.js
CHANGED
@@ -26,6 +26,7 @@ module.exports = {
|
|
26
26
|
* @param {string} moduleName The name of a Node module, or a path to a Node module.
|
27
27
|
* @param {string} relativeToPath An absolute path indicating the module that `moduleName` should be resolved relative to. This must be
|
28
28
|
* a file rather than a directory, but the file need not actually exist.
|
29
|
+
* @throws {Error} Any error from `module.createRequire` or its `resolve`.
|
29
30
|
* @returns {string} The absolute path that would result from calling `require.resolve(moduleName)` in a file located at `relativeToPath`
|
30
31
|
*/
|
31
32
|
resolve(moduleName, relativeToPath) {
|
@@ -40,6 +40,7 @@ function environment() {
|
|
40
40
|
* Synchronously executes a shell command and formats the result.
|
41
41
|
* @param {string} cmd The command to execute.
|
42
42
|
* @param {Array} args The arguments to be executed with the command.
|
43
|
+
* @throws {Error} As may be collected by `cross-spawn.sync`.
|
43
44
|
* @returns {string} The version returned by the command.
|
44
45
|
*/
|
45
46
|
function execCommand(cmd, args) {
|
@@ -73,6 +74,7 @@ function environment() {
|
|
73
74
|
/**
|
74
75
|
* Gets bin version.
|
75
76
|
* @param {string} bin The bin to check.
|
77
|
+
* @throws {Error} As may be collected by `cross-spawn.sync`.
|
76
78
|
* @returns {string} The normalized version returned by the command.
|
77
79
|
*/
|
78
80
|
function getBinVersion(bin) {
|
@@ -90,6 +92,7 @@ function environment() {
|
|
90
92
|
* Gets installed npm package version.
|
91
93
|
* @param {string} pkg The package to check.
|
92
94
|
* @param {boolean} global Whether to check globally or not.
|
95
|
+
* @throws {Error} As may be collected by `cross-spawn.sync`.
|
93
96
|
* @returns {string} The normalized version returned by the command.
|
94
97
|
*/
|
95
98
|
function getNpmPackageVersion(pkg, { global = false } = {}) {
|
package/lib/shared/traverser.js
CHANGED
@@ -65,16 +65,16 @@ class Traverser {
|
|
65
65
|
this._leave = null;
|
66
66
|
}
|
67
67
|
|
68
|
-
// eslint-disable-next-line jsdoc/require-description
|
69
68
|
/**
|
69
|
+
* Gives current node.
|
70
70
|
* @returns {ASTNode} The current node.
|
71
71
|
*/
|
72
72
|
current() {
|
73
73
|
return this._current;
|
74
74
|
}
|
75
75
|
|
76
|
-
// eslint-disable-next-line jsdoc/require-description
|
77
76
|
/**
|
77
|
+
* Gives a a copy of the ancestor nodes.
|
78
78
|
* @returns {ASTNode[]} The ancestor nodes.
|
79
79
|
*/
|
80
80
|
parents() {
|
package/lib/shared/types.js
CHANGED
@@ -83,12 +83,12 @@ module.exports = {};
|
|
83
83
|
|
84
84
|
/**
|
85
85
|
* @typedef {Object} LintMessage
|
86
|
-
* @property {number} column The 1-based column number.
|
86
|
+
* @property {number|undefined} column The 1-based column number.
|
87
87
|
* @property {number} [endColumn] The 1-based column number of the end location.
|
88
88
|
* @property {number} [endLine] The 1-based line number of the end location.
|
89
89
|
* @property {boolean} fatal If `true` then this is a fatal error.
|
90
90
|
* @property {{range:[number,number], text:string}} [fix] Information for autofix.
|
91
|
-
* @property {number} line The 1-based line number.
|
91
|
+
* @property {number|undefined} line The 1-based line number.
|
92
92
|
* @property {string} message The error message.
|
93
93
|
* @property {string|null} ruleId The ID of the rule which makes this message.
|
94
94
|
* @property {0|1|2} severity The severity of this message.
|
@@ -143,10 +143,12 @@ function isSpaceBetween(sourceCode, first, second, checkInsideOfJSXText) {
|
|
143
143
|
// Public Interface
|
144
144
|
//------------------------------------------------------------------------------
|
145
145
|
|
146
|
+
/**
|
147
|
+
* Represents parsed source code.
|
148
|
+
*/
|
146
149
|
class SourceCode extends TokenStore {
|
147
150
|
|
148
151
|
/**
|
149
|
-
* Represents parsed source code.
|
150
152
|
* @param {string|Object} textOrConfig The source code text or config object.
|
151
153
|
* @param {string} textOrConfig.text The source code text.
|
152
154
|
* @param {ASTNode} textOrConfig.ast The Program node of the AST representing the code. This AST should be created from the text that BOM was stripped.
|
@@ -175,20 +177,20 @@ class SourceCode extends TokenStore {
|
|
175
177
|
|
176
178
|
/**
|
177
179
|
* The flag to indicate that the source code has Unicode BOM.
|
178
|
-
* @type boolean
|
180
|
+
* @type {boolean}
|
179
181
|
*/
|
180
182
|
this.hasBOM = (text.charCodeAt(0) === 0xFEFF);
|
181
183
|
|
182
184
|
/**
|
183
185
|
* The original text source code.
|
184
186
|
* BOM was stripped from this text.
|
185
|
-
* @type string
|
187
|
+
* @type {string}
|
186
188
|
*/
|
187
189
|
this.text = (this.hasBOM ? text.slice(1) : text);
|
188
190
|
|
189
191
|
/**
|
190
192
|
* The parsed AST for the source code.
|
191
|
-
* @type ASTNode
|
193
|
+
* @type {ASTNode}
|
192
194
|
*/
|
193
195
|
this.ast = ast;
|
194
196
|
|
@@ -223,7 +225,7 @@ class SourceCode extends TokenStore {
|
|
223
225
|
/**
|
224
226
|
* The source code split into lines according to ECMA-262 specification.
|
225
227
|
* This is done to avoid each rule needing to do so separately.
|
226
|
-
* @type string[]
|
228
|
+
* @type {string[]}
|
227
229
|
*/
|
228
230
|
this.lines = [];
|
229
231
|
this.lineStartIndices = [0];
|
@@ -506,6 +508,7 @@ class SourceCode extends TokenStore {
|
|
506
508
|
/**
|
507
509
|
* Converts a source text index into a (line, column) pair.
|
508
510
|
* @param {number} index The index of a character in a file
|
511
|
+
* @throws {TypeError} If non-numeric index or index out of range.
|
509
512
|
* @returns {Object} A {line, column} location object with a 0-indexed column
|
510
513
|
* @public
|
511
514
|
*/
|
@@ -545,6 +548,9 @@ class SourceCode extends TokenStore {
|
|
545
548
|
* @param {Object} loc A line/column location
|
546
549
|
* @param {number} loc.line The line number of the location (1-indexed)
|
547
550
|
* @param {number} loc.column The column number of the location (0-indexed)
|
551
|
+
* @throws {TypeError|RangeError} If `loc` is not an object with a numeric
|
552
|
+
* `line` and `column`, if the `line` is less than or equal to zero or
|
553
|
+
* the line or column is out of the expected range.
|
548
554
|
* @returns {number} The range index of the location in the file.
|
549
555
|
* @public
|
550
556
|
*/
|
@@ -70,7 +70,7 @@ module.exports = class Cursor {
|
|
70
70
|
* @abstract
|
71
71
|
*/
|
72
72
|
/* istanbul ignore next */
|
73
|
-
moveNext() { // eslint-disable-line class-methods-use-this
|
73
|
+
moveNext() { // eslint-disable-line class-methods-use-this -- Unused
|
74
74
|
throw new Error("Not implemented.");
|
75
75
|
}
|
76
76
|
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "8.0.0
|
3
|
+
"version": "8.0.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -23,7 +23,6 @@
|
|
23
23
|
"generate-betarelease": "node Makefile.js generatePrerelease -- beta",
|
24
24
|
"generate-rcrelease": "node Makefile.js generatePrerelease -- rc",
|
25
25
|
"publish-release": "node Makefile.js publishRelease",
|
26
|
-
"docs": "node Makefile.js docs",
|
27
26
|
"gensite": "node Makefile.js gensite",
|
28
27
|
"webpack": "node Makefile.js webpack",
|
29
28
|
"perf": "node Makefile.js perf"
|
@@ -48,7 +47,7 @@
|
|
48
47
|
"homepage": "https://eslint.org",
|
49
48
|
"bugs": "https://github.com/eslint/eslint/issues/",
|
50
49
|
"dependencies": {
|
51
|
-
"@eslint/eslintrc": "^1.0.
|
50
|
+
"@eslint/eslintrc": "^1.0.2",
|
52
51
|
"@humanwhocodes/config-array": "^0.6.0",
|
53
52
|
"ajv": "^6.10.0",
|
54
53
|
"chalk": "^4.0.0",
|
@@ -60,7 +59,7 @@
|
|
60
59
|
"eslint-scope": "^6.0.0",
|
61
60
|
"eslint-utils": "^3.0.0",
|
62
61
|
"eslint-visitor-keys": "^3.0.0",
|
63
|
-
"espree": "^
|
62
|
+
"espree": "^9.0.0",
|
64
63
|
"esquery": "^1.4.0",
|
65
64
|
"esutils": "^2.0.2",
|
66
65
|
"fast-deep-equal": "^3.1.3",
|
@@ -99,9 +98,10 @@
|
|
99
98
|
"ejs": "^3.0.2",
|
100
99
|
"eslint": "file:.",
|
101
100
|
"eslint-config-eslint": "file:packages/eslint-config-eslint",
|
101
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
102
102
|
"eslint-plugin-eslint-plugin": "^3.5.3",
|
103
103
|
"eslint-plugin-internal-rules": "file:tools/internal-rules",
|
104
|
-
"eslint-plugin-jsdoc": "^
|
104
|
+
"eslint-plugin-jsdoc": "^36.0.6",
|
105
105
|
"eslint-plugin-node": "^11.1.0",
|
106
106
|
"eslint-release": "^3.1.2",
|
107
107
|
"eslump": "^3.0.0",
|