eslint 8.38.0 → 8.40.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 -7
- package/lib/config/flat-config-schema.js +57 -35
- package/lib/eslint/flat-eslint.js +56 -16
- package/lib/linter/linter.js +7 -35
- package/lib/rules/accessor-pairs.js +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- package/lib/rules/max-classes-per-file.js +1 -1
- package/lib/rules/max-depth.js +1 -1
- package/lib/rules/max-len.js +2 -2
- 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 -2
- 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 +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 +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 +1 -1
- package/lib/rules/no-empty-function.js +2 -2
- package/lib/rules/no-empty-pattern.js +1 -1
- 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 +2 -2
- package/lib/rules/no-extra-semi.js +3 -3
- 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 +1 -1
- package/lib/rules/no-invalid-this.js +2 -2
- package/lib/rules/no-irregular-whitespace.js +2 -2
- 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 +3 -3
- package/lib/rules/no-lonely-if.js +4 -5
- package/lib/rules/no-loop-func.js +2 -2
- package/lib/rules/no-loss-of-precision.js +1 -1
- package/lib/rules/no-magic-numbers.js +1 -1
- package/lib/rules/no-misleading-character-class.js +2 -2
- 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 +1 -1
- 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 +2 -2
- 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 +1 -1
- 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 +3 -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 +6 -8
- package/lib/rules/no-unused-labels.js +2 -2
- package/lib/rules/no-unused-private-class-members.js +1 -1
- package/lib/rules/no-unused-vars.js +2 -2
- package/lib/rules/no-use-before-define.js +2 -2
- package/lib/rules/no-useless-backreference.js +2 -2
- 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 +2 -2
- package/lib/rules/no-useless-rename.js +2 -2
- package/lib/rules/no-useless-return.js +2 -2
- 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 +4 -4
- 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 +2 -2
- package/lib/rules/prefer-named-capture-group.js +2 -2
- 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 -3
- 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 +2 -2
- 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 +2 -2
- 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 +2 -2
- 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/valid-jsdoc.js +2 -2
- package/lib/rules/valid-typeof.js +3 -3
- package/lib/rules/vars-on-top.js +1 -1
- package/lib/rules/wrap-iife.js +2 -2
- package/lib/rules/wrap-regex.js +4 -5
- package/lib/rules/yield-star-spacing.js +2 -2
- package/lib/rules/yoda.js +3 -3
- package/lib/shared/string-utils.js +39 -1
- package/lib/source-code/source-code.js +47 -4
- package/lib/source-code/token-store/utils.js +21 -16
- 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 +6 -6
@@ -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
package/lib/rules/valid-jsdoc.js
CHANGED
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Enforce valid JSDoc comments",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/valid-jsdoc"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/valid-jsdoc"
|
27
27
|
},
|
28
28
|
|
29
29
|
schema: [
|
@@ -96,7 +96,7 @@ module.exports = {
|
|
96
96
|
|
97
97
|
const options = context.options[0] || {},
|
98
98
|
prefer = options.prefer || {},
|
99
|
-
sourceCode = context.
|
99
|
+
sourceCode = context.sourceCode,
|
100
100
|
|
101
101
|
// these both default to true, so you have to explicitly make them false
|
102
102
|
requireReturn = options.requireReturn !== false,
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Enforce comparing `typeof` expressions against valid strings",
|
18
18
|
recommended: true,
|
19
|
-
url: "https://eslint.org/docs/rules/valid-typeof"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/valid-typeof"
|
20
20
|
},
|
21
21
|
|
22
22
|
hasSuggestions: true,
|
@@ -44,7 +44,7 @@ module.exports = {
|
|
44
44
|
|
45
45
|
const VALID_TYPES = new Set(["symbol", "undefined", "object", "boolean", "number", "string", "function", "bigint"]),
|
46
46
|
OPERATORS = new Set(["==", "===", "!=", "!=="]);
|
47
|
-
const sourceCode = context.
|
47
|
+
const sourceCode = context.sourceCode;
|
48
48
|
const requireStringLiterals = context.options[0] && context.options[0].requireStringLiterals;
|
49
49
|
|
50
50
|
let globalScope;
|
@@ -83,7 +83,7 @@ module.exports = {
|
|
83
83
|
|
84
84
|
UnaryExpression(node) {
|
85
85
|
if (isTypeofExpression(node)) {
|
86
|
-
const parent =
|
86
|
+
const { parent } = node;
|
87
87
|
|
88
88
|
if (parent.type === "BinaryExpression" && OPERATORS.has(parent.operator)) {
|
89
89
|
const sibling = parent.left === node ? parent.right : parent.left;
|
package/lib/rules/vars-on-top.js
CHANGED
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require `var` declarations be placed at the top of their containing scope",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/vars-on-top"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/vars-on-top"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
package/lib/rules/wrap-iife.js
CHANGED
@@ -45,7 +45,7 @@ module.exports = {
|
|
45
45
|
docs: {
|
46
46
|
description: "Require parentheses around immediate `function` invocations",
|
47
47
|
recommended: false,
|
48
|
-
url: "https://eslint.org/docs/rules/wrap-iife"
|
48
|
+
url: "https://eslint.org/docs/latest/rules/wrap-iife"
|
49
49
|
},
|
50
50
|
|
51
51
|
schema: [
|
@@ -77,7 +77,7 @@ module.exports = {
|
|
77
77
|
const style = context.options[0] || "outside";
|
78
78
|
const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods;
|
79
79
|
|
80
|
-
const sourceCode = context.
|
80
|
+
const sourceCode = context.sourceCode;
|
81
81
|
|
82
82
|
/**
|
83
83
|
* Check if the node is wrapped in any (). All parens count: grouping parens and parens for constructs such as if()
|
package/lib/rules/wrap-regex.js
CHANGED
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require parenthesis around regex literals",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/wrap-regex"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/wrap-regex"
|
21
21
|
},
|
22
22
|
|
23
23
|
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
|
return {
|
35
35
|
|
@@ -40,10 +40,9 @@ module.exports = {
|
|
40
40
|
if (nodeType === "RegularExpression") {
|
41
41
|
const beforeToken = sourceCode.getTokenBefore(node);
|
42
42
|
const afterToken = sourceCode.getTokenAfter(node);
|
43
|
-
const
|
44
|
-
const grandparent = ancestors[ancestors.length - 1];
|
43
|
+
const { parent } = node;
|
45
44
|
|
46
|
-
if (
|
45
|
+
if (parent.type === "MemberExpression" && parent.object === node &&
|
47
46
|
!(beforeToken && beforeToken.value === "(" && afterToken && afterToken.value === ")")) {
|
48
47
|
context.report({
|
49
48
|
node,
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require or disallow spacing around the `*` in `yield*` expressions",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/yield-star-spacing"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/yield-star-spacing"
|
21
21
|
},
|
22
22
|
|
23
23
|
fixable: "whitespace",
|
@@ -48,7 +48,7 @@ module.exports = {
|
|
48
48
|
},
|
49
49
|
|
50
50
|
create(context) {
|
51
|
-
const sourceCode = context.
|
51
|
+
const sourceCode = context.sourceCode;
|
52
52
|
|
53
53
|
const mode = (function(option) {
|
54
54
|
if (!option || typeof option === "string") {
|
package/lib/rules/yoda.js
CHANGED
@@ -123,7 +123,7 @@ module.exports = {
|
|
123
123
|
docs: {
|
124
124
|
description: 'Require or disallow "Yoda" conditions',
|
125
125
|
recommended: false,
|
126
|
-
url: "https://eslint.org/docs/rules/yoda"
|
126
|
+
url: "https://eslint.org/docs/latest/rules/yoda"
|
127
127
|
},
|
128
128
|
|
129
129
|
schema: [
|
@@ -162,7 +162,7 @@ module.exports = {
|
|
162
162
|
const onlyEquality =
|
163
163
|
context.options[1] && context.options[1].onlyEquality;
|
164
164
|
|
165
|
-
const sourceCode = context.
|
165
|
+
const sourceCode = context.sourceCode;
|
166
166
|
|
167
167
|
/**
|
168
168
|
* Determines whether node represents a range test.
|
@@ -343,7 +343,7 @@ module.exports = {
|
|
343
343
|
) &&
|
344
344
|
!(!isEqualityOperator(node.operator) && onlyEquality) &&
|
345
345
|
isComparisonOperator(node.operator) &&
|
346
|
-
!(exceptRange && isRangeTest(
|
346
|
+
!(exceptRange && isRangeTest(node.parent))
|
347
347
|
) {
|
348
348
|
context.report({
|
349
349
|
node,
|
@@ -5,6 +5,26 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
//------------------------------------------------------------------------------
|
9
|
+
// Requirements
|
10
|
+
//------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
const GraphemeSplitter = require("grapheme-splitter");
|
13
|
+
|
14
|
+
//------------------------------------------------------------------------------
|
15
|
+
// Helpers
|
16
|
+
//------------------------------------------------------------------------------
|
17
|
+
|
18
|
+
// eslint-disable-next-line no-control-regex -- intentionally including control characters
|
19
|
+
const ASCII_REGEX = /^[\u0000-\u007f]*$/u;
|
20
|
+
|
21
|
+
/** @type {GraphemeSplitter | undefined} */
|
22
|
+
let splitter;
|
23
|
+
|
24
|
+
//------------------------------------------------------------------------------
|
25
|
+
// Public Interface
|
26
|
+
//------------------------------------------------------------------------------
|
27
|
+
|
8
28
|
/**
|
9
29
|
* Converts the first letter of a string to uppercase.
|
10
30
|
* @param {string} string The string to operate on
|
@@ -17,6 +37,24 @@ function upperCaseFirst(string) {
|
|
17
37
|
return string[0].toUpperCase() + string.slice(1);
|
18
38
|
}
|
19
39
|
|
40
|
+
/**
|
41
|
+
* Counts graphemes in a given string.
|
42
|
+
* @param {string} value A string to count graphemes.
|
43
|
+
* @returns {number} The number of graphemes in `value`.
|
44
|
+
*/
|
45
|
+
function getGraphemeCount(value) {
|
46
|
+
if (ASCII_REGEX.test(value)) {
|
47
|
+
return value.length;
|
48
|
+
}
|
49
|
+
|
50
|
+
if (!splitter) {
|
51
|
+
splitter = new GraphemeSplitter();
|
52
|
+
}
|
53
|
+
|
54
|
+
return splitter.countGraphemes(value);
|
55
|
+
}
|
56
|
+
|
20
57
|
module.exports = {
|
21
|
-
upperCaseFirst
|
58
|
+
upperCaseFirst,
|
59
|
+
getGraphemeCount
|
22
60
|
};
|
@@ -646,12 +646,12 @@ class SourceCode extends TokenStore {
|
|
646
646
|
}
|
647
647
|
|
648
648
|
/**
|
649
|
-
*
|
650
|
-
*
|
649
|
+
* Get the variables that `node` defines.
|
650
|
+
* This is a convenience method that passes through
|
651
651
|
* to the same method on the `scopeManager`.
|
652
|
-
* @param {ASTNode} node The node
|
652
|
+
* @param {ASTNode} node The node for which the variables are obtained.
|
653
653
|
* @returns {Array<Variable>} An array of variable nodes representing
|
654
|
-
* the
|
654
|
+
* the variables that `node` defines.
|
655
655
|
*/
|
656
656
|
getDeclaredVariables(node) {
|
657
657
|
return this.scopeManager.getDeclaredVariables(node);
|
@@ -681,6 +681,49 @@ class SourceCode extends TokenStore {
|
|
681
681
|
}
|
682
682
|
/* eslint-enable class-methods-use-this -- node is owned by SourceCode */
|
683
683
|
|
684
|
+
/**
|
685
|
+
* Marks a variable as used in the current scope
|
686
|
+
* @param {string} name The name of the variable to mark as used.
|
687
|
+
* @param {ASTNode} [refNode] The closest node to the variable reference.
|
688
|
+
* @returns {boolean} True if the variable was found and marked as used, false if not.
|
689
|
+
*/
|
690
|
+
markVariableAsUsed(name, refNode = this.ast) {
|
691
|
+
|
692
|
+
const currentScope = this.getScope(refNode);
|
693
|
+
let initialScope = currentScope;
|
694
|
+
|
695
|
+
/*
|
696
|
+
* When we are in an ESM or CommonJS module, we need to start searching
|
697
|
+
* from the top-level scope, not the global scope. For ESM the top-level
|
698
|
+
* scope is the module scope; for CommonJS the top-level scope is the
|
699
|
+
* outer function scope.
|
700
|
+
*
|
701
|
+
* Without this check, we might miss a variable declared with `var` at
|
702
|
+
* the top-level because it won't exist in the global scope.
|
703
|
+
*/
|
704
|
+
if (
|
705
|
+
currentScope.type === "global" &&
|
706
|
+
currentScope.childScopes.length > 0 &&
|
707
|
+
|
708
|
+
// top-level scopes refer to a `Program` node
|
709
|
+
currentScope.childScopes[0].block === this.ast
|
710
|
+
) {
|
711
|
+
initialScope = currentScope.childScopes[0];
|
712
|
+
}
|
713
|
+
|
714
|
+
for (let scope = initialScope; scope; scope = scope.upper) {
|
715
|
+
const variable = scope.variables.find(scopeVar => scopeVar.name === name);
|
716
|
+
|
717
|
+
if (variable) {
|
718
|
+
variable.eslintUsed = true;
|
719
|
+
return true;
|
720
|
+
}
|
721
|
+
}
|
722
|
+
|
723
|
+
return false;
|
724
|
+
}
|
725
|
+
|
726
|
+
|
684
727
|
}
|
685
728
|
|
686
729
|
module.exports = SourceCode;
|
@@ -4,20 +4,6 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
-
//------------------------------------------------------------------------------
|
8
|
-
// Helpers
|
9
|
-
//------------------------------------------------------------------------------
|
10
|
-
|
11
|
-
/**
|
12
|
-
* Gets `token.range[0]` from the given token.
|
13
|
-
* @param {Node|Token|Comment} token The token to get.
|
14
|
-
* @returns {number} The start location.
|
15
|
-
* @private
|
16
|
-
*/
|
17
|
-
function getStartLocation(token) {
|
18
|
-
return token.range[0];
|
19
|
-
}
|
20
|
-
|
21
7
|
//------------------------------------------------------------------------------
|
22
8
|
// Exports
|
23
9
|
//------------------------------------------------------------------------------
|
@@ -30,9 +16,28 @@ function getStartLocation(token) {
|
|
30
16
|
* @returns {number} The found index or `tokens.length`.
|
31
17
|
*/
|
32
18
|
exports.search = function search(tokens, location) {
|
33
|
-
|
19
|
+
for (let minIndex = 0, maxIndex = tokens.length - 1; minIndex <= maxIndex;) {
|
34
20
|
|
35
|
-
|
21
|
+
/*
|
22
|
+
* Calculate the index in the middle between minIndex and maxIndex.
|
23
|
+
* `| 0` is used to round a fractional value down to the nearest integer: this is similar to
|
24
|
+
* using `Math.trunc()` or `Math.floor()`, but performance tests have shown this method to
|
25
|
+
* be faster.
|
26
|
+
*/
|
27
|
+
const index = (minIndex + maxIndex) / 2 | 0;
|
28
|
+
const token = tokens[index];
|
29
|
+
const tokenStartLocation = token.range[0];
|
30
|
+
|
31
|
+
if (location <= tokenStartLocation) {
|
32
|
+
if (index === minIndex) {
|
33
|
+
return index;
|
34
|
+
}
|
35
|
+
maxIndex = index;
|
36
|
+
} else {
|
37
|
+
minIndex = index + 1;
|
38
|
+
}
|
39
|
+
}
|
40
|
+
return tokens.length;
|
36
41
|
};
|
37
42
|
|
38
43
|
/**
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const { stringifyValueForError } = require("./shared");
|
4
|
+
|
5
|
+
module.exports = function({ ruleId, value }) {
|
6
|
+
return `
|
7
|
+
Configuration for rule "${ruleId}" is invalid. Each rule must have a severity ("off", 0, "warn", 1, "error", or 2) and may be followed by additional options for the rule.
|
8
|
+
|
9
|
+
You passed '${stringifyValueForError(value, 4)}', which doesn't contain a valid severity.
|
10
|
+
|
11
|
+
If you're attempting to configure rule options, perhaps you meant:
|
12
|
+
|
13
|
+
"${ruleId}": ["error", ${stringifyValueForError(value, 8)}]
|
14
|
+
|
15
|
+
See https://eslint.org/docs/latest/use/configure/rules#using-configuration-files for configuring rules.
|
16
|
+
`.trimStart();
|
17
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const { stringifyValueForError } = require("./shared");
|
4
|
+
|
5
|
+
module.exports = function({ ruleId, value }) {
|
6
|
+
return `
|
7
|
+
Configuration for rule "${ruleId}" is invalid. Expected severity of "off", 0, "warn", 1, "error", or 2.
|
8
|
+
|
9
|
+
You passed '${stringifyValueForError(value, 4)}'.
|
10
|
+
|
11
|
+
See https://eslint.org/docs/latest/use/configure/rules#using-configuration-files for configuring rules.
|
12
|
+
`.trimStart();
|
13
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Shared utilities for error messages.
|
3
|
+
* @author Josh Goldberg
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Converts a value to a string that may be printed in errors.
|
10
|
+
* @param {any} value The invalid value.
|
11
|
+
* @param {number} indentation How many spaces to indent
|
12
|
+
* @returns {string} The value, stringified.
|
13
|
+
*/
|
14
|
+
function stringifyValueForError(value, indentation) {
|
15
|
+
return value ? JSON.stringify(value, null, 4).replace(/\n/gu, `\n${" ".repeat(indentation)}`) : `${value}`;
|
16
|
+
}
|
17
|
+
|
18
|
+
module.exports = { stringifyValueForError };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.40.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -62,8 +62,8 @@
|
|
62
62
|
"dependencies": {
|
63
63
|
"@eslint-community/eslint-utils": "^4.2.0",
|
64
64
|
"@eslint-community/regexpp": "^4.4.0",
|
65
|
-
"@eslint/eslintrc": "^2.0.
|
66
|
-
"@eslint/js": "8.
|
65
|
+
"@eslint/eslintrc": "^2.0.3",
|
66
|
+
"@eslint/js": "8.40.0",
|
67
67
|
"@humanwhocodes/config-array": "^0.11.8",
|
68
68
|
"@humanwhocodes/module-importer": "^1.0.1",
|
69
69
|
"@nodelib/fs.walk": "^1.2.8",
|
@@ -73,9 +73,9 @@
|
|
73
73
|
"debug": "^4.3.2",
|
74
74
|
"doctrine": "^3.0.0",
|
75
75
|
"escape-string-regexp": "^4.0.0",
|
76
|
-
"eslint-scope": "^7.
|
77
|
-
"eslint-visitor-keys": "^3.4.
|
78
|
-
"espree": "^9.5.
|
76
|
+
"eslint-scope": "^7.2.0",
|
77
|
+
"eslint-visitor-keys": "^3.4.1",
|
78
|
+
"espree": "^9.5.2",
|
79
79
|
"esquery": "^1.4.2",
|
80
80
|
"esutils": "^2.0.2",
|
81
81
|
"fast-deep-equal": "^3.1.3",
|