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
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Disallow declarations in the global scope",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/no-implicit-globals"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/no-implicit-globals"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [{
|
@@ -43,7 +43,7 @@ module.exports = {
|
|
43
43
|
create(context) {
|
44
44
|
|
45
45
|
const checkLexicalBindings = context.options[0] && context.options[0].lexicalBindings === true;
|
46
|
-
const sourceCode = context.
|
46
|
+
const sourceCode = context.sourceCode;
|
47
47
|
|
48
48
|
/**
|
49
49
|
* Reports the node.
|
@@ -24,7 +24,7 @@ module.exports = {
|
|
24
24
|
docs: {
|
25
25
|
description: "Disallow the use of `eval()`-like methods",
|
26
26
|
recommended: false,
|
27
|
-
url: "https://eslint.org/docs/rules/no-implied-eval"
|
27
|
+
url: "https://eslint.org/docs/latest/rules/no-implied-eval"
|
28
28
|
},
|
29
29
|
|
30
30
|
schema: [],
|
@@ -37,7 +37,7 @@ module.exports = {
|
|
37
37
|
create(context) {
|
38
38
|
const GLOBAL_CANDIDATES = Object.freeze(["global", "window", "globalThis"]);
|
39
39
|
const EVAL_LIKE_FUNC_PATTERN = /^(?:set(?:Interval|Timeout)|execScript)$/u;
|
40
|
-
const sourceCode = context.
|
40
|
+
const sourceCode = context.sourceCode;
|
41
41
|
|
42
42
|
/**
|
43
43
|
* Checks whether a node is evaluated as a string or not.
|
@@ -182,7 +182,7 @@ module.exports = {
|
|
182
182
|
docs: {
|
183
183
|
description: "Disallow assigning to imported bindings",
|
184
184
|
recommended: true,
|
185
|
-
url: "https://eslint.org/docs/rules/no-import-assign"
|
185
|
+
url: "https://eslint.org/docs/latest/rules/no-import-assign"
|
186
186
|
},
|
187
187
|
|
188
188
|
schema: [],
|
@@ -194,7 +194,7 @@ module.exports = {
|
|
194
194
|
},
|
195
195
|
|
196
196
|
create(context) {
|
197
|
-
const sourceCode = context.
|
197
|
+
const sourceCode = context.sourceCode;
|
198
198
|
|
199
199
|
return {
|
200
200
|
ImportDeclaration(node) {
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Disallow inline comments after code",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/no-inline-comments"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/no-inline-comments"
|
22
22
|
},
|
23
23
|
|
24
24
|
schema: [
|
@@ -39,7 +39,7 @@ module.exports = {
|
|
39
39
|
},
|
40
40
|
|
41
41
|
create(context) {
|
42
|
-
const sourceCode = context.
|
42
|
+
const sourceCode = context.sourceCode;
|
43
43
|
const options = context.options[0];
|
44
44
|
let customIgnoreRegExp;
|
45
45
|
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
50
50
|
docs: {
|
51
51
|
description: "Disallow variable or `function` declarations in nested blocks",
|
52
52
|
recommended: true,
|
53
|
-
url: "https://eslint.org/docs/rules/no-inner-declarations"
|
53
|
+
url: "https://eslint.org/docs/latest/rules/no-inner-declarations"
|
54
54
|
},
|
55
55
|
|
56
56
|
schema: [
|
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
const RegExpValidator = require("@eslint-community/regexpp").RegExpValidator;
|
12
12
|
const validator = new RegExpValidator();
|
13
|
-
const validFlags = /[
|
13
|
+
const validFlags = /[dgimsuvy]/gu;
|
14
14
|
const undefined1 = void 0;
|
15
15
|
|
16
16
|
//------------------------------------------------------------------------------
|
@@ -25,7 +25,7 @@ module.exports = {
|
|
25
25
|
docs: {
|
26
26
|
description: "Disallow invalid regular expression strings in `RegExp` constructors",
|
27
27
|
recommended: true,
|
28
|
-
url: "https://eslint.org/docs/rules/no-invalid-regexp"
|
28
|
+
url: "https://eslint.org/docs/latest/rules/no-invalid-regexp"
|
29
29
|
},
|
30
30
|
|
31
31
|
schema: [{
|
@@ -108,12 +108,14 @@ module.exports = {
|
|
108
108
|
/**
|
109
109
|
* Check syntax error in a given pattern.
|
110
110
|
* @param {string} pattern The RegExp pattern to validate.
|
111
|
-
* @param {
|
111
|
+
* @param {Object} flags The RegExp flags to validate.
|
112
|
+
* @param {boolean} [flags.unicode] The Unicode flag.
|
113
|
+
* @param {boolean} [flags.unicodeSets] The UnicodeSets flag.
|
112
114
|
* @returns {string|null} The syntax error.
|
113
115
|
*/
|
114
|
-
function validateRegExpPattern(pattern,
|
116
|
+
function validateRegExpPattern(pattern, flags) {
|
115
117
|
try {
|
116
|
-
validator.validatePattern(pattern, undefined1, undefined1,
|
118
|
+
validator.validatePattern(pattern, undefined1, undefined1, flags);
|
117
119
|
return null;
|
118
120
|
} catch (err) {
|
119
121
|
return err.message;
|
@@ -131,10 +133,19 @@ module.exports = {
|
|
131
133
|
}
|
132
134
|
try {
|
133
135
|
validator.validateFlags(flags);
|
134
|
-
return null;
|
135
136
|
} catch {
|
136
137
|
return `Invalid flags supplied to RegExp constructor '${flags}'`;
|
137
138
|
}
|
139
|
+
|
140
|
+
/*
|
141
|
+
* `regexpp` checks the combination of `u` and `v` flags when parsing `Pattern` according to `ecma262`,
|
142
|
+
* but this rule may check only the flag when the pattern is unidentifiable, so check it here.
|
143
|
+
* https://tc39.es/ecma262/multipage/text-processing.html#sec-parsepattern
|
144
|
+
*/
|
145
|
+
if (flags.includes("u") && flags.includes("v")) {
|
146
|
+
return "Regex 'u' and 'v' flags cannot be used together";
|
147
|
+
}
|
148
|
+
return null;
|
138
149
|
}
|
139
150
|
|
140
151
|
return {
|
@@ -166,8 +177,12 @@ module.exports = {
|
|
166
177
|
|
167
178
|
// If flags are unknown, report the regex only if its pattern is invalid both with and without the "u" flag
|
168
179
|
flags === null
|
169
|
-
?
|
170
|
-
|
180
|
+
? (
|
181
|
+
validateRegExpPattern(pattern, { unicode: true, unicodeSets: false }) &&
|
182
|
+
validateRegExpPattern(pattern, { unicode: false, unicodeSets: true }) &&
|
183
|
+
validateRegExpPattern(pattern, { unicode: false, unicodeSets: false })
|
184
|
+
)
|
185
|
+
: validateRegExpPattern(pattern, { unicode: flags.includes("u"), unicodeSets: flags.includes("v") })
|
171
186
|
);
|
172
187
|
|
173
188
|
if (message) {
|
@@ -38,7 +38,7 @@ module.exports = {
|
|
38
38
|
docs: {
|
39
39
|
description: "Disallow use of `this` in contexts where the value of `this` is `undefined`",
|
40
40
|
recommended: false,
|
41
|
-
url: "https://eslint.org/docs/rules/no-invalid-this"
|
41
|
+
url: "https://eslint.org/docs/latest/rules/no-invalid-this"
|
42
42
|
},
|
43
43
|
|
44
44
|
schema: [
|
@@ -63,7 +63,7 @@ module.exports = {
|
|
63
63
|
const options = context.options[0] || {};
|
64
64
|
const capIsConstructor = options.capIsConstructor !== false;
|
65
65
|
const stack = [],
|
66
|
-
sourceCode = context.
|
66
|
+
sourceCode = context.sourceCode;
|
67
67
|
|
68
68
|
/**
|
69
69
|
* Gets the current checking context.
|
@@ -33,7 +33,7 @@ module.exports = {
|
|
33
33
|
docs: {
|
34
34
|
description: "Disallow irregular whitespace",
|
35
35
|
recommended: true,
|
36
|
-
url: "https://eslint.org/docs/rules/no-irregular-whitespace"
|
36
|
+
url: "https://eslint.org/docs/latest/rules/no-irregular-whitespace"
|
37
37
|
},
|
38
38
|
|
39
39
|
schema: [
|
@@ -55,6 +55,10 @@ module.exports = {
|
|
55
55
|
skipRegExps: {
|
56
56
|
type: "boolean",
|
57
57
|
default: false
|
58
|
+
},
|
59
|
+
skipJSXText: {
|
60
|
+
type: "boolean",
|
61
|
+
default: false
|
58
62
|
}
|
59
63
|
},
|
60
64
|
additionalProperties: false
|
@@ -77,8 +81,9 @@ module.exports = {
|
|
77
81
|
const skipStrings = options.skipStrings !== false;
|
78
82
|
const skipRegExps = !!options.skipRegExps;
|
79
83
|
const skipTemplates = !!options.skipTemplates;
|
84
|
+
const skipJSXText = !!options.skipJSXText;
|
80
85
|
|
81
|
-
const sourceCode = context.
|
86
|
+
const sourceCode = context.sourceCode;
|
82
87
|
const commentNodes = sourceCode.getAllComments();
|
83
88
|
|
84
89
|
/**
|
@@ -100,12 +105,12 @@ module.exports = {
|
|
100
105
|
}
|
101
106
|
|
102
107
|
/**
|
103
|
-
* Checks
|
108
|
+
* Checks literal nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
|
104
109
|
* @param {ASTNode} node to check for matching errors.
|
105
110
|
* @returns {void}
|
106
111
|
* @private
|
107
112
|
*/
|
108
|
-
function
|
113
|
+
function removeInvalidNodeErrorsInLiteral(node) {
|
109
114
|
const shouldCheckStrings = skipStrings && (typeof node.value === "string");
|
110
115
|
const shouldCheckRegExps = skipRegExps && Boolean(node.regex);
|
111
116
|
|
@@ -144,6 +149,18 @@ module.exports = {
|
|
144
149
|
}
|
145
150
|
}
|
146
151
|
|
152
|
+
/**
|
153
|
+
* Checks JSX nodes for errors that we are choosing to ignore and calls the relevant methods to remove the errors
|
154
|
+
* @param {ASTNode} node to check for matching errors.
|
155
|
+
* @returns {void}
|
156
|
+
* @private
|
157
|
+
*/
|
158
|
+
function removeInvalidNodeErrorsInJSXText(node) {
|
159
|
+
if (ALL_IRREGULARS.test(node.raw)) {
|
160
|
+
removeWhitespaceError(node);
|
161
|
+
}
|
162
|
+
}
|
163
|
+
|
147
164
|
/**
|
148
165
|
* Checks the program source for irregular whitespace
|
149
166
|
* @param {ASTNode} node The program node
|
@@ -237,9 +254,9 @@ module.exports = {
|
|
237
254
|
checkForIrregularLineTerminators(node);
|
238
255
|
};
|
239
256
|
|
240
|
-
nodes.
|
241
|
-
nodes.Literal = removeInvalidNodeErrorsInIdentifierOrLiteral;
|
257
|
+
nodes.Literal = removeInvalidNodeErrorsInLiteral;
|
242
258
|
nodes.TemplateElement = skipTemplates ? removeInvalidNodeErrorsInTemplateLiteral : noop;
|
259
|
+
nodes.JSXText = skipJSXText ? removeInvalidNodeErrorsInJSXText : noop;
|
243
260
|
nodes["Program:exit"] = function() {
|
244
261
|
if (skipComments) {
|
245
262
|
|
package/lib/rules/no-iterator.js
CHANGED
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Disallow labels that share a name with a variable",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/no-label-var"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/no-label-var"
|
27
27
|
},
|
28
28
|
|
29
29
|
schema: [],
|
@@ -34,7 +34,7 @@ module.exports = {
|
|
34
34
|
},
|
35
35
|
|
36
36
|
create(context) {
|
37
|
-
const sourceCode = context.
|
37
|
+
const sourceCode = context.sourceCode;
|
38
38
|
|
39
39
|
//--------------------------------------------------------------------------
|
40
40
|
// Helpers
|
package/lib/rules/no-labels.js
CHANGED
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Disallow unnecessary nested blocks",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/no-lone-blocks"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/no-lone-blocks"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
@@ -33,7 +33,7 @@ module.exports = {
|
|
33
33
|
// A stack of lone blocks to be checked for block-level bindings
|
34
34
|
const loneBlocks = [];
|
35
35
|
let ruleDef;
|
36
|
-
const sourceCode = context.
|
36
|
+
const sourceCode = context.sourceCode;
|
37
37
|
|
38
38
|
/**
|
39
39
|
* Reports a node as invalid.
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Disallow `if` statements as the only statement in `else` blocks",
|
18
18
|
recommended: false,
|
19
|
-
url: "https://eslint.org/docs/rules/no-lonely-if"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/no-lonely-if"
|
20
20
|
},
|
21
21
|
|
22
22
|
schema: [],
|
@@ -28,7 +28,7 @@ module.exports = {
|
|
28
28
|
},
|
29
29
|
|
30
30
|
create(context) {
|
31
|
-
const sourceCode = context.
|
31
|
+
const sourceCode = context.sourceCode;
|
32
32
|
|
33
33
|
return {
|
34
34
|
IfStatement(node) {
|
@@ -156,7 +156,7 @@ module.exports = {
|
|
156
156
|
docs: {
|
157
157
|
description: "Disallow function declarations that contain unsafe references inside loop statements",
|
158
158
|
recommended: false,
|
159
|
-
url: "https://eslint.org/docs/rules/no-loop-func"
|
159
|
+
url: "https://eslint.org/docs/latest/rules/no-loop-func"
|
160
160
|
},
|
161
161
|
|
162
162
|
schema: [],
|
@@ -168,7 +168,7 @@ module.exports = {
|
|
168
168
|
|
169
169
|
create(context) {
|
170
170
|
|
171
|
-
const sourceCode = context.
|
171
|
+
const sourceCode = context.sourceCode;
|
172
172
|
|
173
173
|
/**
|
174
174
|
* Reports functions which match the following condition:
|
@@ -186,7 +186,7 @@ module.exports = {
|
|
186
186
|
}
|
187
187
|
|
188
188
|
const references = sourceCode.getScope(node).through;
|
189
|
-
const unsafeRefs = references.filter(r => !isSafe(loopNode, r)).map(r => r.identifier.name);
|
189
|
+
const unsafeRefs = references.filter(r => r.resolved && !isSafe(loopNode, r)).map(r => r.identifier.name);
|
190
190
|
|
191
191
|
if (unsafeRefs.length > 0) {
|
192
192
|
context.report({
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Disallow literal numbers that lose precision",
|
19
19
|
recommended: true,
|
20
|
-
url: "https://eslint.org/docs/rules/no-loss-of-precision"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/no-loss-of-precision"
|
21
21
|
},
|
22
22
|
schema: [],
|
23
23
|
messages: {
|
@@ -83,7 +83,7 @@ module.exports = {
|
|
83
83
|
* @returns {string} the numeric string with a decimal point in the proper place
|
84
84
|
*/
|
85
85
|
function addDecimalPointToNumber(stringNumber) {
|
86
|
-
return `${stringNumber
|
86
|
+
return `${stringNumber[0]}.${stringNumber.slice(1)}`;
|
87
87
|
}
|
88
88
|
|
89
89
|
/**
|
@@ -92,7 +92,12 @@ module.exports = {
|
|
92
92
|
* @returns {string} the stripped string
|
93
93
|
*/
|
94
94
|
function removeLeadingZeros(numberAsString) {
|
95
|
-
|
95
|
+
for (let i = 0; i < numberAsString.length; i++) {
|
96
|
+
if (numberAsString[i] !== "0") {
|
97
|
+
return numberAsString.slice(i);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
return numberAsString;
|
96
101
|
}
|
97
102
|
|
98
103
|
/**
|
@@ -101,7 +106,12 @@ module.exports = {
|
|
101
106
|
* @returns {string} the stripped string
|
102
107
|
*/
|
103
108
|
function removeTrailingZeros(numberAsString) {
|
104
|
-
|
109
|
+
for (let i = numberAsString.length - 1; i >= 0; i--) {
|
110
|
+
if (numberAsString[i] !== "0") {
|
111
|
+
return numberAsString.slice(0, i + 1);
|
112
|
+
}
|
113
|
+
}
|
114
|
+
return numberAsString;
|
105
115
|
}
|
106
116
|
|
107
117
|
/**
|
@@ -128,7 +138,7 @@ module.exports = {
|
|
128
138
|
const trimmedFloat = removeLeadingZeros(stringFloat);
|
129
139
|
|
130
140
|
if (trimmedFloat.startsWith(".")) {
|
131
|
-
const decimalDigits = trimmedFloat.
|
141
|
+
const decimalDigits = trimmedFloat.slice(1);
|
132
142
|
const significantDigits = removeLeadingZeros(decimalDigits);
|
133
143
|
|
134
144
|
return {
|
@@ -144,7 +154,6 @@ module.exports = {
|
|
144
154
|
};
|
145
155
|
}
|
146
156
|
|
147
|
-
|
148
157
|
/**
|
149
158
|
* Converts a base ten number to proper scientific notation
|
150
159
|
* @param {string} stringNumber the string representation of the base ten number to be converted
|
@@ -160,7 +169,6 @@ module.exports = {
|
|
160
169
|
: normalizedNumber.magnitude;
|
161
170
|
|
162
171
|
return `${normalizedCoefficient}e${magnitude}`;
|
163
|
-
|
164
172
|
}
|
165
173
|
|
166
174
|
/**
|
@@ -18,7 +18,7 @@ const { isValidWithUnicodeFlag } = require("./utils/regular-expressions");
|
|
18
18
|
*
|
19
19
|
* CharacterClassRange syntax can steal a part of character sequence,
|
20
20
|
* so this function reverts CharacterClassRange syntax and restore the sequence.
|
21
|
-
* @param {regexpp.AST.CharacterClassElement[]} nodes The node list to iterate character sequences.
|
21
|
+
* @param {import('@eslint-community/regexpp').AST.CharacterClassElement[]} nodes The node list to iterate character sequences.
|
22
22
|
* @returns {IterableIterator<number[]>} The list of character sequences.
|
23
23
|
*/
|
24
24
|
function *iterateCharacterSequence(nodes) {
|
@@ -37,6 +37,9 @@ function *iterateCharacterSequence(nodes) {
|
|
37
37
|
break;
|
38
38
|
|
39
39
|
case "CharacterSet":
|
40
|
+
case "CharacterClass": // [[]] nesting character class
|
41
|
+
case "ClassStringDisjunction": // \q{...}
|
42
|
+
case "ExpressionCharacterClass": // [A--B]
|
40
43
|
if (seq.length > 0) {
|
41
44
|
yield seq;
|
42
45
|
seq = [];
|
@@ -108,7 +111,7 @@ module.exports = {
|
|
108
111
|
docs: {
|
109
112
|
description: "Disallow characters which are made with multiple code points in character class syntax",
|
110
113
|
recommended: true,
|
111
|
-
url: "https://eslint.org/docs/rules/no-misleading-character-class"
|
114
|
+
url: "https://eslint.org/docs/latest/rules/no-misleading-character-class"
|
112
115
|
},
|
113
116
|
|
114
117
|
hasSuggestions: true,
|
@@ -125,7 +128,7 @@ module.exports = {
|
|
125
128
|
}
|
126
129
|
},
|
127
130
|
create(context) {
|
128
|
-
const sourceCode = context.
|
131
|
+
const sourceCode = context.sourceCode;
|
129
132
|
const parser = new RegExpParser();
|
130
133
|
|
131
134
|
/**
|
@@ -144,7 +147,10 @@ module.exports = {
|
|
144
147
|
pattern,
|
145
148
|
0,
|
146
149
|
pattern.length,
|
147
|
-
|
150
|
+
{
|
151
|
+
unicode: flags.includes("u"),
|
152
|
+
unicodeSets: flags.includes("v")
|
153
|
+
}
|
148
154
|
);
|
149
155
|
} catch {
|
150
156
|
|
@@ -90,7 +90,7 @@ module.exports = {
|
|
90
90
|
docs: {
|
91
91
|
description: "Disallow mixed binary operators",
|
92
92
|
recommended: false,
|
93
|
-
url: "https://eslint.org/docs/rules/no-mixed-operators"
|
93
|
+
url: "https://eslint.org/docs/latest/rules/no-mixed-operators"
|
94
94
|
},
|
95
95
|
|
96
96
|
schema: [
|
@@ -122,7 +122,7 @@ module.exports = {
|
|
122
122
|
},
|
123
123
|
|
124
124
|
create(context) {
|
125
|
-
const sourceCode = context.
|
125
|
+
const sourceCode = context.sourceCode;
|
126
126
|
const options = normalizeOptions(context.options[0]);
|
127
127
|
|
128
128
|
/**
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Disallow `require` calls to be mixed with regular variable declarations",
|
24
24
|
recommended: false,
|
25
|
-
url: "https://eslint.org/docs/rules/no-mixed-requires"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/no-mixed-requires"
|
26
26
|
},
|
27
27
|
|
28
28
|
schema: [
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Disallow mixed spaces and tabs for indentation",
|
18
18
|
recommended: true,
|
19
|
-
url: "https://eslint.org/docs/rules/no-mixed-spaces-and-tabs"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/no-mixed-spaces-and-tabs"
|
20
20
|
},
|
21
21
|
|
22
22
|
schema: [
|
@@ -31,7 +31,7 @@ module.exports = {
|
|
31
31
|
},
|
32
32
|
|
33
33
|
create(context) {
|
34
|
-
const sourceCode = context.
|
34
|
+
const sourceCode = context.sourceCode;
|
35
35
|
|
36
36
|
let smartTabs;
|
37
37
|
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Disallow use of chained assignment expressions",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/no-multi-assign"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/no-multi-assign"
|
22
22
|
},
|
23
23
|
|
24
24
|
schema: [{
|
@@ -19,7 +19,7 @@ module.exports = {
|
|
19
19
|
docs: {
|
20
20
|
description: "Disallow multiple spaces",
|
21
21
|
recommended: false,
|
22
|
-
url: "https://eslint.org/docs/rules/no-multi-spaces"
|
22
|
+
url: "https://eslint.org/docs/latest/rules/no-multi-spaces"
|
23
23
|
},
|
24
24
|
|
25
25
|
fixable: "whitespace",
|
@@ -52,7 +52,7 @@ module.exports = {
|
|
52
52
|
},
|
53
53
|
|
54
54
|
create(context) {
|
55
|
-
const sourceCode = context.
|
55
|
+
const sourceCode = context.sourceCode;
|
56
56
|
const options = context.options[0] || {};
|
57
57
|
const ignoreEOLComments = options.ignoreEOLComments;
|
58
58
|
const exceptions = Object.assign({ Property: true }, options.exceptions);
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Disallow multiple empty lines",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/no-multiple-empty-lines"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/no-multiple-empty-lines"
|
21
21
|
},
|
22
22
|
|
23
23
|
fixable: "whitespace",
|
@@ -64,7 +64,7 @@ module.exports = {
|
|
64
64
|
maxBOF = typeof context.options[0].maxBOF !== "undefined" ? context.options[0].maxBOF : max;
|
65
65
|
}
|
66
66
|
|
67
|
-
const sourceCode = context.
|
67
|
+
const sourceCode = context.sourceCode;
|
68
68
|
|
69
69
|
// Swallow the final newline, as some editors add it automatically and we don't want it to cause an issue
|
70
70
|
const allLines = sourceCode.lines[sourceCode.lines.length - 1] === "" ? sourceCode.lines.slice(0, -1) : sourceCode.lines;
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Disallow assignments to native objects or read-only global variables",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/no-native-reassign"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/no-native-reassign"
|
22
22
|
},
|
23
23
|
|
24
24
|
deprecated: true,
|
@@ -47,7 +47,7 @@ module.exports = {
|
|
47
47
|
create(context) {
|
48
48
|
const config = context.options[0];
|
49
49
|
const exceptions = (config && config.exceptions) || [];
|
50
|
-
const sourceCode = context.
|
50
|
+
const sourceCode = context.sourceCode;
|
51
51
|
|
52
52
|
/**
|
53
53
|
* Reports write references.
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Disallow negating the left operand in `in` expressions",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/no-negated-in-lhs"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/no-negated-in-lhs"
|
22
22
|
},
|
23
23
|
|
24
24
|
replacedBy: ["no-unsafe-negation"],
|
package/lib/rules/no-new-func.js
CHANGED
@@ -29,7 +29,7 @@ module.exports = {
|
|
29
29
|
docs: {
|
30
30
|
description: "Disallow `new` operators with the `Function` object",
|
31
31
|
recommended: false,
|
32
|
-
url: "https://eslint.org/docs/rules/no-new-func"
|
32
|
+
url: "https://eslint.org/docs/latest/rules/no-new-func"
|
33
33
|
},
|
34
34
|
|
35
35
|
schema: [],
|
@@ -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
|
|
45
45
|
return {
|
46
46
|
"Program:exit"(node) {
|