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
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Disallow `new` operators with global non-constructor functions",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/no-new-native-nonconstructor"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/no-new-native-nonconstructor"
|
27
27
|
},
|
28
28
|
|
29
29
|
schema: [],
|
@@ -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
|
return {
|
41
41
|
"Program:exit"(node) {
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Disallow `Object` constructors",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/no-new-object"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/no-new-object"
|
27
27
|
},
|
28
28
|
|
29
29
|
schema: [],
|
@@ -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
|
return {
|
41
41
|
NewExpression(node) {
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Disallow `new` operators with calls to `require`",
|
24
24
|
recommended: false,
|
25
|
-
url: "https://eslint.org/docs/rules/no-new-require"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/no-new-require"
|
26
26
|
},
|
27
27
|
|
28
28
|
schema: [],
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Disallow `new` operators with the `Symbol` object",
|
19
19
|
recommended: true,
|
20
|
-
url: "https://eslint.org/docs/rules/no-new-symbol"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/no-new-symbol"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
@@ -29,7 +29,7 @@ module.exports = {
|
|
29
29
|
|
30
30
|
create(context) {
|
31
31
|
|
32
|
-
const sourceCode = context.
|
32
|
+
const sourceCode = context.sourceCode;
|
33
33
|
|
34
34
|
return {
|
35
35
|
"Program:exit"(node) {
|
@@ -5,6 +5,12 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
//------------------------------------------------------------------------------
|
9
|
+
// Requirements
|
10
|
+
//------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
const { getVariableByName } = 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 `new` operators with the `String`, `Number`, and `Boolean` objects",
|
19
25
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/no-new-wrappers"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/no-new-wrappers"
|
21
27
|
},
|
22
28
|
|
23
29
|
schema: [],
|
@@ -28,18 +34,24 @@ module.exports = {
|
|
28
34
|
},
|
29
35
|
|
30
36
|
create(context) {
|
37
|
+
const { sourceCode } = context;
|
31
38
|
|
32
39
|
return {
|
33
40
|
|
34
41
|
NewExpression(node) {
|
35
42
|
const wrapperObjects = ["String", "Number", "Boolean"];
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
+
const { name } = node.callee;
|
44
|
+
|
45
|
+
if (wrapperObjects.includes(name)) {
|
46
|
+
const variable = getVariableByName(sourceCode.getScope(node), name);
|
47
|
+
|
48
|
+
if (variable && variable.identifiers.length === 0) {
|
49
|
+
context.report({
|
50
|
+
node,
|
51
|
+
messageId: "noConstructor",
|
52
|
+
data: { fn: name }
|
53
|
+
});
|
54
|
+
}
|
43
55
|
}
|
44
56
|
}
|
45
57
|
};
|
package/lib/rules/no-new.js
CHANGED
@@ -32,7 +32,7 @@ module.exports = {
|
|
32
32
|
docs: {
|
33
33
|
description: "Disallow `\\8` and `\\9` escape sequences in string literals",
|
34
34
|
recommended: true,
|
35
|
-
url: "https://eslint.org/docs/rules/no-nonoctal-decimal-escape"
|
35
|
+
url: "https://eslint.org/docs/latest/rules/no-nonoctal-decimal-escape"
|
36
36
|
},
|
37
37
|
|
38
38
|
hasSuggestions: true,
|
@@ -49,7 +49,7 @@ module.exports = {
|
|
49
49
|
},
|
50
50
|
|
51
51
|
create(context) {
|
52
|
-
const sourceCode = context.
|
52
|
+
const sourceCode = context.sourceCode;
|
53
53
|
|
54
54
|
/**
|
55
55
|
* Creates a new Suggestion object.
|
@@ -45,7 +45,7 @@ module.exports = {
|
|
45
45
|
docs: {
|
46
46
|
description: "Disallow calling global object properties as functions",
|
47
47
|
recommended: true,
|
48
|
-
url: "https://eslint.org/docs/rules/no-obj-calls"
|
48
|
+
url: "https://eslint.org/docs/latest/rules/no-obj-calls"
|
49
49
|
},
|
50
50
|
|
51
51
|
schema: [],
|
@@ -58,7 +58,7 @@ module.exports = {
|
|
58
58
|
|
59
59
|
create(context) {
|
60
60
|
|
61
|
-
const sourceCode = context.
|
61
|
+
const sourceCode = context.sourceCode;
|
62
62
|
|
63
63
|
return {
|
64
64
|
Program(node) {
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Disallow octal escape sequences in string literals",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/no-octal-escape"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/no-octal-escape"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
package/lib/rules/no-octal.js
CHANGED
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Disallow reassigning `function` parameters",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/no-param-reassign"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/no-param-reassign"
|
22
22
|
},
|
23
23
|
|
24
24
|
schema: [
|
@@ -70,7 +70,7 @@ module.exports = {
|
|
70
70
|
const props = context.options[0] && context.options[0].props;
|
71
71
|
const ignoredPropertyAssignmentsFor = context.options[0] && context.options[0].ignorePropertyModificationsFor || [];
|
72
72
|
const ignoredPropertyAssignmentsForRegex = context.options[0] && context.options[0].ignorePropertyModificationsForRegex || [];
|
73
|
-
const sourceCode = context.
|
73
|
+
const sourceCode = context.sourceCode;
|
74
74
|
|
75
75
|
/**
|
76
76
|
* Checks whether or not the reference modifies properties of its variable.
|
@@ -21,7 +21,7 @@ module.exports = {
|
|
21
21
|
docs: {
|
22
22
|
description: "Disallow string concatenation with `__dirname` and `__filename`",
|
23
23
|
recommended: false,
|
24
|
-
url: "https://eslint.org/docs/rules/no-path-concat"
|
24
|
+
url: "https://eslint.org/docs/latest/rules/no-path-concat"
|
25
25
|
},
|
26
26
|
|
27
27
|
schema: [],
|
package/lib/rules/no-plusplus.js
CHANGED
@@ -71,7 +71,7 @@ module.exports = {
|
|
71
71
|
docs: {
|
72
72
|
description: "Disallow returning values from Promise executor functions",
|
73
73
|
recommended: false,
|
74
|
-
url: "https://eslint.org/docs/rules/no-promise-executor-return"
|
74
|
+
url: "https://eslint.org/docs/latest/rules/no-promise-executor-return"
|
75
75
|
},
|
76
76
|
|
77
77
|
schema: [],
|
@@ -84,7 +84,7 @@ module.exports = {
|
|
84
84
|
create(context) {
|
85
85
|
|
86
86
|
let funcInfo = null;
|
87
|
-
const sourceCode = context.
|
87
|
+
const sourceCode = context.sourceCode;
|
88
88
|
|
89
89
|
/**
|
90
90
|
* Reports the given node.
|
package/lib/rules/no-proto.js
CHANGED
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Disallow calling some `Object.prototype` methods directly on objects",
|
24
24
|
recommended: true,
|
25
|
-
url: "https://eslint.org/docs/rules/no-prototype-builtins"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/no-prototype-builtins"
|
26
26
|
},
|
27
27
|
|
28
28
|
schema: [],
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Disallow variable redeclaration",
|
25
25
|
recommended: true,
|
26
|
-
url: "https://eslint.org/docs/rules/no-redeclare"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/no-redeclare"
|
27
27
|
},
|
28
28
|
|
29
29
|
messages: {
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
50
50
|
context.options[0].builtinGlobals
|
51
51
|
)
|
52
52
|
};
|
53
|
-
const sourceCode = context.
|
53
|
+
const sourceCode = context.sourceCode;
|
54
54
|
|
55
55
|
/**
|
56
56
|
* Iterate declarations of a given variable.
|
@@ -41,7 +41,7 @@ module.exports = {
|
|
41
41
|
docs: {
|
42
42
|
description: "Disallow multiple spaces in regular expressions",
|
43
43
|
recommended: true,
|
44
|
-
url: "https://eslint.org/docs/rules/no-regex-spaces"
|
44
|
+
url: "https://eslint.org/docs/latest/rules/no-regex-spaces"
|
45
45
|
},
|
46
46
|
|
47
47
|
schema: [],
|
@@ -54,7 +54,7 @@ module.exports = {
|
|
54
54
|
|
55
55
|
create(context) {
|
56
56
|
|
57
|
-
const sourceCode = context.
|
57
|
+
const sourceCode = context.sourceCode;
|
58
58
|
|
59
59
|
/**
|
60
60
|
* Validate regular expression
|
@@ -77,7 +77,7 @@ module.exports = {
|
|
77
77
|
let regExpAST;
|
78
78
|
|
79
79
|
try {
|
80
|
-
regExpAST = regExpParser.parsePattern(pattern, 0, pattern.length, flags.includes("u"));
|
80
|
+
regExpAST = regExpParser.parsePattern(pattern, 0, pattern.length, { unicode: flags.includes("u"), unicodeSets: flags.includes("v") });
|
81
81
|
} catch {
|
82
82
|
|
83
83
|
// Ignore regular expressions with syntax errors
|
@@ -155,13 +155,28 @@ module.exports = {
|
|
155
155
|
const regExpVar = astUtils.getVariableByName(scope, "RegExp");
|
156
156
|
const shadowed = regExpVar && regExpVar.defs.length > 0;
|
157
157
|
const patternNode = node.arguments[0];
|
158
|
-
const flagsNode = node.arguments[1];
|
159
158
|
|
160
159
|
if (node.callee.type === "Identifier" && node.callee.name === "RegExp" && isString(patternNode) && !shadowed) {
|
161
160
|
const pattern = patternNode.value;
|
162
161
|
const rawPattern = patternNode.raw.slice(1, -1);
|
163
162
|
const rawPatternStartRange = patternNode.range[0] + 1;
|
164
|
-
|
163
|
+
let flags;
|
164
|
+
|
165
|
+
if (node.arguments.length < 2) {
|
166
|
+
|
167
|
+
// It has no flags.
|
168
|
+
flags = "";
|
169
|
+
} else {
|
170
|
+
const flagsNode = node.arguments[1];
|
171
|
+
|
172
|
+
if (isString(flagsNode)) {
|
173
|
+
flags = flagsNode.value;
|
174
|
+
} else {
|
175
|
+
|
176
|
+
// The flags cannot be determined.
|
177
|
+
return;
|
178
|
+
}
|
179
|
+
}
|
165
180
|
|
166
181
|
checkRegex(
|
167
182
|
node,
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Disallow specified names in exports",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/no-restricted-exports"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/no-restricted-exports"
|
27
27
|
},
|
28
28
|
|
29
29
|
schema: [{
|
@@ -99,7 +99,7 @@ module.exports = {
|
|
99
99
|
|
100
100
|
const restrictedNames = new Set(context.options[0] && context.options[0].restrictedNamedExports);
|
101
101
|
const restrictDefaultExports = context.options[0] && context.options[0].restrictDefaultExports;
|
102
|
-
const sourceCode = context.
|
102
|
+
const sourceCode = context.sourceCode;
|
103
103
|
|
104
104
|
/**
|
105
105
|
* Checks and reports given exported name.
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Disallow specified global variables",
|
18
18
|
recommended: false,
|
19
|
-
url: "https://eslint.org/docs/rules/no-restricted-globals"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/no-restricted-globals"
|
20
20
|
},
|
21
21
|
|
22
22
|
schema: {
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
50
50
|
|
51
51
|
create(context) {
|
52
52
|
|
53
|
-
const sourceCode = context.
|
53
|
+
const sourceCode = context.sourceCode;
|
54
54
|
|
55
55
|
// If no globals are restricted, we don't need to do anything
|
56
56
|
if (context.options.length === 0) {
|
@@ -98,7 +98,7 @@ module.exports = {
|
|
98
98
|
docs: {
|
99
99
|
description: "Disallow specified modules when loaded by `import`",
|
100
100
|
recommended: false,
|
101
|
-
url: "https://eslint.org/docs/rules/no-restricted-imports"
|
101
|
+
url: "https://eslint.org/docs/latest/rules/no-restricted-imports"
|
102
102
|
},
|
103
103
|
|
104
104
|
messages: {
|
@@ -147,7 +147,7 @@ module.exports = {
|
|
147
147
|
},
|
148
148
|
|
149
149
|
create(context) {
|
150
|
-
const sourceCode = context.
|
150
|
+
const sourceCode = context.sourceCode;
|
151
151
|
const options = Array.isArray(context.options) ? context.options : [];
|
152
152
|
const isPathAndPatternsObject =
|
153
153
|
typeof options[0] === "object" &&
|
@@ -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
|
//------------------------------------------------------------------------------
|
@@ -51,7 +57,7 @@ module.exports = {
|
|
51
57
|
docs: {
|
52
58
|
description: "Disallow specified modules when loaded by `require`",
|
53
59
|
recommended: false,
|
54
|
-
url: "https://eslint.org/docs/rules/no-restricted-modules"
|
60
|
+
url: "https://eslint.org/docs/latest/rules/no-restricted-modules"
|
55
61
|
},
|
56
62
|
|
57
63
|
schema: {
|
@@ -116,15 +122,6 @@ module.exports = {
|
|
116
122
|
return node && node.type === "Literal" && typeof node.value === "string";
|
117
123
|
}
|
118
124
|
|
119
|
-
/**
|
120
|
-
* Function to check if a node is a static string template literal.
|
121
|
-
* @param {ASTNode} node The node to check.
|
122
|
-
* @returns {boolean} If the node is a string template literal.
|
123
|
-
*/
|
124
|
-
function isStaticTemplateLiteral(node) {
|
125
|
-
return node && node.type === "TemplateLiteral" && node.expressions.length === 0;
|
126
|
-
}
|
127
|
-
|
128
125
|
/**
|
129
126
|
* Function to check if a node is a require call.
|
130
127
|
* @param {ASTNode} node The node to check.
|
@@ -144,7 +141,7 @@ module.exports = {
|
|
144
141
|
return node.value.trim();
|
145
142
|
}
|
146
143
|
|
147
|
-
if (isStaticTemplateLiteral(node)) {
|
144
|
+
if (astUtils.isStaticTemplateLiteral(node)) {
|
148
145
|
return node.quasis[0].value.cooked.trim();
|
149
146
|
}
|
150
147
|
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
19
19
|
docs: {
|
20
20
|
description: "Disallow certain properties on certain objects",
|
21
21
|
recommended: false,
|
22
|
-
url: "https://eslint.org/docs/rules/no-restricted-properties"
|
22
|
+
url: "https://eslint.org/docs/latest/rules/no-restricted-properties"
|
23
23
|
},
|
24
24
|
|
25
25
|
schema: {
|
@@ -28,7 +28,7 @@ module.exports = {
|
|
28
28
|
docs: {
|
29
29
|
description: "Disallow assignment operators in `return` statements",
|
30
30
|
recommended: false,
|
31
|
-
url: "https://eslint.org/docs/rules/no-return-assign"
|
31
|
+
url: "https://eslint.org/docs/latest/rules/no-return-assign"
|
32
32
|
},
|
33
33
|
|
34
34
|
schema: [
|
@@ -45,7 +45,7 @@ module.exports = {
|
|
45
45
|
|
46
46
|
create(context) {
|
47
47
|
const always = (context.options[0] || "except-parens") !== "except-parens";
|
48
|
-
const sourceCode = context.
|
48
|
+
const sourceCode = context.sourceCode;
|
49
49
|
|
50
50
|
return {
|
51
51
|
AssignmentExpression(node) {
|
@@ -1,6 +1,7 @@
|
|
1
1
|
/**
|
2
2
|
* @fileoverview Disallows unnecessary `return await`
|
3
3
|
* @author Jordan Harband
|
4
|
+
* @deprecated in ESLint v8.46.0
|
4
5
|
*/
|
5
6
|
"use strict";
|
6
7
|
|
@@ -21,11 +22,15 @@ module.exports = {
|
|
21
22
|
|
22
23
|
recommended: false,
|
23
24
|
|
24
|
-
url: "https://eslint.org/docs/rules/no-return-await"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/no-return-await"
|
25
26
|
},
|
26
27
|
|
27
28
|
fixable: null,
|
28
29
|
|
30
|
+
deprecated: true,
|
31
|
+
|
32
|
+
replacedBy: [],
|
33
|
+
|
29
34
|
schema: [
|
30
35
|
],
|
31
36
|
|
@@ -44,14 +49,14 @@ module.exports = {
|
|
44
49
|
*/
|
45
50
|
function reportUnnecessaryAwait(node) {
|
46
51
|
context.report({
|
47
|
-
node: context.
|
52
|
+
node: context.sourceCode.getFirstToken(node),
|
48
53
|
loc: node.loc,
|
49
54
|
messageId: "redundantUseOfAwait",
|
50
55
|
suggest: [
|
51
56
|
{
|
52
57
|
messageId: "removeAwait",
|
53
58
|
fix(fixer) {
|
54
|
-
const sourceCode = context.
|
59
|
+
const sourceCode = context.sourceCode;
|
55
60
|
const [awaitToken, tokenAfterAwait] = sourceCode.getFirstTokens(node, 2);
|
56
61
|
|
57
62
|
const areAwaitAndAwaitedExpressionOnTheSameLine = awaitToken.loc.start.line === tokenAfterAwait.loc.start.line;
|
@@ -132,7 +132,7 @@ module.exports = {
|
|
132
132
|
docs: {
|
133
133
|
description: "Disallow assignments where both sides are exactly the same",
|
134
134
|
recommended: true,
|
135
|
-
url: "https://eslint.org/docs/rules/no-self-assign"
|
135
|
+
url: "https://eslint.org/docs/latest/rules/no-self-assign"
|
136
136
|
},
|
137
137
|
|
138
138
|
schema: [
|
@@ -154,7 +154,7 @@ module.exports = {
|
|
154
154
|
},
|
155
155
|
|
156
156
|
create(context) {
|
157
|
-
const sourceCode = context.
|
157
|
+
const sourceCode = context.sourceCode;
|
158
158
|
const [{ props = true } = {}] = context.options;
|
159
159
|
|
160
160
|
/**
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Disallow comparisons where both sides are exactly the same",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/no-self-compare"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/no-self-compare"
|
22
22
|
},
|
23
23
|
|
24
24
|
schema: [],
|
@@ -29,7 +29,7 @@ module.exports = {
|
|
29
29
|
},
|
30
30
|
|
31
31
|
create(context) {
|
32
|
-
const sourceCode = context.
|
32
|
+
const sourceCode = context.sourceCode;
|
33
33
|
|
34
34
|
/**
|
35
35
|
* Determines whether two nodes are composed of the same tokens.
|
@@ -31,7 +31,7 @@ module.exports = {
|
|
31
31
|
docs: {
|
32
32
|
description: "Disallow comma operators",
|
33
33
|
recommended: false,
|
34
|
-
url: "https://eslint.org/docs/rules/no-sequences"
|
34
|
+
url: "https://eslint.org/docs/latest/rules/no-sequences"
|
35
35
|
},
|
36
36
|
|
37
37
|
schema: [{
|
@@ -51,7 +51,7 @@ module.exports = {
|
|
51
51
|
|
52
52
|
create(context) {
|
53
53
|
const options = Object.assign({}, DEFAULT_OPTIONS, context.options[0]);
|
54
|
-
const sourceCode = context.
|
54
|
+
const sourceCode = context.sourceCode;
|
55
55
|
|
56
56
|
/**
|
57
57
|
* Parts of the grammar that are required to have parens.
|
@@ -144,7 +144,7 @@ module.exports = {
|
|
144
144
|
docs: {
|
145
145
|
description: "Disallow returning values from setters",
|
146
146
|
recommended: true,
|
147
|
-
url: "https://eslint.org/docs/rules/no-setter-return"
|
147
|
+
url: "https://eslint.org/docs/latest/rules/no-setter-return"
|
148
148
|
},
|
149
149
|
|
150
150
|
schema: [],
|
@@ -156,7 +156,7 @@ module.exports = {
|
|
156
156
|
|
157
157
|
create(context) {
|
158
158
|
let funcInfo = null;
|
159
|
-
const sourceCode = context.
|
159
|
+
const sourceCode = context.sourceCode;
|
160
160
|
|
161
161
|
/**
|
162
162
|
* Creates and pushes to the stack a function info object for the given function node.
|
@@ -29,7 +29,7 @@ module.exports = {
|
|
29
29
|
docs: {
|
30
30
|
description: "Disallow identifiers from shadowing restricted names",
|
31
31
|
recommended: true,
|
32
|
-
url: "https://eslint.org/docs/rules/no-shadow-restricted-names"
|
32
|
+
url: "https://eslint.org/docs/latest/rules/no-shadow-restricted-names"
|
33
33
|
},
|
34
34
|
|
35
35
|
schema: [],
|
@@ -43,7 +43,7 @@ module.exports = {
|
|
43
43
|
|
44
44
|
|
45
45
|
const RESTRICTED = new Set(["undefined", "NaN", "Infinity", "arguments", "eval"]);
|
46
|
-
const sourceCode = context.
|
46
|
+
const sourceCode = context.sourceCode;
|
47
47
|
|
48
48
|
return {
|
49
49
|
"VariableDeclaration, :function, CatchClause"(node) {
|