eslint 9.23.0 → 9.25.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 +3 -2
- package/lib/cli-engine/cli-engine.js +2 -2
- package/lib/cli-engine/formatters/html.js +3 -3
- package/lib/cli-engine/formatters/stylish.js +1 -1
- package/lib/cli.js +98 -1
- package/lib/config/config-loader.js +108 -34
- package/lib/config/flat-config-helpers.js +7 -4
- package/lib/eslint/eslint-helpers.js +50 -5
- package/lib/eslint/eslint.js +17 -53
- package/lib/eslint/legacy-eslint.js +1 -1
- package/lib/languages/js/source-code/source-code.js +3 -3
- package/lib/languages/js/source-code/token-store/index.js +3 -3
- package/lib/linter/code-path-analysis/code-path-state.js +1 -1
- package/lib/linter/linter.js +1 -1
- package/lib/linter/node-event-generator.js +3 -1
- package/lib/linter/report-translator.js +1 -1
- package/lib/linter/rule-fixer.js +13 -5
- package/lib/linter/rules.js +1 -1
- package/lib/linter/source-code-fixer.js +2 -2
- package/lib/linter/timing.js +2 -2
- package/lib/options.js +29 -0
- package/lib/rule-tester/rule-tester.js +1 -1
- package/lib/rules/accessor-pairs.js +1 -1
- package/lib/rules/array-bracket-newline.js +1 -1
- package/lib/rules/array-bracket-spacing.js +1 -1
- package/lib/rules/array-callback-return.js +1 -1
- package/lib/rules/array-element-newline.js +1 -1
- package/lib/rules/arrow-body-style.js +1 -1
- package/lib/rules/arrow-parens.js +1 -1
- package/lib/rules/arrow-spacing.js +1 -1
- package/lib/rules/block-scoped-var.js +1 -1
- package/lib/rules/block-spacing.js +1 -1
- package/lib/rules/brace-style.js +1 -1
- package/lib/rules/callback-return.js +1 -1
- package/lib/rules/camelcase.js +1 -1
- package/lib/rules/capitalized-comments.js +1 -1
- package/lib/rules/class-methods-use-this.js +46 -2
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/comma-style.js +1 -1
- package/lib/rules/complexity.js +1 -1
- package/lib/rules/computed-property-spacing.js +1 -1
- package/lib/rules/consistent-return.js +1 -1
- package/lib/rules/consistent-this.js +1 -1
- package/lib/rules/constructor-super.js +1 -1
- package/lib/rules/curly.js +1 -1
- package/lib/rules/default-case-last.js +1 -1
- package/lib/rules/default-case.js +1 -1
- package/lib/rules/default-param-last.js +1 -1
- package/lib/rules/dot-location.js +1 -1
- package/lib/rules/dot-notation.js +1 -1
- package/lib/rules/eol-last.js +1 -1
- package/lib/rules/eqeqeq.js +1 -1
- package/lib/rules/for-direction.js +5 -5
- package/lib/rules/func-call-spacing.js +1 -1
- package/lib/rules/func-name-matching.js +2 -2
- package/lib/rules/func-names.js +1 -1
- package/lib/rules/func-style.js +1 -1
- package/lib/rules/function-call-argument-newline.js +1 -1
- package/lib/rules/function-paren-newline.js +1 -1
- package/lib/rules/generator-star-spacing.js +1 -1
- package/lib/rules/getter-return.js +1 -1
- package/lib/rules/global-require.js +1 -1
- package/lib/rules/grouped-accessor-pairs.js +1 -1
- package/lib/rules/guard-for-in.js +1 -1
- package/lib/rules/handle-callback-err.js +1 -1
- package/lib/rules/id-blacklist.js +1 -1
- package/lib/rules/id-denylist.js +1 -1
- package/lib/rules/id-length.js +1 -1
- package/lib/rules/id-match.js +1 -1
- package/lib/rules/implicit-arrow-linebreak.js +1 -1
- package/lib/rules/indent-legacy.js +14 -14
- package/lib/rules/indent.js +4 -4
- package/lib/rules/init-declarations.js +22 -1
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/key-spacing.js +3 -3
- package/lib/rules/keyword-spacing.js +1 -1
- package/lib/rules/line-comment-position.js +1 -1
- package/lib/rules/linebreak-style.js +10 -2
- package/lib/rules/lines-around-comment.js +1 -1
- package/lib/rules/lines-around-directive.js +1 -1
- package/lib/rules/lines-between-class-members.js +1 -1
- package/lib/rules/logical-assignment-operators.js +1 -1
- package/lib/rules/max-classes-per-file.js +1 -1
- package/lib/rules/max-depth.js +1 -1
- package/lib/rules/max-len.js +3 -3
- package/lib/rules/max-lines-per-function.js +1 -1
- package/lib/rules/max-lines.js +1 -1
- package/lib/rules/max-nested-callbacks.js +1 -1
- package/lib/rules/max-params.js +1 -1
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/max-statements.js +3 -3
- package/lib/rules/multiline-comment-style.js +1 -1
- package/lib/rules/multiline-ternary.js +1 -1
- package/lib/rules/new-cap.js +1 -1
- package/lib/rules/new-parens.js +1 -1
- package/lib/rules/newline-after-var.js +1 -1
- package/lib/rules/newline-before-return.js +1 -1
- package/lib/rules/newline-per-chained-call.js +1 -1
- package/lib/rules/no-alert.js +1 -1
- package/lib/rules/no-array-constructor.js +4 -1
- package/lib/rules/no-async-promise-executor.js +1 -1
- 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 +1 -1
- package/lib/rules/no-class-assign.js +1 -1
- package/lib/rules/no-compare-neg-zero.js +1 -1
- package/lib/rules/no-cond-assign.js +1 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-console.js +1 -1
- package/lib/rules/no-const-assign.js +1 -1
- package/lib/rules/no-constant-binary-expression.js +2 -2
- package/lib/rules/no-constant-condition.js +1 -1
- package/lib/rules/no-constructor-return.js +1 -1
- package/lib/rules/no-continue.js +1 -1
- package/lib/rules/no-control-regex.js +1 -1
- package/lib/rules/no-debugger.js +1 -1
- package/lib/rules/no-delete-var.js +1 -1
- package/lib/rules/no-div-regex.js +1 -1
- package/lib/rules/no-dupe-args.js +1 -1
- package/lib/rules/no-dupe-class-members.js +10 -1
- package/lib/rules/no-dupe-else-if.js +1 -1
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-duplicate-case.js +1 -1
- package/lib/rules/no-duplicate-imports.js +1 -1
- package/lib/rules/no-else-return.js +1 -1
- package/lib/rules/no-empty-character-class.js +1 -1
- package/lib/rules/no-empty-function.js +54 -3
- package/lib/rules/no-empty-pattern.js +1 -1
- package/lib/rules/no-empty-static-block.js +1 -1
- package/lib/rules/no-empty.js +1 -1
- package/lib/rules/no-eq-null.js +1 -1
- package/lib/rules/no-eval.js +1 -1
- package/lib/rules/no-ex-assign.js +1 -1
- package/lib/rules/no-extend-native.js +1 -1
- package/lib/rules/no-extra-bind.js +1 -1
- package/lib/rules/no-extra-boolean-cast.js +1 -1
- package/lib/rules/no-extra-label.js +1 -1
- package/lib/rules/no-extra-parens.js +1 -1
- package/lib/rules/no-extra-semi.js +1 -1
- package/lib/rules/no-fallthrough.js +1 -1
- package/lib/rules/no-floating-decimal.js +1 -1
- package/lib/rules/no-func-assign.js +1 -1
- package/lib/rules/no-global-assign.js +2 -2
- package/lib/rules/no-implicit-coercion.js +1 -1
- package/lib/rules/no-implicit-globals.js +1 -1
- package/lib/rules/no-implied-eval.js +1 -1
- package/lib/rules/no-import-assign.js +1 -1
- package/lib/rules/no-inline-comments.js +1 -1
- package/lib/rules/no-inner-declarations.js +1 -1
- package/lib/rules/no-invalid-regexp.js +1 -1
- package/lib/rules/no-invalid-this.js +23 -1
- package/lib/rules/no-irregular-whitespace.js +1 -1
- package/lib/rules/no-iterator.js +1 -1
- package/lib/rules/no-label-var.js +1 -1
- package/lib/rules/no-labels.js +1 -1
- package/lib/rules/no-lone-blocks.js +1 -1
- package/lib/rules/no-lonely-if.js +1 -1
- package/lib/rules/no-loop-func.js +10 -4
- package/lib/rules/no-loss-of-precision.js +3 -1
- package/lib/rules/no-magic-numbers.js +1 -1
- package/lib/rules/no-misleading-character-class.js +1 -1
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/no-mixed-requires.js +1 -1
- package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
- package/lib/rules/no-multi-assign.js +1 -1
- package/lib/rules/no-multi-spaces.js +1 -1
- package/lib/rules/no-multi-str.js +1 -1
- package/lib/rules/no-multiple-empty-lines.js +1 -1
- 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 +1 -1
- package/lib/rules/no-new-native-nonconstructor.js +1 -1
- package/lib/rules/no-new-object.js +1 -1
- package/lib/rules/no-new-require.js +1 -1
- package/lib/rules/no-new-symbol.js +1 -1
- package/lib/rules/no-new-wrappers.js +1 -1
- package/lib/rules/no-new.js +1 -1
- package/lib/rules/no-nonoctal-decimal-escape.js +10 -2
- package/lib/rules/no-obj-calls.js +1 -1
- package/lib/rules/no-object-constructor.js +1 -1
- 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 +1 -1
- package/lib/rules/no-proto.js +1 -1
- package/lib/rules/no-prototype-builtins.js +1 -1
- package/lib/rules/no-redeclare.js +1 -1
- package/lib/rules/no-regex-spaces.js +1 -1
- package/lib/rules/no-restricted-exports.js +1 -1
- package/lib/rules/no-restricted-globals.js +1 -1
- package/lib/rules/no-restricted-imports.js +1 -1
- package/lib/rules/no-restricted-modules.js +1 -1
- package/lib/rules/no-restricted-properties.js +43 -29
- package/lib/rules/no-restricted-syntax.js +1 -1
- package/lib/rules/no-return-assign.js +1 -1
- package/lib/rules/no-return-await.js +1 -2
- package/lib/rules/no-script-url.js +1 -1
- package/lib/rules/no-self-assign.js +1 -1
- package/lib/rules/no-self-compare.js +1 -1
- package/lib/rules/no-sequences.js +1 -1
- package/lib/rules/no-setter-return.js +1 -1
- package/lib/rules/no-shadow-restricted-names.js +1 -1
- package/lib/rules/no-shadow.js +1 -1
- package/lib/rules/no-spaced-func.js +1 -1
- package/lib/rules/no-sparse-arrays.js +1 -1
- package/lib/rules/no-sync.js +1 -1
- package/lib/rules/no-tabs.js +1 -1
- 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 +11 -3
- package/lib/rules/no-undef-init.js +1 -1
- package/lib/rules/no-undef.js +1 -1
- package/lib/rules/no-undefined.js +1 -1
- package/lib/rules/no-underscore-dangle.js +1 -1
- package/lib/rules/no-unexpected-multiline.js +1 -1
- package/lib/rules/no-unmodified-loop-condition.js +1 -1
- package/lib/rules/no-unneeded-ternary.js +1 -1
- package/lib/rules/no-unreachable-loop.js +1 -1
- package/lib/rules/no-unreachable.js +1 -1
- package/lib/rules/no-unsafe-finally.js +1 -1
- package/lib/rules/no-unsafe-negation.js +1 -1
- package/lib/rules/no-unsafe-optional-chaining.js +1 -1
- package/lib/rules/no-unused-expressions.js +15 -57
- package/lib/rules/no-unused-labels.js +1 -1
- package/lib/rules/no-unused-private-class-members.js +1 -1
- package/lib/rules/no-unused-vars.js +3 -3
- package/lib/rules/no-use-before-define.js +1 -1
- package/lib/rules/no-useless-assignment.js +1 -1
- package/lib/rules/no-useless-backreference.js +1 -1
- package/lib/rules/no-useless-call.js +1 -1
- package/lib/rules/no-useless-catch.js +1 -1
- package/lib/rules/no-useless-computed-key.js +1 -1
- package/lib/rules/no-useless-concat.js +1 -1
- package/lib/rules/no-useless-constructor.js +1 -1
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-useless-rename.js +1 -1
- package/lib/rules/no-useless-return.js +1 -1
- package/lib/rules/no-var.js +1 -1
- package/lib/rules/no-void.js +1 -1
- package/lib/rules/no-warning-comments.js +1 -1
- package/lib/rules/no-whitespace-before-property.js +1 -1
- package/lib/rules/no-with.js +1 -1
- package/lib/rules/nonblock-statement-body-position.js +1 -1
- package/lib/rules/object-curly-newline.js +1 -1
- package/lib/rules/object-curly-spacing.js +1 -1
- package/lib/rules/object-property-newline.js +1 -1
- package/lib/rules/object-shorthand.js +1 -1
- package/lib/rules/one-var-declaration-per-line.js +1 -1
- package/lib/rules/one-var.js +1 -1
- package/lib/rules/operator-assignment.js +1 -1
- package/lib/rules/operator-linebreak.js +1 -1
- package/lib/rules/padded-blocks.js +1 -1
- package/lib/rules/padding-line-between-statements.js +1 -1
- package/lib/rules/prefer-arrow-callback.js +1 -1
- package/lib/rules/prefer-const.js +1 -1
- package/lib/rules/prefer-destructuring.js +1 -1
- package/lib/rules/prefer-exponentiation-operator.js +1 -1
- package/lib/rules/prefer-named-capture-group.js +1 -1
- package/lib/rules/prefer-numeric-literals.js +1 -1
- package/lib/rules/prefer-object-has-own.js +1 -1
- package/lib/rules/prefer-object-spread.js +1 -1
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-reflect.js +1 -2
- package/lib/rules/prefer-regex-literals.js +1 -1
- package/lib/rules/prefer-rest-params.js +1 -1
- package/lib/rules/prefer-spread.js +1 -1
- package/lib/rules/prefer-template.js +1 -1
- package/lib/rules/quote-props.js +1 -1
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/radix.js +1 -1
- package/lib/rules/require-atomic-updates.js +1 -1
- package/lib/rules/require-await.js +1 -1
- package/lib/rules/require-unicode-regexp.js +1 -1
- package/lib/rules/require-yield.js +1 -1
- package/lib/rules/rest-spread-spacing.js +1 -1
- package/lib/rules/semi-spacing.js +1 -1
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/semi.js +1 -1
- package/lib/rules/sort-imports.js +1 -1
- package/lib/rules/sort-keys.js +1 -1
- package/lib/rules/sort-vars.js +1 -1
- package/lib/rules/space-before-blocks.js +1 -1
- package/lib/rules/space-before-function-paren.js +1 -1
- package/lib/rules/space-in-parens.js +1 -1
- package/lib/rules/space-infix-ops.js +1 -1
- package/lib/rules/space-unary-ops.js +1 -1
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/strict.js +1 -1
- package/lib/rules/switch-colon-spacing.js +1 -1
- package/lib/rules/symbol-description.js +1 -1
- package/lib/rules/template-curly-spacing.js +1 -1
- package/lib/rules/template-tag-spacing.js +1 -1
- package/lib/rules/unicode-bom.js +1 -1
- package/lib/rules/use-isnan.js +1 -1
- package/lib/rules/utils/ast-utils.js +13 -2
- package/lib/rules/utils/fix-tracker.js +10 -2
- package/lib/rules/valid-typeof.js +1 -1
- package/lib/rules/vars-on-top.js +1 -1
- package/lib/rules/wrap-iife.js +1 -1
- package/lib/rules/wrap-regex.js +1 -1
- package/lib/rules/yield-star-spacing.js +1 -1
- package/lib/rules/yoda.js +1 -1
- package/lib/services/suppressions-service.js +289 -0
- package/lib/shared/flags.js +4 -0
- package/lib/shared/types.js +4 -27
- package/lib/types/index.d.ts +30 -7
- package/lib/types/rules.d.ts +14 -0
- package/package.json +9 -9
@@ -15,7 +15,7 @@ const astUtils = require("./utils/ast-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
/** @type {import('../
|
18
|
+
/** @type {import('../types').Rule.RuleModule} */
|
19
19
|
module.exports = {
|
20
20
|
meta: {
|
21
21
|
type: "suggestion",
|
@@ -33,7 +33,7 @@ function isString(node) {
|
|
33
33
|
// Rule Definition
|
34
34
|
//------------------------------------------------------------------------------
|
35
35
|
|
36
|
-
/** @type {import('../
|
36
|
+
/** @type {import('../types').Rule.RuleModule} */
|
37
37
|
module.exports = {
|
38
38
|
meta: {
|
39
39
|
type: "suggestion",
|
@@ -15,7 +15,7 @@ const astUtils = require("./utils/ast-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
/** @type {import('../
|
18
|
+
/** @type {import('../types').Rule.RuleModule} */
|
19
19
|
module.exports = {
|
20
20
|
meta: {
|
21
21
|
type: "suggestion",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Rule Definition
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
/** @type {import('../
|
11
|
+
/** @type {import('../types').Rule.RuleModule} */
|
12
12
|
module.exports = {
|
13
13
|
meta: {
|
14
14
|
type: "suggestion",
|
@@ -11,7 +11,7 @@ const astUtils = require("./utils/ast-utils");
|
|
11
11
|
// Rule Definition
|
12
12
|
//------------------------------------------------------------------------------
|
13
13
|
|
14
|
-
/** @type {import('../
|
14
|
+
/** @type {import('../types').Rule.RuleModule} */
|
15
15
|
module.exports = {
|
16
16
|
meta: {
|
17
17
|
type: "suggestion",
|
@@ -25,41 +25,37 @@ module.exports = {
|
|
25
25
|
schema: {
|
26
26
|
type: "array",
|
27
27
|
items: {
|
28
|
+
type: "object",
|
29
|
+
properties: {
|
30
|
+
object: {
|
31
|
+
type: "string",
|
32
|
+
},
|
33
|
+
property: {
|
34
|
+
type: "string",
|
35
|
+
},
|
36
|
+
allowObjects: {
|
37
|
+
type: "array",
|
38
|
+
items: {
|
39
|
+
type: "string",
|
40
|
+
},
|
41
|
+
uniqueItems: true,
|
42
|
+
},
|
43
|
+
message: {
|
44
|
+
type: "string",
|
45
|
+
},
|
46
|
+
},
|
28
47
|
anyOf: [
|
29
|
-
// `object` and `property` are both optional, but at least one of them must be provided.
|
30
48
|
{
|
31
|
-
type: "object",
|
32
|
-
properties: {
|
33
|
-
object: {
|
34
|
-
type: "string",
|
35
|
-
},
|
36
|
-
property: {
|
37
|
-
type: "string",
|
38
|
-
},
|
39
|
-
message: {
|
40
|
-
type: "string",
|
41
|
-
},
|
42
|
-
},
|
43
|
-
additionalProperties: false,
|
44
49
|
required: ["object"],
|
45
50
|
},
|
46
51
|
{
|
47
|
-
type: "object",
|
48
|
-
properties: {
|
49
|
-
object: {
|
50
|
-
type: "string",
|
51
|
-
},
|
52
|
-
property: {
|
53
|
-
type: "string",
|
54
|
-
},
|
55
|
-
message: {
|
56
|
-
type: "string",
|
57
|
-
},
|
58
|
-
},
|
59
|
-
additionalProperties: false,
|
60
52
|
required: ["property"],
|
61
53
|
},
|
62
54
|
],
|
55
|
+
not: {
|
56
|
+
required: ["allowObjects", "object"],
|
57
|
+
},
|
58
|
+
additionalProperties: false,
|
63
59
|
},
|
64
60
|
uniqueItems: true,
|
65
61
|
},
|
@@ -91,6 +87,7 @@ module.exports = {
|
|
91
87
|
|
92
88
|
if (typeof objectName === "undefined") {
|
93
89
|
globallyRestrictedProperties.set(propertyName, {
|
90
|
+
allowObjects: option.allowObjects,
|
94
91
|
message: option.message,
|
95
92
|
});
|
96
93
|
} else if (typeof propertyName === "undefined") {
|
@@ -108,6 +105,20 @@ module.exports = {
|
|
108
105
|
}
|
109
106
|
});
|
110
107
|
|
108
|
+
/**
|
109
|
+
* Checks if an object name is in the allowed objects list.
|
110
|
+
* @param {string} objectName The name of the object to check
|
111
|
+
* @param {string[]} [allowObjects] The list of objects to allow
|
112
|
+
* @returns {boolean} True if the object is allowed, false otherwise
|
113
|
+
*/
|
114
|
+
function isAllowedObject(objectName, allowObjects) {
|
115
|
+
if (!allowObjects) {
|
116
|
+
return false;
|
117
|
+
}
|
118
|
+
|
119
|
+
return allowObjects.includes(objectName);
|
120
|
+
}
|
121
|
+
|
111
122
|
/**
|
112
123
|
* Checks to see whether a property access is restricted, and reports it if so.
|
113
124
|
* @param {ASTNode} node The node to report
|
@@ -140,7 +151,10 @@ module.exports = {
|
|
140
151
|
message,
|
141
152
|
},
|
142
153
|
});
|
143
|
-
} else if (
|
154
|
+
} else if (
|
155
|
+
globalMatchedProperty &&
|
156
|
+
!isAllowedObject(objectName, globalMatchedProperty.allowObjects)
|
157
|
+
) {
|
144
158
|
const message = globalMatchedProperty.message
|
145
159
|
? ` ${globalMatchedProperty.message}`
|
146
160
|
: "";
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Rule Definition
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
/** @type {import('../
|
11
|
+
/** @type {import('../types').Rule.RuleModule} */
|
12
12
|
module.exports = {
|
13
13
|
meta: {
|
14
14
|
type: "suggestion",
|
@@ -21,7 +21,7 @@ const SENTINEL_TYPE =
|
|
21
21
|
// Rule Definition
|
22
22
|
//------------------------------------------------------------------------------
|
23
23
|
|
24
|
-
/** @type {import('../
|
24
|
+
/** @type {import('../types').Rule.RuleModule} */
|
25
25
|
module.exports = {
|
26
26
|
meta: {
|
27
27
|
type: "suggestion",
|
@@ -11,7 +11,7 @@ const astUtils = require("./utils/ast-utils");
|
|
11
11
|
// Rule Definition
|
12
12
|
//------------------------------------------------------------------------------
|
13
13
|
|
14
|
-
/** @type {import('../
|
14
|
+
/** @type {import('../types').Rule.RuleModule} */
|
15
15
|
module.exports = {
|
16
16
|
meta: {
|
17
17
|
hasSuggestions: true,
|
@@ -30,7 +30,6 @@ module.exports = {
|
|
30
30
|
deprecated: {
|
31
31
|
message:
|
32
32
|
"The original assumption of the rule no longer holds true because of engine optimization.",
|
33
|
-
url: "https://eslint.org/docs/latest/rules/no-return-await",
|
34
33
|
deprecatedSince: "8.46.0",
|
35
34
|
availableUntil: null,
|
36
35
|
replacedBy: [],
|
@@ -12,7 +12,7 @@ const astUtils = require("./utils/ast-utils");
|
|
12
12
|
// Rule Definition
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
|
15
|
-
/** @type {import('../
|
15
|
+
/** @type {import('../types').Rule.RuleModule} */
|
16
16
|
module.exports = {
|
17
17
|
meta: {
|
18
18
|
type: "suggestion",
|
@@ -125,7 +125,7 @@ function eachSelfAssignment(left, right, props, report) {
|
|
125
125
|
// Rule Definition
|
126
126
|
//------------------------------------------------------------------------------
|
127
127
|
|
128
|
-
/** @type {import('../
|
128
|
+
/** @type {import('../types').Rule.RuleModule} */
|
129
129
|
module.exports = {
|
130
130
|
meta: {
|
131
131
|
type: "problem",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
// Rule Definition
|
11
11
|
//------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
/** @type {import('../
|
13
|
+
/** @type {import('../types').Rule.RuleModule} */
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
16
|
type: "problem",
|
@@ -19,7 +19,7 @@ const astUtils = require("./utils/ast-utils");
|
|
19
19
|
// Rule Definition
|
20
20
|
//------------------------------------------------------------------------------
|
21
21
|
|
22
|
-
/** @type {import('../
|
22
|
+
/** @type {import('../types').Rule.RuleModule} */
|
23
23
|
module.exports = {
|
24
24
|
meta: {
|
25
25
|
type: "suggestion",
|
@@ -172,7 +172,7 @@ function getOuterScope(scope) {
|
|
172
172
|
// Rule Definition
|
173
173
|
//------------------------------------------------------------------------------
|
174
174
|
|
175
|
-
/** @type {import('../
|
175
|
+
/** @type {import('../types').Rule.RuleModule} */
|
176
176
|
module.exports = {
|
177
177
|
meta: {
|
178
178
|
type: "problem",
|
@@ -27,7 +27,7 @@ function safelyShadowsUndefined(variable) {
|
|
27
27
|
// Rule Definition
|
28
28
|
//------------------------------------------------------------------------------
|
29
29
|
|
30
|
-
/** @type {import('../
|
30
|
+
/** @type {import('../types').Rule.RuleModule} */
|
31
31
|
module.exports = {
|
32
32
|
meta: {
|
33
33
|
type: "suggestion",
|
package/lib/rules/no-shadow.js
CHANGED
@@ -28,7 +28,7 @@ const SENTINEL_TYPE =
|
|
28
28
|
// Rule Definition
|
29
29
|
//------------------------------------------------------------------------------
|
30
30
|
|
31
|
-
/** @type {import('../
|
31
|
+
/** @type {import('../types').Rule.RuleModule} */
|
32
32
|
module.exports = {
|
33
33
|
meta: {
|
34
34
|
type: "suggestion",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
// Rule Definition
|
11
11
|
//------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
/** @type {import('../
|
13
|
+
/** @type {import('../types').Rule.RuleModule} */
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
16
|
type: "layout",
|
@@ -10,7 +10,7 @@ const astUtils = require("./utils/ast-utils");
|
|
10
10
|
// Rule Definition
|
11
11
|
//------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
/** @type {import('../
|
13
|
+
/** @type {import('../types').Rule.RuleModule} */
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
16
|
type: "problem",
|
package/lib/rules/no-sync.js
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
// Rule Definition
|
11
11
|
//------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
/** @type {import('../
|
13
|
+
/** @type {import('../types').Rule.RuleModule} */
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
16
|
deprecated: {
|
package/lib/rules/no-tabs.js
CHANGED
@@ -17,7 +17,7 @@ const anyNonWhitespaceRegex = /\S/u;
|
|
17
17
|
// Public Interface
|
18
18
|
//------------------------------------------------------------------------------
|
19
19
|
|
20
|
-
/** @type {import('../
|
20
|
+
/** @type {import('../types').Rule.RuleModule} */
|
21
21
|
module.exports = {
|
22
22
|
meta: {
|
23
23
|
deprecated: {
|
package/lib/rules/no-ternary.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
// Rule Definition
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
/** @type {import('../
|
12
|
+
/** @type {import('../types').Rule.RuleModule} */
|
13
13
|
module.exports = {
|
14
14
|
meta: {
|
15
15
|
type: "suggestion",
|
@@ -56,7 +56,7 @@ class SegmentInfo {
|
|
56
56
|
// Rule Definition
|
57
57
|
//------------------------------------------------------------------------------
|
58
58
|
|
59
|
-
/** @type {import('../
|
59
|
+
/** @type {import('../types').Rule.RuleModule} */
|
60
60
|
module.exports = {
|
61
61
|
meta: {
|
62
62
|
type: "problem",
|
@@ -11,7 +11,7 @@ const astUtils = require("./utils/ast-utils");
|
|
11
11
|
// Rule Definition
|
12
12
|
//------------------------------------------------------------------------------
|
13
13
|
|
14
|
-
/** @type {import('../
|
14
|
+
/** @type {import('../types').Rule.RuleModule} */
|
15
15
|
module.exports = {
|
16
16
|
meta: {
|
17
17
|
type: "suggestion",
|
@@ -5,6 +5,14 @@
|
|
5
5
|
*/
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
//------------------------------------------------------------------------------
|
9
|
+
// Typedefs
|
10
|
+
//------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
/**
|
13
|
+
* @import { SourceLocation, SourceRange } from "@eslint/core";
|
14
|
+
*/
|
15
|
+
|
8
16
|
//------------------------------------------------------------------------------
|
9
17
|
// Requirements
|
10
18
|
//------------------------------------------------------------------------------
|
@@ -15,7 +23,7 @@ const astUtils = require("./utils/ast-utils");
|
|
15
23
|
// Rule Definition
|
16
24
|
//------------------------------------------------------------------------------
|
17
25
|
|
18
|
-
/** @type {import('../
|
26
|
+
/** @type {import('../types').Rule.RuleModule} */
|
19
27
|
module.exports = {
|
20
28
|
meta: {
|
21
29
|
deprecated: {
|
@@ -85,8 +93,8 @@ module.exports = {
|
|
85
93
|
/**
|
86
94
|
* Report the error message
|
87
95
|
* @param {ASTNode} node node to report
|
88
|
-
* @param {
|
89
|
-
* @param {
|
96
|
+
* @param {SourceLocation} location range information
|
97
|
+
* @param {SourceRange} fixRange Range based on the whole program
|
90
98
|
* @returns {void}
|
91
99
|
*/
|
92
100
|
function report(node, location, fixRange) {
|
@@ -11,7 +11,7 @@ const astUtils = require("./utils/ast-utils");
|
|
11
11
|
// Rule Definition
|
12
12
|
//------------------------------------------------------------------------------
|
13
13
|
|
14
|
-
/** @type {import('../
|
14
|
+
/** @type {import('../types').Rule.RuleModule} */
|
15
15
|
module.exports = {
|
16
16
|
meta: {
|
17
17
|
type: "suggestion",
|
package/lib/rules/no-undef.js
CHANGED
@@ -23,7 +23,7 @@ function hasTypeOfOperator(node) {
|
|
23
23
|
// Rule Definition
|
24
24
|
//------------------------------------------------------------------------------
|
25
25
|
|
26
|
-
/** @type {import('../
|
26
|
+
/** @type {import('../types').Rule.RuleModule} */
|
27
27
|
module.exports = {
|
28
28
|
meta: {
|
29
29
|
type: "problem",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
// Rule Definition
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
/** @type {import('../
|
11
|
+
/** @type {import('../types').Rule.RuleModule} */
|
12
12
|
module.exports = {
|
13
13
|
meta: {
|
14
14
|
type: "suggestion",
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Rule Definition
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
/** @type {import('../
|
12
|
+
/** @type {import('../types').Rule.RuleModule} */
|
13
13
|
module.exports = {
|
14
14
|
meta: {
|
15
15
|
type: "suggestion",
|
@@ -14,7 +14,7 @@ const astUtils = require("./utils/ast-utils");
|
|
14
14
|
// Rule Definition
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
|
17
|
-
/** @type {import('../
|
17
|
+
/** @type {import('../types').Rule.RuleModule} */
|
18
18
|
module.exports = {
|
19
19
|
meta: {
|
20
20
|
type: "problem",
|
@@ -161,7 +161,7 @@ function updateModifiedFlag(conditions, modifiers) {
|
|
161
161
|
// Rule Definition
|
162
162
|
//------------------------------------------------------------------------------
|
163
163
|
|
164
|
-
/** @type {import('../
|
164
|
+
/** @type {import('../types').Rule.RuleModule} */
|
165
165
|
module.exports = {
|
166
166
|
meta: {
|
167
167
|
type: "problem",
|
@@ -37,7 +37,7 @@ const OR_PRECEDENCE = astUtils.getPrecedence({
|
|
37
37
|
// Rule Definition
|
38
38
|
//------------------------------------------------------------------------------
|
39
39
|
|
40
|
-
/** @type {import('../
|
40
|
+
/** @type {import('../types').Rule.RuleModule} */
|
41
41
|
module.exports = {
|
42
42
|
meta: {
|
43
43
|
type: "suggestion",
|
@@ -74,7 +74,7 @@ function getDifference(arrA, arrB) {
|
|
74
74
|
// Rule Definition
|
75
75
|
//------------------------------------------------------------------------------
|
76
76
|
|
77
|
-
/** @type {import('../
|
77
|
+
/** @type {import('../types').Rule.RuleModule} */
|
78
78
|
module.exports = {
|
79
79
|
meta: {
|
80
80
|
type: "problem",
|
@@ -111,7 +111,7 @@ class ConsecutiveRange {
|
|
111
111
|
// Rule Definition
|
112
112
|
//------------------------------------------------------------------------------
|
113
113
|
|
114
|
-
/** @type {import('../
|
114
|
+
/** @type {import('../types').Rule.RuleModule} */
|
115
115
|
module.exports = {
|
116
116
|
meta: {
|
117
117
|
type: "problem",
|
@@ -20,7 +20,7 @@ const SENTINEL_NODE_TYPE_CONTINUE =
|
|
20
20
|
// Rule Definition
|
21
21
|
//------------------------------------------------------------------------------
|
22
22
|
|
23
|
-
/** @type {import('../
|
23
|
+
/** @type {import('../types').Rule.RuleModule} */
|
24
24
|
module.exports = {
|
25
25
|
meta: {
|
26
26
|
type: "problem",
|
@@ -46,7 +46,7 @@ function isNegation(node) {
|
|
46
46
|
// Rule Definition
|
47
47
|
//------------------------------------------------------------------------------
|
48
48
|
|
49
|
-
/** @type {import('../
|
49
|
+
/** @type {import('../types').Rule.RuleModule} */
|
50
50
|
module.exports = {
|
51
51
|
meta: {
|
52
52
|
type: "problem",
|
@@ -25,7 +25,7 @@ function isDestructuringPattern(node) {
|
|
25
25
|
return node.type === "ObjectPattern" || node.type === "ArrayPattern";
|
26
26
|
}
|
27
27
|
|
28
|
-
/** @type {import('../
|
28
|
+
/** @type {import('../types').Rule.RuleModule} */
|
29
29
|
module.exports = {
|
30
30
|
meta: {
|
31
31
|
type: "problem",
|
@@ -26,7 +26,7 @@ function alwaysFalse() {
|
|
26
26
|
return false;
|
27
27
|
}
|
28
28
|
|
29
|
-
/** @type {import('../
|
29
|
+
/** @type {import('../types').Rule.RuleModule} */
|
30
30
|
module.exports = {
|
31
31
|
meta: {
|
32
32
|
type: "suggestion",
|
@@ -83,61 +83,6 @@ module.exports = {
|
|
83
83
|
},
|
84
84
|
] = context.options;
|
85
85
|
|
86
|
-
/**
|
87
|
-
* Has AST suggesting a directive.
|
88
|
-
* @param {ASTNode} node any node
|
89
|
-
* @returns {boolean} whether the given node structurally represents a directive
|
90
|
-
*/
|
91
|
-
function looksLikeDirective(node) {
|
92
|
-
return (
|
93
|
-
node.type === "ExpressionStatement" &&
|
94
|
-
node.expression.type === "Literal" &&
|
95
|
-
typeof node.expression.value === "string"
|
96
|
-
);
|
97
|
-
}
|
98
|
-
|
99
|
-
/**
|
100
|
-
* Gets the leading sequence of members in a list that pass the predicate.
|
101
|
-
* @param {Function} predicate ([a] -> Boolean) the function used to make the determination
|
102
|
-
* @param {a[]} list the input list
|
103
|
-
* @returns {a[]} the leading sequence of members in the given list that pass the given predicate
|
104
|
-
*/
|
105
|
-
function takeWhile(predicate, list) {
|
106
|
-
for (let i = 0; i < list.length; ++i) {
|
107
|
-
if (!predicate(list[i])) {
|
108
|
-
return list.slice(0, i);
|
109
|
-
}
|
110
|
-
}
|
111
|
-
return list.slice();
|
112
|
-
}
|
113
|
-
|
114
|
-
/**
|
115
|
-
* Gets leading directives nodes in a Node body.
|
116
|
-
* @param {ASTNode} node a Program or BlockStatement node
|
117
|
-
* @returns {ASTNode[]} the leading sequence of directive nodes in the given node's body
|
118
|
-
*/
|
119
|
-
function directives(node) {
|
120
|
-
return takeWhile(looksLikeDirective, node.body);
|
121
|
-
}
|
122
|
-
|
123
|
-
/**
|
124
|
-
* Detect if a Node is a directive.
|
125
|
-
* @param {ASTNode} node any node
|
126
|
-
* @returns {boolean} whether the given node is considered a directive in its current position
|
127
|
-
*/
|
128
|
-
function isDirective(node) {
|
129
|
-
/**
|
130
|
-
* https://tc39.es/ecma262/#directive-prologue
|
131
|
-
*
|
132
|
-
* Only `FunctionBody`, `ScriptBody` and `ModuleBody` can have directive prologue.
|
133
|
-
* Class static blocks do not have directive prologue.
|
134
|
-
*/
|
135
|
-
return (
|
136
|
-
astUtils.isTopLevelExpressionStatement(node) &&
|
137
|
-
directives(node.parent).includes(node)
|
138
|
-
);
|
139
|
-
}
|
140
|
-
|
141
86
|
/**
|
142
87
|
* The member functions return `true` if the type has no side-effects.
|
143
88
|
* Unknown nodes are handled as `false`, then this rule ignores those.
|
@@ -190,13 +135,26 @@ module.exports = {
|
|
190
135
|
UnaryExpression(node) {
|
191
136
|
return node.operator !== "void" && node.operator !== "delete";
|
192
137
|
},
|
138
|
+
// TypeScript-specific node types
|
139
|
+
TSAsExpression(node) {
|
140
|
+
return Checker.isDisallowed(node.expression);
|
141
|
+
},
|
142
|
+
TSTypeAssertion(node) {
|
143
|
+
return Checker.isDisallowed(node.expression);
|
144
|
+
},
|
145
|
+
TSNonNullExpression(node) {
|
146
|
+
return Checker.isDisallowed(node.expression);
|
147
|
+
},
|
148
|
+
TSInstantiationExpression(node) {
|
149
|
+
return Checker.isDisallowed(node.expression);
|
150
|
+
},
|
193
151
|
});
|
194
152
|
|
195
153
|
return {
|
196
154
|
ExpressionStatement(node) {
|
197
155
|
if (
|
198
156
|
Checker.isDisallowed(node.expression) &&
|
199
|
-
!isDirective(node)
|
157
|
+
!astUtils.isDirective(node)
|
200
158
|
) {
|
201
159
|
context.report({ node, messageId: "unusedExpression" });
|
202
160
|
}
|
@@ -15,7 +15,7 @@ const astUtils = require("./utils/ast-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
/** @type {import('../
|
18
|
+
/** @type {import('../types').Rule.RuleModule} */
|
19
19
|
module.exports = {
|
20
20
|
meta: {
|
21
21
|
type: "suggestion",
|