eslint 8.39.0 → 8.47.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 +10 -4
- package/conf/globals.js +6 -1
- package/lib/cli-engine/cli-engine.js +30 -19
- package/lib/cli.js +2 -28
- package/lib/config/default-config.js +1 -1
- package/lib/config/flat-config-schema.js +127 -35
- package/lib/eslint/eslint-helpers.js +11 -10
- package/lib/eslint/eslint.js +1 -1
- package/lib/eslint/flat-eslint.js +119 -161
- package/lib/linter/apply-disable-directives.js +11 -1
- package/lib/linter/code-path-analysis/debug-helpers.js +1 -1
- package/lib/linter/config-comment-parser.js +9 -2
- package/lib/linter/linter.js +20 -11
- package/lib/linter/report-translator.js +22 -21
- package/lib/rule-tester/flat-rule-tester.js +1 -2
- package/lib/rule-tester/rule-tester.js +1 -2
- package/lib/rules/accessor-pairs.js +35 -43
- package/lib/rules/array-bracket-newline.js +2 -2
- package/lib/rules/array-bracket-spacing.js +2 -2
- package/lib/rules/array-callback-return.js +2 -2
- package/lib/rules/array-element-newline.js +12 -6
- package/lib/rules/arrow-body-style.js +2 -2
- package/lib/rules/arrow-parens.js +2 -2
- package/lib/rules/arrow-spacing.js +2 -2
- package/lib/rules/block-scoped-var.js +17 -7
- package/lib/rules/block-spacing.js +2 -2
- package/lib/rules/brace-style.js +2 -2
- package/lib/rules/callback-return.js +2 -2
- package/lib/rules/camelcase.js +2 -2
- package/lib/rules/capitalized-comments.js +2 -2
- package/lib/rules/class-methods-use-this.js +2 -2
- package/lib/rules/comma-dangle.js +2 -2
- package/lib/rules/comma-spacing.js +2 -2
- package/lib/rules/comma-style.js +2 -2
- package/lib/rules/complexity.js +1 -1
- package/lib/rules/computed-property-spacing.js +2 -2
- package/lib/rules/consistent-return.js +3 -3
- package/lib/rules/consistent-this.js +2 -2
- package/lib/rules/constructor-super.js +1 -1
- package/lib/rules/curly.js +2 -2
- package/lib/rules/default-case-last.js +1 -1
- package/lib/rules/default-case.js +2 -2
- package/lib/rules/default-param-last.js +1 -1
- package/lib/rules/dot-location.js +2 -2
- package/lib/rules/dot-notation.js +3 -4
- package/lib/rules/eol-last.js +2 -2
- package/lib/rules/eqeqeq.js +2 -2
- package/lib/rules/for-direction.js +1 -1
- package/lib/rules/func-call-spacing.js +2 -2
- package/lib/rules/func-name-matching.js +1 -1
- package/lib/rules/func-names.js +2 -2
- package/lib/rules/func-style.js +1 -1
- package/lib/rules/function-call-argument-newline.js +2 -2
- package/lib/rules/function-paren-newline.js +2 -2
- package/lib/rules/generator-star-spacing.js +2 -2
- package/lib/rules/getter-return.js +2 -2
- package/lib/rules/global-require.js +2 -2
- package/lib/rules/grouped-accessor-pairs.js +35 -44
- package/lib/rules/guard-for-in.js +1 -1
- package/lib/rules/handle-callback-err.js +2 -2
- package/lib/rules/id-blacklist.js +2 -2
- package/lib/rules/id-denylist.js +2 -2
- package/lib/rules/id-length.js +3 -36
- package/lib/rules/id-match.js +2 -2
- package/lib/rules/implicit-arrow-linebreak.js +2 -2
- package/lib/rules/indent-legacy.js +2 -2
- package/lib/rules/indent.js +84 -88
- package/lib/rules/init-declarations.js +1 -1
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/key-spacing.js +4 -10
- package/lib/rules/keyword-spacing.js +2 -2
- package/lib/rules/line-comment-position.js +2 -2
- package/lib/rules/linebreak-style.js +2 -2
- package/lib/rules/lines-around-comment.js +2 -2
- package/lib/rules/lines-around-directive.js +2 -2
- package/lib/rules/lines-between-class-members.js +2 -2
- package/lib/rules/logical-assignment-operators.js +7 -5
- package/lib/rules/max-classes-per-file.js +1 -1
- package/lib/rules/max-depth.js +1 -1
- package/lib/rules/max-len.js +19 -15
- package/lib/rules/max-lines-per-function.js +2 -2
- package/lib/rules/max-lines.js +2 -2
- package/lib/rules/max-nested-callbacks.js +1 -1
- package/lib/rules/max-params.js +2 -2
- package/lib/rules/max-statements-per-line.js +2 -2
- package/lib/rules/max-statements.js +1 -1
- package/lib/rules/multiline-comment-style.js +2 -2
- package/lib/rules/multiline-ternary.js +2 -2
- package/lib/rules/new-cap.js +2 -2
- package/lib/rules/new-parens.js +2 -2
- package/lib/rules/newline-after-var.js +2 -4
- package/lib/rules/newline-before-return.js +2 -2
- package/lib/rules/newline-per-chained-call.js +2 -2
- package/lib/rules/no-alert.js +2 -2
- package/lib/rules/no-array-constructor.js +1 -1
- package/lib/rules/no-async-promise-executor.js +2 -2
- package/lib/rules/no-await-in-loop.js +1 -1
- package/lib/rules/no-bitwise.js +1 -1
- package/lib/rules/no-buffer-constructor.js +1 -1
- package/lib/rules/no-caller.js +1 -1
- package/lib/rules/no-case-declarations.js +1 -1
- package/lib/rules/no-catch-shadow.js +2 -2
- package/lib/rules/no-class-assign.js +2 -2
- package/lib/rules/no-compare-neg-zero.js +1 -1
- package/lib/rules/no-cond-assign.js +2 -2
- package/lib/rules/no-confusing-arrow.js +2 -2
- package/lib/rules/no-console.js +2 -2
- package/lib/rules/no-const-assign.js +2 -2
- package/lib/rules/no-constant-binary-expression.js +2 -2
- package/lib/rules/no-constant-condition.js +2 -2
- package/lib/rules/no-constructor-return.js +1 -1
- package/lib/rules/no-continue.js +1 -1
- package/lib/rules/no-control-regex.js +16 -3
- package/lib/rules/no-debugger.js +1 -1
- package/lib/rules/no-delete-var.js +1 -1
- package/lib/rules/no-div-regex.js +2 -2
- package/lib/rules/no-dupe-args.js +2 -2
- package/lib/rules/no-dupe-class-members.js +1 -1
- package/lib/rules/no-dupe-else-if.js +2 -2
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-duplicate-case.js +2 -2
- package/lib/rules/no-duplicate-imports.js +1 -1
- package/lib/rules/no-else-return.js +2 -2
- package/lib/rules/no-empty-character-class.js +34 -13
- package/lib/rules/no-empty-function.js +2 -2
- package/lib/rules/no-empty-pattern.js +39 -4
- package/lib/rules/no-empty-static-block.js +2 -2
- package/lib/rules/no-empty.js +2 -2
- package/lib/rules/no-eq-null.js +1 -1
- package/lib/rules/no-eval.js +2 -2
- package/lib/rules/no-ex-assign.js +2 -2
- package/lib/rules/no-extend-native.js +2 -2
- package/lib/rules/no-extra-bind.js +2 -2
- package/lib/rules/no-extra-boolean-cast.js +2 -2
- package/lib/rules/no-extra-label.js +2 -2
- package/lib/rules/no-extra-parens.js +48 -12
- package/lib/rules/no-extra-semi.js +31 -13
- package/lib/rules/no-fallthrough.js +3 -3
- package/lib/rules/no-floating-decimal.js +2 -2
- package/lib/rules/no-func-assign.js +2 -2
- package/lib/rules/no-global-assign.js +2 -2
- package/lib/rules/no-implicit-coercion.js +2 -2
- package/lib/rules/no-implicit-globals.js +2 -2
- package/lib/rules/no-implied-eval.js +2 -2
- package/lib/rules/no-import-assign.js +2 -2
- package/lib/rules/no-inline-comments.js +2 -2
- package/lib/rules/no-inner-declarations.js +1 -1
- package/lib/rules/no-invalid-regexp.js +23 -8
- package/lib/rules/no-invalid-this.js +2 -2
- package/lib/rules/no-irregular-whitespace.js +23 -6
- package/lib/rules/no-iterator.js +1 -1
- package/lib/rules/no-label-var.js +2 -2
- package/lib/rules/no-labels.js +1 -1
- package/lib/rules/no-lone-blocks.js +2 -2
- package/lib/rules/no-lonely-if.js +2 -2
- package/lib/rules/no-loop-func.js +3 -3
- package/lib/rules/no-loss-of-precision.js +15 -7
- package/lib/rules/no-magic-numbers.js +1 -1
- package/lib/rules/no-misleading-character-class.js +10 -4
- package/lib/rules/no-mixed-operators.js +2 -2
- package/lib/rules/no-mixed-requires.js +1 -1
- package/lib/rules/no-mixed-spaces-and-tabs.js +2 -2
- package/lib/rules/no-multi-assign.js +1 -1
- package/lib/rules/no-multi-spaces.js +2 -2
- package/lib/rules/no-multi-str.js +1 -1
- package/lib/rules/no-multiple-empty-lines.js +2 -2
- package/lib/rules/no-native-reassign.js +2 -2
- package/lib/rules/no-negated-condition.js +1 -1
- package/lib/rules/no-negated-in-lhs.js +1 -1
- package/lib/rules/no-nested-ternary.js +1 -1
- package/lib/rules/no-new-func.js +2 -2
- package/lib/rules/no-new-native-nonconstructor.js +2 -2
- package/lib/rules/no-new-object.js +2 -2
- package/lib/rules/no-new-require.js +1 -1
- package/lib/rules/no-new-symbol.js +2 -2
- package/lib/rules/no-new-wrappers.js +20 -8
- package/lib/rules/no-new.js +1 -1
- package/lib/rules/no-nonoctal-decimal-escape.js +2 -2
- package/lib/rules/no-obj-calls.js +2 -2
- package/lib/rules/no-octal-escape.js +1 -1
- package/lib/rules/no-octal.js +1 -1
- package/lib/rules/no-param-reassign.js +2 -2
- package/lib/rules/no-path-concat.js +1 -1
- package/lib/rules/no-plusplus.js +1 -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 +2 -2
- package/lib/rules/no-proto.js +1 -1
- package/lib/rules/no-prototype-builtins.js +1 -1
- package/lib/rules/no-redeclare.js +2 -2
- package/lib/rules/no-regex-spaces.js +20 -5
- package/lib/rules/no-restricted-exports.js +2 -2
- package/lib/rules/no-restricted-globals.js +2 -2
- package/lib/rules/no-restricted-imports.js +2 -2
- package/lib/rules/no-restricted-modules.js +8 -11
- package/lib/rules/no-restricted-properties.js +1 -1
- package/lib/rules/no-restricted-syntax.js +1 -1
- package/lib/rules/no-return-assign.js +2 -2
- package/lib/rules/no-return-await.js +8 -3
- package/lib/rules/no-script-url.js +1 -1
- package/lib/rules/no-self-assign.js +2 -2
- package/lib/rules/no-self-compare.js +2 -2
- package/lib/rules/no-sequences.js +2 -2
- package/lib/rules/no-setter-return.js +2 -2
- package/lib/rules/no-shadow-restricted-names.js +2 -2
- package/lib/rules/no-shadow.js +2 -2
- package/lib/rules/no-spaced-func.js +2 -2
- package/lib/rules/no-sparse-arrays.js +1 -1
- package/lib/rules/no-sync.js +1 -1
- package/lib/rules/no-tabs.js +2 -2
- package/lib/rules/no-template-curly-in-string.js +1 -1
- package/lib/rules/no-ternary.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 +2 -2
- package/lib/rules/no-undef-init.js +2 -2
- package/lib/rules/no-undef.js +2 -2
- package/lib/rules/no-undefined.js +2 -2
- package/lib/rules/no-underscore-dangle.js +2 -2
- package/lib/rules/no-unexpected-multiline.js +2 -2
- package/lib/rules/no-unmodified-loop-condition.js +2 -2
- package/lib/rules/no-unneeded-ternary.js +2 -2
- package/lib/rules/no-unreachable-loop.js +1 -1
- package/lib/rules/no-unreachable.js +2 -2
- package/lib/rules/no-unsafe-finally.js +1 -1
- package/lib/rules/no-unsafe-negation.js +2 -2
- package/lib/rules/no-unsafe-optional-chaining.js +1 -1
- package/lib/rules/no-unused-expressions.js +4 -6
- package/lib/rules/no-unused-labels.js +48 -15
- package/lib/rules/no-unused-private-class-members.js +1 -1
- package/lib/rules/no-unused-vars.js +4 -3
- package/lib/rules/no-use-before-define.js +2 -2
- package/lib/rules/no-useless-backreference.js +3 -3
- package/lib/rules/no-useless-call.js +2 -2
- package/lib/rules/no-useless-catch.js +1 -1
- package/lib/rules/no-useless-computed-key.js +2 -2
- package/lib/rules/no-useless-concat.js +2 -2
- package/lib/rules/no-useless-constructor.js +1 -1
- package/lib/rules/no-useless-escape.js +162 -83
- package/lib/rules/no-useless-rename.js +2 -2
- package/lib/rules/no-useless-return.js +37 -9
- package/lib/rules/no-var.js +2 -2
- package/lib/rules/no-void.js +1 -1
- package/lib/rules/no-warning-comments.js +2 -2
- package/lib/rules/no-whitespace-before-property.js +2 -2
- package/lib/rules/no-with.js +1 -1
- package/lib/rules/nonblock-statement-body-position.js +2 -2
- package/lib/rules/object-curly-newline.js +2 -2
- package/lib/rules/object-curly-spacing.js +4 -4
- package/lib/rules/object-property-newline.js +2 -2
- package/lib/rules/object-shorthand.js +2 -2
- package/lib/rules/one-var-declaration-per-line.js +1 -1
- package/lib/rules/one-var.js +2 -2
- package/lib/rules/operator-assignment.js +2 -2
- package/lib/rules/operator-linebreak.js +2 -2
- package/lib/rules/padded-blocks.js +2 -2
- package/lib/rules/padding-line-between-statements.js +8 -53
- package/lib/rules/prefer-arrow-callback.js +2 -2
- package/lib/rules/prefer-const.js +2 -2
- package/lib/rules/prefer-destructuring.js +2 -2
- package/lib/rules/prefer-exponentiation-operator.js +4 -3
- package/lib/rules/prefer-named-capture-group.js +10 -7
- package/lib/rules/prefer-numeric-literals.js +2 -2
- package/lib/rules/prefer-object-has-own.js +2 -2
- package/lib/rules/prefer-object-spread.js +2 -2
- package/lib/rules/prefer-promise-reject-errors.js +2 -2
- package/lib/rules/prefer-reflect.js +1 -1
- package/lib/rules/prefer-regex-literals.js +14 -17
- package/lib/rules/prefer-rest-params.js +2 -2
- package/lib/rules/prefer-spread.js +2 -2
- package/lib/rules/prefer-template.js +2 -2
- package/lib/rules/quote-props.js +2 -2
- package/lib/rules/quotes.js +16 -16
- package/lib/rules/radix.js +2 -2
- package/lib/rules/require-atomic-updates.js +2 -2
- package/lib/rules/require-await.js +2 -2
- package/lib/rules/require-jsdoc.js +2 -2
- package/lib/rules/require-unicode-regexp.js +5 -5
- package/lib/rules/require-yield.js +1 -1
- package/lib/rules/rest-spread-spacing.js +2 -2
- package/lib/rules/semi-spacing.js +2 -2
- package/lib/rules/semi-style.js +2 -2
- package/lib/rules/semi.js +30 -5
- package/lib/rules/sort-imports.js +2 -2
- package/lib/rules/sort-keys.js +2 -2
- package/lib/rules/sort-vars.js +2 -2
- package/lib/rules/space-before-blocks.js +2 -2
- package/lib/rules/space-before-function-paren.js +2 -2
- package/lib/rules/space-in-parens.js +2 -2
- package/lib/rules/space-infix-ops.js +2 -2
- package/lib/rules/space-unary-ops.js +2 -2
- package/lib/rules/spaced-comment.js +2 -2
- package/lib/rules/strict.js +1 -1
- package/lib/rules/switch-colon-spacing.js +2 -2
- package/lib/rules/symbol-description.js +2 -2
- package/lib/rules/template-curly-spacing.js +2 -2
- package/lib/rules/template-tag-spacing.js +2 -2
- package/lib/rules/unicode-bom.js +2 -2
- package/lib/rules/use-isnan.js +1 -1
- package/lib/rules/utils/ast-utils.js +55 -7
- package/lib/rules/utils/regular-expressions.js +2 -2
- package/lib/rules/valid-jsdoc.js +2 -2
- package/lib/rules/valid-typeof.js +9 -3
- package/lib/rules/vars-on-top.js +1 -1
- package/lib/rules/wrap-iife.js +2 -2
- package/lib/rules/wrap-regex.js +2 -2
- package/lib/rules/yield-star-spacing.js +2 -2
- package/lib/rules/yoda.js +4 -13
- package/lib/shared/string-utils.js +39 -1
- package/lib/shared/types.js +7 -3
- package/lib/unsupported-api.js +5 -2
- package/messages/eslintrc-incompat.js +98 -0
- package/messages/eslintrc-plugins.js +24 -0
- package/messages/invalid-rule-options.js +17 -0
- package/messages/invalid-rule-severity.js +13 -0
- package/messages/shared.js +18 -0
- package/package.json +15 -19
package/lib/rules/no-shadow.js
CHANGED
@@ -32,7 +32,7 @@ module.exports = {
|
|
32
32
|
docs: {
|
33
33
|
description: "Disallow variable declarations from shadowing variables declared in the outer scope",
|
34
34
|
recommended: false,
|
35
|
-
url: "https://eslint.org/docs/rules/no-shadow"
|
35
|
+
url: "https://eslint.org/docs/latest/rules/no-shadow"
|
36
36
|
},
|
37
37
|
|
38
38
|
schema: [
|
@@ -67,7 +67,7 @@ module.exports = {
|
|
67
67
|
allow: (context.options[0] && context.options[0].allow) || [],
|
68
68
|
ignoreOnInitialization: context.options[0] && context.options[0].ignoreOnInitialization
|
69
69
|
};
|
70
|
-
const sourceCode = context.
|
70
|
+
const sourceCode = context.sourceCode;
|
71
71
|
|
72
72
|
/**
|
73
73
|
* Checks whether or not a given location is inside of the range of a given node.
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Disallow spacing between function identifiers and their applications (deprecated)",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/no-spaced-func"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/no-spaced-func"
|
22
22
|
},
|
23
23
|
|
24
24
|
deprecated: true,
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
35
35
|
|
36
36
|
create(context) {
|
37
37
|
|
38
|
-
const sourceCode = context.
|
38
|
+
const sourceCode = context.sourceCode;
|
39
39
|
|
40
40
|
/**
|
41
41
|
* Check if open space is present in a function name
|
package/lib/rules/no-sync.js
CHANGED
package/lib/rules/no-tabs.js
CHANGED
@@ -24,7 +24,7 @@ module.exports = {
|
|
24
24
|
docs: {
|
25
25
|
description: "Disallow all tabs",
|
26
26
|
recommended: false,
|
27
|
-
url: "https://eslint.org/docs/rules/no-tabs"
|
27
|
+
url: "https://eslint.org/docs/latest/rules/no-tabs"
|
28
28
|
},
|
29
29
|
schema: [{
|
30
30
|
type: "object",
|
@@ -43,7 +43,7 @@ module.exports = {
|
|
43
43
|
},
|
44
44
|
|
45
45
|
create(context) {
|
46
|
-
const sourceCode = context.
|
46
|
+
const sourceCode = context.sourceCode;
|
47
47
|
const allowIndentationTabs = context.options && context.options[0] && context.options[0].allowIndentationTabs;
|
48
48
|
|
49
49
|
return {
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Disallow template literal placeholder syntax in regular strings",
|
18
18
|
recommended: false,
|
19
|
-
url: "https://eslint.org/docs/rules/no-template-curly-in-string"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/no-template-curly-in-string"
|
20
20
|
},
|
21
21
|
|
22
22
|
schema: [],
|
package/lib/rules/no-ternary.js
CHANGED
@@ -42,7 +42,7 @@ module.exports = {
|
|
42
42
|
docs: {
|
43
43
|
description: "Disallow `this`/`super` before calling `super()` in constructors",
|
44
44
|
recommended: true,
|
45
|
-
url: "https://eslint.org/docs/rules/no-this-before-super"
|
45
|
+
url: "https://eslint.org/docs/latest/rules/no-this-before-super"
|
46
46
|
},
|
47
47
|
|
48
48
|
schema: [],
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Disallow trailing whitespace at the end of lines",
|
24
24
|
recommended: false,
|
25
|
-
url: "https://eslint.org/docs/rules/no-trailing-spaces"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/no-trailing-spaces"
|
26
26
|
},
|
27
27
|
|
28
28
|
fixable: "whitespace",
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
50
50
|
},
|
51
51
|
|
52
52
|
create(context) {
|
53
|
-
const sourceCode = context.
|
53
|
+
const sourceCode = context.sourceCode;
|
54
54
|
|
55
55
|
const BLANK_CLASS = "[ \t\u00a0\u2000-\u200b\u3000]",
|
56
56
|
SKIP_BLANK = `^${BLANK_CLASS}*$`,
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
19
19
|
docs: {
|
20
20
|
description: "Disallow initializing variables to `undefined`",
|
21
21
|
recommended: false,
|
22
|
-
url: "https://eslint.org/docs/rules/no-undef-init"
|
22
|
+
url: "https://eslint.org/docs/latest/rules/no-undef-init"
|
23
23
|
},
|
24
24
|
|
25
25
|
schema: [],
|
@@ -32,7 +32,7 @@ module.exports = {
|
|
32
32
|
|
33
33
|
create(context) {
|
34
34
|
|
35
|
-
const sourceCode = context.
|
35
|
+
const sourceCode = context.sourceCode;
|
36
36
|
|
37
37
|
return {
|
38
38
|
|
package/lib/rules/no-undef.js
CHANGED
@@ -31,7 +31,7 @@ module.exports = {
|
|
31
31
|
docs: {
|
32
32
|
description: "Disallow the use of undeclared variables unless mentioned in `/*global */` comments",
|
33
33
|
recommended: true,
|
34
|
-
url: "https://eslint.org/docs/rules/no-undef"
|
34
|
+
url: "https://eslint.org/docs/latest/rules/no-undef"
|
35
35
|
},
|
36
36
|
|
37
37
|
schema: [
|
@@ -54,7 +54,7 @@ module.exports = {
|
|
54
54
|
create(context) {
|
55
55
|
const options = context.options[0];
|
56
56
|
const considerTypeOf = options && options.typeof === true || false;
|
57
|
-
const sourceCode = context.
|
57
|
+
const sourceCode = context.sourceCode;
|
58
58
|
|
59
59
|
return {
|
60
60
|
"Program:exit"(node) {
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Disallow the use of `undefined` as an identifier",
|
18
18
|
recommended: false,
|
19
|
-
url: "https://eslint.org/docs/rules/no-undefined"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/no-undefined"
|
20
20
|
},
|
21
21
|
|
22
22
|
schema: [],
|
@@ -28,7 +28,7 @@ module.exports = {
|
|
28
28
|
|
29
29
|
create(context) {
|
30
30
|
|
31
|
-
const sourceCode = context.
|
31
|
+
const sourceCode = context.sourceCode;
|
32
32
|
|
33
33
|
/**
|
34
34
|
* Report an invalid "undefined" identifier node.
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Disallow dangling underscores in identifiers",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/no-underscore-dangle"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/no-underscore-dangle"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [
|
@@ -84,7 +84,7 @@ module.exports = {
|
|
84
84
|
const allowFunctionParams = typeof options.allowFunctionParams !== "undefined" ? options.allowFunctionParams : true;
|
85
85
|
const allowInArrayDestructuring = typeof options.allowInArrayDestructuring !== "undefined" ? options.allowInArrayDestructuring : true;
|
86
86
|
const allowInObjectDestructuring = typeof options.allowInObjectDestructuring !== "undefined" ? options.allowInObjectDestructuring : true;
|
87
|
-
const sourceCode = context.
|
87
|
+
const sourceCode = context.sourceCode;
|
88
88
|
|
89
89
|
//-------------------------------------------------------------------------
|
90
90
|
// Helpers
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Disallow confusing multiline expressions",
|
24
24
|
recommended: true,
|
25
|
-
url: "https://eslint.org/docs/rules/no-unexpected-multiline"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/no-unexpected-multiline"
|
26
26
|
},
|
27
27
|
|
28
28
|
schema: [],
|
@@ -38,7 +38,7 @@ module.exports = {
|
|
38
38
|
|
39
39
|
const REGEX_FLAG_MATCHER = /^[gimsuy]+$/u;
|
40
40
|
|
41
|
-
const sourceCode = context.
|
41
|
+
const sourceCode = context.sourceCode;
|
42
42
|
|
43
43
|
/**
|
44
44
|
* Check to see if there is a newline between the node and the following open bracket
|
@@ -164,7 +164,7 @@ module.exports = {
|
|
164
164
|
docs: {
|
165
165
|
description: "Disallow unmodified loop conditions",
|
166
166
|
recommended: false,
|
167
|
-
url: "https://eslint.org/docs/rules/no-unmodified-loop-condition"
|
167
|
+
url: "https://eslint.org/docs/latest/rules/no-unmodified-loop-condition"
|
168
168
|
},
|
169
169
|
|
170
170
|
schema: [],
|
@@ -175,7 +175,7 @@ module.exports = {
|
|
175
175
|
},
|
176
176
|
|
177
177
|
create(context) {
|
178
|
-
const sourceCode = context.
|
178
|
+
const sourceCode = context.sourceCode;
|
179
179
|
let groupMap = null;
|
180
180
|
|
181
181
|
/**
|
@@ -31,7 +31,7 @@ module.exports = {
|
|
31
31
|
docs: {
|
32
32
|
description: "Disallow ternary operators when simpler alternatives exist",
|
33
33
|
recommended: false,
|
34
|
-
url: "https://eslint.org/docs/rules/no-unneeded-ternary"
|
34
|
+
url: "https://eslint.org/docs/latest/rules/no-unneeded-ternary"
|
35
35
|
},
|
36
36
|
|
37
37
|
schema: [
|
@@ -58,7 +58,7 @@ module.exports = {
|
|
58
58
|
create(context) {
|
59
59
|
const options = context.options[0] || {};
|
60
60
|
const defaultAssignment = options.defaultAssignment !== false;
|
61
|
-
const sourceCode = context.
|
61
|
+
const sourceCode = context.sourceCode;
|
62
62
|
|
63
63
|
/**
|
64
64
|
* Test if the node is a boolean literal
|
@@ -61,7 +61,7 @@ module.exports = {
|
|
61
61
|
docs: {
|
62
62
|
description: "Disallow loops with a body that allows only one iteration",
|
63
63
|
recommended: false,
|
64
|
-
url: "https://eslint.org/docs/rules/no-unreachable-loop"
|
64
|
+
url: "https://eslint.org/docs/latest/rules/no-unreachable-loop"
|
65
65
|
},
|
66
66
|
|
67
67
|
schema: [{
|
@@ -113,7 +113,7 @@ module.exports = {
|
|
113
113
|
docs: {
|
114
114
|
description: "Disallow unreachable code after `return`, `throw`, `continue`, and `break` statements",
|
115
115
|
recommended: true,
|
116
|
-
url: "https://eslint.org/docs/rules/no-unreachable"
|
116
|
+
url: "https://eslint.org/docs/latest/rules/no-unreachable"
|
117
117
|
},
|
118
118
|
|
119
119
|
schema: [],
|
@@ -130,7 +130,7 @@ module.exports = {
|
|
130
130
|
let constructorInfo = null;
|
131
131
|
|
132
132
|
/** @type {ConsecutiveRange} */
|
133
|
-
const range = new ConsecutiveRange(context.
|
133
|
+
const range = new ConsecutiveRange(context.sourceCode);
|
134
134
|
|
135
135
|
/**
|
136
136
|
* Reports a given node if it's unreachable.
|
@@ -26,7 +26,7 @@ module.exports = {
|
|
26
26
|
docs: {
|
27
27
|
description: "Disallow control flow statements in `finally` blocks",
|
28
28
|
recommended: true,
|
29
|
-
url: "https://eslint.org/docs/rules/no-unsafe-finally"
|
29
|
+
url: "https://eslint.org/docs/latest/rules/no-unsafe-finally"
|
30
30
|
},
|
31
31
|
|
32
32
|
schema: [],
|
@@ -54,7 +54,7 @@ module.exports = {
|
|
54
54
|
docs: {
|
55
55
|
description: "Disallow negating the left operand of relational operators",
|
56
56
|
recommended: true,
|
57
|
-
url: "https://eslint.org/docs/rules/no-unsafe-negation"
|
57
|
+
url: "https://eslint.org/docs/latest/rules/no-unsafe-negation"
|
58
58
|
},
|
59
59
|
|
60
60
|
hasSuggestions: true,
|
@@ -82,7 +82,7 @@ module.exports = {
|
|
82
82
|
},
|
83
83
|
|
84
84
|
create(context) {
|
85
|
-
const sourceCode = context.
|
85
|
+
const sourceCode = context.sourceCode;
|
86
86
|
const options = context.options[0] || {};
|
87
87
|
const enforceForOrderingRelations = options.enforceForOrderingRelations === true;
|
88
88
|
|
@@ -26,7 +26,7 @@ module.exports = {
|
|
26
26
|
docs: {
|
27
27
|
description: "Disallow use of optional chaining in contexts where the `undefined` value is not allowed",
|
28
28
|
recommended: true,
|
29
|
-
url: "https://eslint.org/docs/rules/no-unsafe-optional-chaining"
|
29
|
+
url: "https://eslint.org/docs/latest/rules/no-unsafe-optional-chaining"
|
30
30
|
},
|
31
31
|
schema: [{
|
32
32
|
type: "object",
|
@@ -4,6 +4,8 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
const astUtils = require("./utils/ast-utils");
|
8
|
+
|
7
9
|
//------------------------------------------------------------------------------
|
8
10
|
// Rule Definition
|
9
11
|
//------------------------------------------------------------------------------
|
@@ -32,7 +34,7 @@ module.exports = {
|
|
32
34
|
docs: {
|
33
35
|
description: "Disallow unused expressions",
|
34
36
|
recommended: false,
|
35
|
-
url: "https://eslint.org/docs/rules/no-unused-expressions"
|
37
|
+
url: "https://eslint.org/docs/latest/rules/no-unused-expressions"
|
36
38
|
},
|
37
39
|
|
38
40
|
schema: [
|
@@ -112,8 +114,6 @@ module.exports = {
|
|
112
114
|
* @returns {boolean} whether the given node is considered a directive in its current position
|
113
115
|
*/
|
114
116
|
function isDirective(node) {
|
115
|
-
const parent = node.parent,
|
116
|
-
grandparent = parent.parent;
|
117
117
|
|
118
118
|
/**
|
119
119
|
* https://tc39.es/ecma262/#directive-prologue
|
@@ -121,9 +121,7 @@ module.exports = {
|
|
121
121
|
* Only `FunctionBody`, `ScriptBody` and `ModuleBody` can have directive prologue.
|
122
122
|
* Class static blocks do not have directive prologue.
|
123
123
|
*/
|
124
|
-
return (
|
125
|
-
(/Function/u.test(grandparent.type))) &&
|
126
|
-
directives(parent).includes(node);
|
124
|
+
return astUtils.isTopLevelExpressionStatement(node) && directives(node.parent).includes(node);
|
127
125
|
}
|
128
126
|
|
129
127
|
/**
|
@@ -5,6 +5,12 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
//------------------------------------------------------------------------------
|
9
|
+
// Requirements
|
10
|
+
//------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
const astUtils = require("./utils/ast-utils");
|
13
|
+
|
8
14
|
//------------------------------------------------------------------------------
|
9
15
|
// Rule Definition
|
10
16
|
//------------------------------------------------------------------------------
|
@@ -17,7 +23,7 @@ module.exports = {
|
|
17
23
|
docs: {
|
18
24
|
description: "Disallow unused labels",
|
19
25
|
recommended: true,
|
20
|
-
url: "https://eslint.org/docs/rules/no-unused-labels"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/no-unused-labels"
|
21
27
|
},
|
22
28
|
|
23
29
|
schema: [],
|
@@ -30,7 +36,7 @@ module.exports = {
|
|
30
36
|
},
|
31
37
|
|
32
38
|
create(context) {
|
33
|
-
const sourceCode = context.
|
39
|
+
const sourceCode = context.sourceCode;
|
34
40
|
let scopeInfo = null;
|
35
41
|
|
36
42
|
/**
|
@@ -46,6 +52,45 @@ module.exports = {
|
|
46
52
|
};
|
47
53
|
}
|
48
54
|
|
55
|
+
/**
|
56
|
+
* Checks if a `LabeledStatement` node is fixable.
|
57
|
+
* For a node to be fixable, there must be no comments between the label and the body.
|
58
|
+
* Furthermore, is must be possible to remove the label without turning the body statement into a
|
59
|
+
* directive after other fixes are applied.
|
60
|
+
* @param {ASTNode} node The node to evaluate.
|
61
|
+
* @returns {boolean} Whether or not the node is fixable.
|
62
|
+
*/
|
63
|
+
function isFixable(node) {
|
64
|
+
|
65
|
+
/*
|
66
|
+
* Only perform a fix if there are no comments between the label and the body. This will be the case
|
67
|
+
* when there is exactly one token/comment (the ":") between the label and the body.
|
68
|
+
*/
|
69
|
+
if (sourceCode.getTokenAfter(node.label, { includeComments: true }) !==
|
70
|
+
sourceCode.getTokenBefore(node.body, { includeComments: true })) {
|
71
|
+
return false;
|
72
|
+
}
|
73
|
+
|
74
|
+
// Looking for the node's deepest ancestor which is not a `LabeledStatement`.
|
75
|
+
let ancestor = node.parent;
|
76
|
+
|
77
|
+
while (ancestor.type === "LabeledStatement") {
|
78
|
+
ancestor = ancestor.parent;
|
79
|
+
}
|
80
|
+
|
81
|
+
if (ancestor.type === "Program" ||
|
82
|
+
(ancestor.type === "BlockStatement" && astUtils.isFunction(ancestor.parent))) {
|
83
|
+
const { body } = node;
|
84
|
+
|
85
|
+
if (body.type === "ExpressionStatement" &&
|
86
|
+
((body.expression.type === "Literal" && typeof body.expression.value === "string") ||
|
87
|
+
astUtils.isStaticTemplateLiteral(body.expression))) {
|
88
|
+
return false; // potential directive
|
89
|
+
}
|
90
|
+
}
|
91
|
+
return true;
|
92
|
+
}
|
93
|
+
|
49
94
|
/**
|
50
95
|
* Removes the top of the stack.
|
51
96
|
* At the same time, this reports the label if it's never used.
|
@@ -58,19 +103,7 @@ module.exports = {
|
|
58
103
|
node: node.label,
|
59
104
|
messageId: "unused",
|
60
105
|
data: node.label,
|
61
|
-
fix(fixer)
|
62
|
-
|
63
|
-
/*
|
64
|
-
* Only perform a fix if there are no comments between the label and the body. This will be the case
|
65
|
-
* when there is exactly one token/comment (the ":") between the label and the body.
|
66
|
-
*/
|
67
|
-
if (sourceCode.getTokenAfter(node.label, { includeComments: true }) ===
|
68
|
-
sourceCode.getTokenBefore(node.body, { includeComments: true })) {
|
69
|
-
return fixer.removeRange([node.range[0], node.body.range[0]]);
|
70
|
-
}
|
71
|
-
|
72
|
-
return null;
|
73
|
-
}
|
106
|
+
fix: isFixable(node) ? fixer => fixer.removeRange([node.range[0], node.body.range[0]]) : null
|
74
107
|
});
|
75
108
|
}
|
76
109
|
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Disallow unused private class members",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/no-unused-private-class-members"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/no-unused-private-class-members"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
35
35
|
docs: {
|
36
36
|
description: "Disallow unused variables",
|
37
37
|
recommended: true,
|
38
|
-
url: "https://eslint.org/docs/rules/no-unused-vars"
|
38
|
+
url: "https://eslint.org/docs/latest/rules/no-unused-vars"
|
39
39
|
},
|
40
40
|
|
41
41
|
schema: [
|
@@ -84,7 +84,7 @@ module.exports = {
|
|
84
84
|
},
|
85
85
|
|
86
86
|
create(context) {
|
87
|
-
const sourceCode = context.
|
87
|
+
const sourceCode = context.sourceCode;
|
88
88
|
|
89
89
|
const REST_PROPERTY_TYPE = /^(?:RestElement|(?:Experimental)?RestProperty)$/u;
|
90
90
|
|
@@ -466,7 +466,8 @@ module.exports = {
|
|
466
466
|
(
|
467
467
|
parent.type === "AssignmentExpression" &&
|
468
468
|
parent.left === id &&
|
469
|
-
isUnusedExpression(parent)
|
469
|
+
isUnusedExpression(parent) &&
|
470
|
+
!astUtils.isLogicalAssignmentOperator(parent.operator)
|
470
471
|
) ||
|
471
472
|
(
|
472
473
|
parent.type === "UpdateExpression" &&
|
@@ -228,7 +228,7 @@ module.exports = {
|
|
228
228
|
docs: {
|
229
229
|
description: "Disallow the use of variables before they are defined",
|
230
230
|
recommended: false,
|
231
|
-
url: "https://eslint.org/docs/rules/no-use-before-define"
|
231
|
+
url: "https://eslint.org/docs/latest/rules/no-use-before-define"
|
232
232
|
},
|
233
233
|
|
234
234
|
schema: [
|
@@ -258,7 +258,7 @@ module.exports = {
|
|
258
258
|
|
259
259
|
create(context) {
|
260
260
|
const options = parseOptions(context.options[0]);
|
261
|
-
const sourceCode = context.
|
261
|
+
const sourceCode = context.sourceCode;
|
262
262
|
|
263
263
|
/**
|
264
264
|
* Determines whether a given reference should be checked.
|
@@ -66,7 +66,7 @@ module.exports = {
|
|
66
66
|
docs: {
|
67
67
|
description: "Disallow useless backreferences in regular expressions",
|
68
68
|
recommended: true,
|
69
|
-
url: "https://eslint.org/docs/rules/no-useless-backreference"
|
69
|
+
url: "https://eslint.org/docs/latest/rules/no-useless-backreference"
|
70
70
|
},
|
71
71
|
|
72
72
|
schema: [],
|
@@ -82,7 +82,7 @@ module.exports = {
|
|
82
82
|
|
83
83
|
create(context) {
|
84
84
|
|
85
|
-
const sourceCode = context.
|
85
|
+
const sourceCode = context.sourceCode;
|
86
86
|
|
87
87
|
/**
|
88
88
|
* Checks and reports useless backreferences in the given regular expression.
|
@@ -95,7 +95,7 @@ module.exports = {
|
|
95
95
|
let regExpAST;
|
96
96
|
|
97
97
|
try {
|
98
|
-
regExpAST = parser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
|
98
|
+
regExpAST = parser.parsePattern(pattern, 0, pattern.length, { unicode: flags.includes("u"), unicodeSets: flags.includes("v") });
|
99
99
|
} catch {
|
100
100
|
|
101
101
|
// Ignore regular expressions with syntax errors
|
@@ -57,7 +57,7 @@ module.exports = {
|
|
57
57
|
docs: {
|
58
58
|
description: "Disallow unnecessary calls to `.call()` and `.apply()`",
|
59
59
|
recommended: false,
|
60
|
-
url: "https://eslint.org/docs/rules/no-useless-call"
|
60
|
+
url: "https://eslint.org/docs/latest/rules/no-useless-call"
|
61
61
|
},
|
62
62
|
|
63
63
|
schema: [],
|
@@ -68,7 +68,7 @@ module.exports = {
|
|
68
68
|
},
|
69
69
|
|
70
70
|
create(context) {
|
71
|
-
const sourceCode = context.
|
71
|
+
const sourceCode = context.sourceCode;
|
72
72
|
|
73
73
|
return {
|
74
74
|
CallExpression(node) {
|
@@ -93,7 +93,7 @@ module.exports = {
|
|
93
93
|
docs: {
|
94
94
|
description: "Disallow unnecessary computed property keys in objects and classes",
|
95
95
|
recommended: false,
|
96
|
-
url: "https://eslint.org/docs/rules/no-useless-computed-key"
|
96
|
+
url: "https://eslint.org/docs/latest/rules/no-useless-computed-key"
|
97
97
|
},
|
98
98
|
|
99
99
|
schema: [{
|
@@ -113,7 +113,7 @@ module.exports = {
|
|
113
113
|
}
|
114
114
|
},
|
115
115
|
create(context) {
|
116
|
-
const sourceCode = context.
|
116
|
+
const sourceCode = context.sourceCode;
|
117
117
|
const enforceForClassMembers = context.options[0] && context.options[0].enforceForClassMembers;
|
118
118
|
|
119
119
|
/**
|
@@ -72,7 +72,7 @@ module.exports = {
|
|
72
72
|
docs: {
|
73
73
|
description: "Disallow unnecessary concatenation of literals or template literals",
|
74
74
|
recommended: false,
|
75
|
-
url: "https://eslint.org/docs/rules/no-useless-concat"
|
75
|
+
url: "https://eslint.org/docs/latest/rules/no-useless-concat"
|
76
76
|
},
|
77
77
|
|
78
78
|
schema: [],
|
@@ -83,7 +83,7 @@ module.exports = {
|
|
83
83
|
},
|
84
84
|
|
85
85
|
create(context) {
|
86
|
-
const sourceCode = context.
|
86
|
+
const sourceCode = context.sourceCode;
|
87
87
|
|
88
88
|
return {
|
89
89
|
BinaryExpression(node) {
|
@@ -140,7 +140,7 @@ module.exports = {
|
|
140
140
|
docs: {
|
141
141
|
description: "Disallow unnecessary constructors",
|
142
142
|
recommended: false,
|
143
|
-
url: "https://eslint.org/docs/rules/no-useless-constructor"
|
143
|
+
url: "https://eslint.org/docs/latest/rules/no-useless-constructor"
|
144
144
|
},
|
145
145
|
|
146
146
|
schema: [],
|