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
@@ -173,7 +173,7 @@ module.exports = {
|
|
173
173
|
docs: {
|
174
174
|
description: "Disallow assignments that can lead to race conditions due to usage of `await` or `yield`",
|
175
175
|
recommended: false,
|
176
|
-
url: "https://eslint.org/docs/rules/require-atomic-updates"
|
176
|
+
url: "https://eslint.org/docs/latest/rules/require-atomic-updates"
|
177
177
|
},
|
178
178
|
|
179
179
|
fixable: null,
|
@@ -198,7 +198,7 @@ module.exports = {
|
|
198
198
|
create(context) {
|
199
199
|
const allowProperties = !!context.options[0] && context.options[0].allowProperties;
|
200
200
|
|
201
|
-
const sourceCode = context.
|
201
|
+
const sourceCode = context.sourceCode;
|
202
202
|
const assignmentReferences = new Map();
|
203
203
|
const segmentInfo = new SegmentInfo();
|
204
204
|
let stack = null;
|
@@ -36,7 +36,7 @@ module.exports = {
|
|
36
36
|
docs: {
|
37
37
|
description: "Disallow async functions which have no `await` expression",
|
38
38
|
recommended: false,
|
39
|
-
url: "https://eslint.org/docs/rules/require-await"
|
39
|
+
url: "https://eslint.org/docs/latest/rules/require-await"
|
40
40
|
},
|
41
41
|
|
42
42
|
schema: [],
|
@@ -47,7 +47,7 @@ module.exports = {
|
|
47
47
|
},
|
48
48
|
|
49
49
|
create(context) {
|
50
|
-
const sourceCode = context.
|
50
|
+
const sourceCode = context.sourceCode;
|
51
51
|
let scopeInfo = null;
|
52
52
|
|
53
53
|
/**
|
@@ -13,7 +13,7 @@ module.exports = {
|
|
13
13
|
docs: {
|
14
14
|
description: "Require JSDoc comments",
|
15
15
|
recommended: false,
|
16
|
-
url: "https://eslint.org/docs/rules/require-jsdoc"
|
16
|
+
url: "https://eslint.org/docs/latest/rules/require-jsdoc"
|
17
17
|
},
|
18
18
|
|
19
19
|
schema: [
|
@@ -61,7 +61,7 @@ module.exports = {
|
|
61
61
|
},
|
62
62
|
|
63
63
|
create(context) {
|
64
|
-
const source = context.
|
64
|
+
const source = context.sourceCode;
|
65
65
|
const DEFAULT_OPTIONS = {
|
66
66
|
FunctionDeclaration: true,
|
67
67
|
MethodDefinition: false,
|
@@ -28,9 +28,9 @@ module.exports = {
|
|
28
28
|
type: "suggestion",
|
29
29
|
|
30
30
|
docs: {
|
31
|
-
description: "Enforce the use of `u` flag on RegExp",
|
31
|
+
description: "Enforce the use of `u` or `v` flag on RegExp",
|
32
32
|
recommended: false,
|
33
|
-
url: "https://eslint.org/docs/rules/require-unicode-regexp"
|
33
|
+
url: "https://eslint.org/docs/latest/rules/require-unicode-regexp"
|
34
34
|
},
|
35
35
|
|
36
36
|
hasSuggestions: true,
|
@@ -45,13 +45,13 @@ module.exports = {
|
|
45
45
|
|
46
46
|
create(context) {
|
47
47
|
|
48
|
-
const sourceCode = context.
|
48
|
+
const sourceCode = context.sourceCode;
|
49
49
|
|
50
50
|
return {
|
51
51
|
"Literal[regex]"(node) {
|
52
52
|
const flags = node.regex.flags || "";
|
53
53
|
|
54
|
-
if (!flags.includes("u")) {
|
54
|
+
if (!flags.includes("u") && !flags.includes("v")) {
|
55
55
|
context.report({
|
56
56
|
messageId: "requireUFlag",
|
57
57
|
node,
|
@@ -85,7 +85,7 @@ module.exports = {
|
|
85
85
|
const pattern = getStringIfConstant(patternNode, scope);
|
86
86
|
const flags = getStringIfConstant(flagsNode, scope);
|
87
87
|
|
88
|
-
if (!flagsNode || (typeof flags === "string" && !flags.includes("u"))) {
|
88
|
+
if (!flagsNode || (typeof flags === "string" && !flags.includes("u") && !flags.includes("v"))) {
|
89
89
|
context.report({
|
90
90
|
messageId: "requireUFlag",
|
91
91
|
node: refNode,
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Enforce spacing between rest and spread operators and their expressions",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/rest-spread-spacing"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/rest-spread-spacing"
|
21
21
|
},
|
22
22
|
|
23
23
|
fixable: "whitespace",
|
@@ -35,7 +35,7 @@ module.exports = {
|
|
35
35
|
},
|
36
36
|
|
37
37
|
create(context) {
|
38
|
-
const sourceCode = context.
|
38
|
+
const sourceCode = context.sourceCode,
|
39
39
|
alwaysSpace = context.options[0] === "always";
|
40
40
|
|
41
41
|
//--------------------------------------------------------------------------
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
19
19
|
docs: {
|
20
20
|
description: "Enforce consistent spacing before and after semicolons",
|
21
21
|
recommended: false,
|
22
|
-
url: "https://eslint.org/docs/rules/semi-spacing"
|
22
|
+
url: "https://eslint.org/docs/latest/rules/semi-spacing"
|
23
23
|
},
|
24
24
|
|
25
25
|
fixable: "whitespace",
|
@@ -52,7 +52,7 @@ module.exports = {
|
|
52
52
|
create(context) {
|
53
53
|
|
54
54
|
const config = context.options[0],
|
55
|
-
sourceCode = context.
|
55
|
+
sourceCode = context.sourceCode;
|
56
56
|
let requireSpaceBefore = false,
|
57
57
|
requireSpaceAfter = true;
|
58
58
|
|
package/lib/rules/semi-style.js
CHANGED
@@ -75,7 +75,7 @@ module.exports = {
|
|
75
75
|
docs: {
|
76
76
|
description: "Enforce location of semicolons",
|
77
77
|
recommended: false,
|
78
|
-
url: "https://eslint.org/docs/rules/semi-style"
|
78
|
+
url: "https://eslint.org/docs/latest/rules/semi-style"
|
79
79
|
},
|
80
80
|
|
81
81
|
schema: [{ enum: ["last", "first"] }],
|
@@ -87,7 +87,7 @@ module.exports = {
|
|
87
87
|
},
|
88
88
|
|
89
89
|
create(context) {
|
90
|
-
const sourceCode = context.
|
90
|
+
const sourceCode = context.sourceCode;
|
91
91
|
const option = context.options[0] || "last";
|
92
92
|
|
93
93
|
/**
|
package/lib/rules/semi.js
CHANGED
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Require or disallow semicolons instead of ASI",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/semi"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/semi"
|
27
27
|
},
|
28
28
|
|
29
29
|
fixable: "code",
|
@@ -58,7 +58,8 @@ module.exports = {
|
|
58
58
|
{
|
59
59
|
type: "object",
|
60
60
|
properties: {
|
61
|
-
omitLastInOneLineBlock: { type: "boolean" }
|
61
|
+
omitLastInOneLineBlock: { type: "boolean" },
|
62
|
+
omitLastInOneLineClassBody: { type: "boolean" }
|
62
63
|
},
|
63
64
|
additionalProperties: false
|
64
65
|
}
|
@@ -83,8 +84,9 @@ module.exports = {
|
|
83
84
|
const options = context.options[1];
|
84
85
|
const never = context.options[0] === "never";
|
85
86
|
const exceptOneLine = Boolean(options && options.omitLastInOneLineBlock);
|
87
|
+
const exceptOneLineClassBody = Boolean(options && options.omitLastInOneLineClassBody);
|
86
88
|
const beforeStatementContinuationChars = options && options.beforeStatementContinuationChars || "any";
|
87
|
-
const sourceCode = context.
|
89
|
+
const sourceCode = context.sourceCode;
|
88
90
|
|
89
91
|
//--------------------------------------------------------------------------
|
90
92
|
// Helpers
|
@@ -334,6 +336,27 @@ module.exports = {
|
|
334
336
|
return false;
|
335
337
|
}
|
336
338
|
|
339
|
+
/**
|
340
|
+
* Checks a node to see if it's the last item in a one-liner `ClassBody` node.
|
341
|
+
* ClassBody is a one-liner if its braces (and consequently everything between them) are on the same line.
|
342
|
+
* @param {ASTNode} node The node to check.
|
343
|
+
* @returns {boolean} whether the node is the last item in a one-liner ClassBody.
|
344
|
+
*/
|
345
|
+
function isLastInOneLinerClassBody(node) {
|
346
|
+
const parent = node.parent;
|
347
|
+
const nextToken = sourceCode.getTokenAfter(node);
|
348
|
+
|
349
|
+
if (!nextToken || nextToken.value !== "}") {
|
350
|
+
return false;
|
351
|
+
}
|
352
|
+
|
353
|
+
if (parent.type === "ClassBody") {
|
354
|
+
return parent.loc.start.line === parent.loc.end.line;
|
355
|
+
}
|
356
|
+
|
357
|
+
return false;
|
358
|
+
}
|
359
|
+
|
337
360
|
/**
|
338
361
|
* Checks a node to see if it's followed by a semicolon.
|
339
362
|
* @param {ASTNode} node The node to check.
|
@@ -354,10 +377,12 @@ module.exports = {
|
|
354
377
|
}
|
355
378
|
} else {
|
356
379
|
const oneLinerBlock = (exceptOneLine && isLastInOneLinerBlock(node));
|
380
|
+
const oneLinerClassBody = (exceptOneLineClassBody && isLastInOneLinerClassBody(node));
|
381
|
+
const oneLinerBlockOrClassBody = oneLinerBlock || oneLinerClassBody;
|
357
382
|
|
358
|
-
if (isSemi &&
|
383
|
+
if (isSemi && oneLinerBlockOrClassBody) {
|
359
384
|
report(node, true);
|
360
|
-
} else if (!isSemi && !
|
385
|
+
} else if (!isSemi && !oneLinerBlockOrClassBody) {
|
361
386
|
report(node);
|
362
387
|
}
|
363
388
|
}
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Enforce sorted import declarations within modules",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/sort-imports"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/sort-imports"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [
|
@@ -71,7 +71,7 @@ module.exports = {
|
|
71
71
|
ignoreMemberSort = configuration.ignoreMemberSort || false,
|
72
72
|
memberSyntaxSortOrder = configuration.memberSyntaxSortOrder || ["none", "all", "multiple", "single"],
|
73
73
|
allowSeparatedGroups = configuration.allowSeparatedGroups || false,
|
74
|
-
sourceCode = context.
|
74
|
+
sourceCode = context.sourceCode;
|
75
75
|
let previousDeclaration = null;
|
76
76
|
|
77
77
|
/**
|
package/lib/rules/sort-keys.js
CHANGED
@@ -83,7 +83,7 @@ module.exports = {
|
|
83
83
|
docs: {
|
84
84
|
description: "Require object keys to be sorted",
|
85
85
|
recommended: false,
|
86
|
-
url: "https://eslint.org/docs/rules/sort-keys"
|
86
|
+
url: "https://eslint.org/docs/latest/rules/sort-keys"
|
87
87
|
},
|
88
88
|
|
89
89
|
schema: [
|
@@ -135,7 +135,7 @@ module.exports = {
|
|
135
135
|
|
136
136
|
// The stack to save the previous property's name for each object literals.
|
137
137
|
let stack = null;
|
138
|
-
const sourceCode = context.
|
138
|
+
const sourceCode = context.sourceCode;
|
139
139
|
|
140
140
|
return {
|
141
141
|
ObjectExpression(node) {
|
package/lib/rules/sort-vars.js
CHANGED
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require variables within the same declaration block to be sorted",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/sort-vars"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/sort-vars"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [
|
@@ -44,7 +44,7 @@ module.exports = {
|
|
44
44
|
|
45
45
|
const configuration = context.options[0] || {},
|
46
46
|
ignoreCase = configuration.ignoreCase || false,
|
47
|
-
sourceCode = context.
|
47
|
+
sourceCode = context.sourceCode;
|
48
48
|
|
49
49
|
return {
|
50
50
|
VariableDeclaration(node) {
|
@@ -42,7 +42,7 @@ module.exports = {
|
|
42
42
|
docs: {
|
43
43
|
description: "Enforce consistent spacing before blocks",
|
44
44
|
recommended: false,
|
45
|
-
url: "https://eslint.org/docs/rules/space-before-blocks"
|
45
|
+
url: "https://eslint.org/docs/latest/rules/space-before-blocks"
|
46
46
|
},
|
47
47
|
|
48
48
|
fixable: "whitespace",
|
@@ -80,7 +80,7 @@ module.exports = {
|
|
80
80
|
|
81
81
|
create(context) {
|
82
82
|
const config = context.options[0],
|
83
|
-
sourceCode = context.
|
83
|
+
sourceCode = context.sourceCode;
|
84
84
|
let alwaysFunctions = true,
|
85
85
|
alwaysKeywords = true,
|
86
86
|
alwaysClasses = true,
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Enforce consistent spacing before `function` definition opening parenthesis",
|
24
24
|
recommended: false,
|
25
|
-
url: "https://eslint.org/docs/rules/space-before-function-paren"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/space-before-function-paren"
|
26
26
|
},
|
27
27
|
|
28
28
|
fixable: "whitespace",
|
@@ -59,7 +59,7 @@ module.exports = {
|
|
59
59
|
},
|
60
60
|
|
61
61
|
create(context) {
|
62
|
-
const sourceCode = context.
|
62
|
+
const sourceCode = context.sourceCode;
|
63
63
|
const baseConfig = typeof context.options[0] === "string" ? context.options[0] : "always";
|
64
64
|
const overrideConfig = typeof context.options[0] === "object" ? context.options[0] : {};
|
65
65
|
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Enforce consistent spacing inside parentheses",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/space-in-parens"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/space-in-parens"
|
22
22
|
},
|
23
23
|
|
24
24
|
fixable: "whitespace",
|
@@ -102,7 +102,7 @@ module.exports = {
|
|
102
102
|
//--------------------------------------------------------------------------
|
103
103
|
// Helpers
|
104
104
|
//--------------------------------------------------------------------------
|
105
|
-
const sourceCode = context.
|
105
|
+
const sourceCode = context.sourceCode;
|
106
106
|
|
107
107
|
/**
|
108
108
|
* Determines if a token is one of the exceptions for the opener paren
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Require spacing around infix operators",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/space-infix-ops"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/space-infix-ops"
|
22
22
|
},
|
23
23
|
|
24
24
|
fixable: "whitespace",
|
@@ -43,7 +43,7 @@ module.exports = {
|
|
43
43
|
|
44
44
|
create(context) {
|
45
45
|
const int32Hint = context.options[0] ? context.options[0].int32Hint === true : false;
|
46
|
-
const sourceCode = context.
|
46
|
+
const sourceCode = context.sourceCode;
|
47
47
|
|
48
48
|
/**
|
49
49
|
* Returns the first token which violates the rule
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Enforce consistent spacing before or after unary operators",
|
24
24
|
recommended: false,
|
25
|
-
url: "https://eslint.org/docs/rules/space-unary-ops"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/space-unary-ops"
|
26
26
|
},
|
27
27
|
|
28
28
|
fixable: "whitespace",
|
@@ -62,7 +62,7 @@ module.exports = {
|
|
62
62
|
create(context) {
|
63
63
|
const options = context.options[0] || { words: true, nonwords: false };
|
64
64
|
|
65
|
-
const sourceCode = context.
|
65
|
+
const sourceCode = context.sourceCode;
|
66
66
|
|
67
67
|
//--------------------------------------------------------------------------
|
68
68
|
// Helpers
|
@@ -154,7 +154,7 @@ module.exports = {
|
|
154
154
|
docs: {
|
155
155
|
description: "Enforce consistent spacing after the `//` or `/*` in a comment",
|
156
156
|
recommended: false,
|
157
|
-
url: "https://eslint.org/docs/rules/spaced-comment"
|
157
|
+
url: "https://eslint.org/docs/latest/rules/spaced-comment"
|
158
158
|
},
|
159
159
|
|
160
160
|
fixable: "whitespace",
|
@@ -235,7 +235,7 @@ module.exports = {
|
|
235
235
|
|
236
236
|
create(context) {
|
237
237
|
|
238
|
-
const sourceCode = context.
|
238
|
+
const sourceCode = context.sourceCode;
|
239
239
|
|
240
240
|
// Unless the first option is never, require a space
|
241
241
|
const requireSpace = context.options[0] !== "never";
|
package/lib/rules/strict.js
CHANGED
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Enforce spacing around colons of switch statements",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/switch-colon-spacing"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/switch-colon-spacing"
|
27
27
|
},
|
28
28
|
|
29
29
|
schema: [
|
@@ -46,7 +46,7 @@ module.exports = {
|
|
46
46
|
},
|
47
47
|
|
48
48
|
create(context) {
|
49
|
-
const sourceCode = context.
|
49
|
+
const sourceCode = context.sourceCode;
|
50
50
|
const options = context.options[0] || {};
|
51
51
|
const beforeSpacing = options.before === true; // false by default
|
52
52
|
const afterSpacing = options.after !== false; // true by default
|
@@ -24,7 +24,7 @@ module.exports = {
|
|
24
24
|
docs: {
|
25
25
|
description: "Require symbol descriptions",
|
26
26
|
recommended: false,
|
27
|
-
url: "https://eslint.org/docs/rules/symbol-description"
|
27
|
+
url: "https://eslint.org/docs/latest/rules/symbol-description"
|
28
28
|
},
|
29
29
|
fixable: null,
|
30
30
|
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
|
/**
|
41
41
|
* Reports if node does not conform the rule in case rule is set to
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Require or disallow spacing around embedded expressions of template strings",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/template-curly-spacing"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/template-curly-spacing"
|
27
27
|
},
|
28
28
|
|
29
29
|
fixable: "whitespace",
|
@@ -40,7 +40,7 @@ module.exports = {
|
|
40
40
|
},
|
41
41
|
|
42
42
|
create(context) {
|
43
|
-
const sourceCode = context.
|
43
|
+
const sourceCode = context.sourceCode;
|
44
44
|
const always = context.options[0] === "always";
|
45
45
|
|
46
46
|
/**
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require or disallow spacing between template tags and their literals",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/template-tag-spacing"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/template-tag-spacing"
|
21
21
|
},
|
22
22
|
|
23
23
|
fixable: "whitespace",
|
@@ -33,7 +33,7 @@ module.exports = {
|
|
33
33
|
|
34
34
|
create(context) {
|
35
35
|
const never = context.options[0] !== "always";
|
36
|
-
const sourceCode = context.
|
36
|
+
const sourceCode = context.sourceCode;
|
37
37
|
|
38
38
|
/**
|
39
39
|
* Check if a space is present between a template tag and its literal
|
package/lib/rules/unicode-bom.js
CHANGED
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Require or disallow Unicode byte order mark (BOM)",
|
18
18
|
recommended: false,
|
19
|
-
url: "https://eslint.org/docs/rules/unicode-bom"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/unicode-bom"
|
20
20
|
},
|
21
21
|
|
22
22
|
fixable: "whitespace",
|
@@ -42,7 +42,7 @@ module.exports = {
|
|
42
42
|
|
43
43
|
Program: function checkUnicodeBOM(node) {
|
44
44
|
|
45
|
-
const sourceCode = context.
|
45
|
+
const sourceCode = context.sourceCode,
|
46
46
|
location = { column: 0, line: 1 },
|
47
47
|
requireBOM = context.options[0] || "never";
|
48
48
|
|
package/lib/rules/use-isnan.js
CHANGED
@@ -9,6 +9,7 @@
|
|
9
9
|
// Requirements
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
+
const { KEYS: eslintVisitorKeys } = require("eslint-visitor-keys");
|
12
13
|
const esutils = require("esutils");
|
13
14
|
const espree = require("espree");
|
14
15
|
const escapeRegExp = require("escape-string-regexp");
|
@@ -25,8 +26,8 @@ const {
|
|
25
26
|
|
26
27
|
const anyFunctionPattern = /^(?:Function(?:Declaration|Expression)|ArrowFunctionExpression)$/u;
|
27
28
|
const anyLoopPattern = /^(?:DoWhile|For|ForIn|ForOf|While)Statement$/u;
|
29
|
+
const arrayMethodWithThisArgPattern = /^(?:every|filter|find(?:Last)?(?:Index)?|flatMap|forEach|map|some)$/u;
|
28
30
|
const arrayOrTypedArrayPattern = /Array$/u;
|
29
|
-
const arrayMethodPattern = /^(?:every|filter|find|findIndex|forEach|map|some)$/u;
|
30
31
|
const bindOrCallOrApplyPattern = /^(?:bind|call|apply)$/u;
|
31
32
|
const thisTagPattern = /^[\s*]*@this/mu;
|
32
33
|
|
@@ -466,12 +467,12 @@ function isArrayFromMethod(node) {
|
|
466
467
|
}
|
467
468
|
|
468
469
|
/**
|
469
|
-
* Checks whether or not a node is a method which
|
470
|
+
* Checks whether or not a node is a method which expects a function as a first argument, and `thisArg` as a second argument.
|
470
471
|
* @param {ASTNode} node A node to check.
|
471
|
-
* @returns {boolean} Whether or not the node is a method which
|
472
|
+
* @returns {boolean} Whether or not the node is a method which expects a function as a first argument, and `thisArg` as a second argument.
|
472
473
|
*/
|
473
474
|
function isMethodWhichHasThisArg(node) {
|
474
|
-
return isSpecificMemberAccess(node, null,
|
475
|
+
return isSpecificMemberAccess(node, null, arrayMethodWithThisArgPattern);
|
475
476
|
}
|
476
477
|
|
477
478
|
/**
|
@@ -986,6 +987,34 @@ function isConstant(scope, node, inBooleanPosition) {
|
|
986
987
|
return false;
|
987
988
|
}
|
988
989
|
|
990
|
+
/**
|
991
|
+
* Checks whether a node is an ExpressionStatement at the top level of a file or function body.
|
992
|
+
* A top-level ExpressionStatement node is a directive if it contains a single unparenthesized
|
993
|
+
* string literal and if it occurs either as the first sibling or immediately after another
|
994
|
+
* directive.
|
995
|
+
* @param {ASTNode} node The node to check.
|
996
|
+
* @returns {boolean} Whether or not the node is an ExpressionStatement at the top level of a
|
997
|
+
* file or function body.
|
998
|
+
*/
|
999
|
+
function isTopLevelExpressionStatement(node) {
|
1000
|
+
if (node.type !== "ExpressionStatement") {
|
1001
|
+
return false;
|
1002
|
+
}
|
1003
|
+
const parent = node.parent;
|
1004
|
+
|
1005
|
+
return parent.type === "Program" || (parent.type === "BlockStatement" && isFunction(parent.parent));
|
1006
|
+
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
/**
|
1010
|
+
* Check whether the given node is a part of a directive prologue or not.
|
1011
|
+
* @param {ASTNode} node The node to check.
|
1012
|
+
* @returns {boolean} `true` if the node is a part of directive prologue.
|
1013
|
+
*/
|
1014
|
+
function isDirective(node) {
|
1015
|
+
return node.type === "ExpressionStatement" && typeof node.directive === "string";
|
1016
|
+
}
|
1017
|
+
|
989
1018
|
//------------------------------------------------------------------------------
|
990
1019
|
// Public Interface
|
991
1020
|
//------------------------------------------------------------------------------
|
@@ -1442,7 +1471,16 @@ module.exports = {
|
|
1442
1471
|
return 19;
|
1443
1472
|
|
1444
1473
|
default:
|
1445
|
-
|
1474
|
+
if (node.type in eslintVisitorKeys) {
|
1475
|
+
return 20;
|
1476
|
+
}
|
1477
|
+
|
1478
|
+
/*
|
1479
|
+
* if the node is not a standard node that we know about, then assume it has the lowest precedence
|
1480
|
+
* this will mean that rules will wrap unknown nodes in parentheses where applicable instead of
|
1481
|
+
* unwrapping them and potentially changing the meaning of the code or introducing a syntax error.
|
1482
|
+
*/
|
1483
|
+
return -1;
|
1446
1484
|
}
|
1447
1485
|
},
|
1448
1486
|
|
@@ -1501,7 +1539,6 @@ module.exports = {
|
|
1501
1539
|
return directives;
|
1502
1540
|
},
|
1503
1541
|
|
1504
|
-
|
1505
1542
|
/**
|
1506
1543
|
* Determines whether this node is a decimal integer literal. If a node is a decimal integer literal, a dot added
|
1507
1544
|
* after the node will be parsed as a decimal point, rather than a property-access dot.
|
@@ -2105,6 +2142,15 @@ module.exports = {
|
|
2105
2142
|
return OCTAL_OR_NON_OCTAL_DECIMAL_ESCAPE_PATTERN.test(rawString);
|
2106
2143
|
},
|
2107
2144
|
|
2145
|
+
/**
|
2146
|
+
* Determines whether the given node is a template literal without expressions.
|
2147
|
+
* @param {ASTNode} node Node to check.
|
2148
|
+
* @returns {boolean} True if the node is a template literal without expressions.
|
2149
|
+
*/
|
2150
|
+
isStaticTemplateLiteral(node) {
|
2151
|
+
return node.type === "TemplateLiteral" && node.expressions.length === 0;
|
2152
|
+
},
|
2153
|
+
|
2108
2154
|
isReferenceToGlobalVariable,
|
2109
2155
|
isLogicalExpression,
|
2110
2156
|
isCoalesceExpression,
|
@@ -2120,5 +2166,7 @@ module.exports = {
|
|
2120
2166
|
isLogicalAssignmentOperator,
|
2121
2167
|
getSwitchCaseColonToken,
|
2122
2168
|
getModuleExportName,
|
2123
|
-
isConstant
|
2169
|
+
isConstant,
|
2170
|
+
isTopLevelExpressionStatement,
|
2171
|
+
isDirective
|
2124
2172
|
};
|
@@ -8,7 +8,7 @@
|
|
8
8
|
|
9
9
|
const { RegExpValidator } = require("@eslint-community/regexpp");
|
10
10
|
|
11
|
-
const REGEXPP_LATEST_ECMA_VERSION =
|
11
|
+
const REGEXPP_LATEST_ECMA_VERSION = 2024;
|
12
12
|
|
13
13
|
/**
|
14
14
|
* Checks if the given regular expression pattern would be valid with the `u` flag.
|
@@ -28,7 +28,7 @@ function isValidWithUnicodeFlag(ecmaVersion, pattern) {
|
|
28
28
|
});
|
29
29
|
|
30
30
|
try {
|
31
|
-
validator.validatePattern(pattern, void 0, void 0, /* uFlag = */ true);
|
31
|
+
validator.validatePattern(pattern, void 0, void 0, { unicode: /* uFlag = */ true });
|
32
32
|
} catch {
|
33
33
|
return false;
|
34
34
|
}
|