eslint 8.39.0 → 8.41.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 +4 -3
- package/lib/cli-engine/cli-engine.js +3 -1
- package/lib/cli.js +2 -28
- package/lib/config/default-config.js +1 -1
- package/lib/config/flat-config-schema.js +57 -35
- package/lib/eslint/eslint-helpers.js +8 -7
- package/lib/eslint/flat-eslint.js +101 -46
- package/lib/linter/apply-disable-directives.js +11 -1
- package/lib/linter/config-comment-parser.js +9 -2
- package/lib/linter/linter.js +20 -11
- package/lib/linter/report-translator.js +4 -19
- 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 +40 -56
- 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 +2 -2
- package/lib/rules/no-lonely-if.js +2 -2
- 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 +1 -1
- 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 -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 +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 +2 -2
- 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 +2 -2
- package/lib/shared/string-utils.js +39 -1
- package/lib/shared/types.js +6 -2
- package/lib/unsupported-api.js +2 -1
- 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 -7
@@ -19,7 +19,7 @@ module.exports = {
|
|
19
19
|
docs: {
|
20
20
|
description: "Enforce consistent newlines before and after dots",
|
21
21
|
recommended: false,
|
22
|
-
url: "https://eslint.org/docs/rules/dot-location"
|
22
|
+
url: "https://eslint.org/docs/latest/rules/dot-location"
|
23
23
|
},
|
24
24
|
|
25
25
|
schema: [
|
@@ -43,7 +43,7 @@ module.exports = {
|
|
43
43
|
// default to onObject if no preference is passed
|
44
44
|
const onObject = config === "object" || !config;
|
45
45
|
|
46
|
-
const sourceCode = context.
|
46
|
+
const sourceCode = context.sourceCode;
|
47
47
|
|
48
48
|
/**
|
49
49
|
* Reports if the dot between object and property is on the correct location.
|
@@ -28,7 +28,7 @@ module.exports = {
|
|
28
28
|
docs: {
|
29
29
|
description: "Enforce dot notation whenever possible",
|
30
30
|
recommended: false,
|
31
|
-
url: "https://eslint.org/docs/rules/dot-notation"
|
31
|
+
url: "https://eslint.org/docs/latest/rules/dot-notation"
|
32
32
|
},
|
33
33
|
|
34
34
|
schema: [
|
@@ -59,7 +59,7 @@ module.exports = {
|
|
59
59
|
create(context) {
|
60
60
|
const options = context.options[0] || {};
|
61
61
|
const allowKeywords = options.allowKeywords === void 0 || options.allowKeywords;
|
62
|
-
const sourceCode = context.
|
62
|
+
const sourceCode = context.sourceCode;
|
63
63
|
|
64
64
|
let allowPattern;
|
65
65
|
|
package/lib/rules/eol-last.js
CHANGED
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Require or disallow newline at the end of files",
|
18
18
|
recommended: false,
|
19
|
-
url: "https://eslint.org/docs/rules/eol-last"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/eol-last"
|
20
20
|
},
|
21
21
|
|
22
22
|
fixable: "whitespace",
|
@@ -40,7 +40,7 @@ module.exports = {
|
|
40
40
|
|
41
41
|
return {
|
42
42
|
Program: function checkBadEOF(node) {
|
43
|
-
const sourceCode = context.
|
43
|
+
const sourceCode = context.sourceCode,
|
44
44
|
src = sourceCode.getText(),
|
45
45
|
lastLine = sourceCode.lines[sourceCode.lines.length - 1],
|
46
46
|
location = {
|
package/lib/rules/eqeqeq.js
CHANGED
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Require the use of `===` and `!==`",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/eqeqeq"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/eqeqeq"
|
27
27
|
},
|
28
28
|
|
29
29
|
schema: {
|
@@ -68,7 +68,7 @@ module.exports = {
|
|
68
68
|
create(context) {
|
69
69
|
const config = context.options[0] || "always";
|
70
70
|
const options = context.options[1] || {};
|
71
|
-
const sourceCode = context.
|
71
|
+
const sourceCode = context.sourceCode;
|
72
72
|
|
73
73
|
const nullOption = (config === "always")
|
74
74
|
? options.null || "always"
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Enforce \"for\" loop update clause moving the counter in the right direction",
|
19
19
|
recommended: true,
|
20
|
-
url: "https://eslint.org/docs/rules/for-direction"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/for-direction"
|
21
21
|
},
|
22
22
|
|
23
23
|
fixable: null,
|
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Require or disallow spacing between function identifiers and their invocations",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/func-call-spacing"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/func-call-spacing"
|
27
27
|
},
|
28
28
|
|
29
29
|
fixable: "whitespace",
|
@@ -73,7 +73,7 @@ module.exports = {
|
|
73
73
|
|
74
74
|
const never = context.options[0] !== "always";
|
75
75
|
const allowNewlines = !never && context.options[1] && context.options[1].allowNewlines;
|
76
|
-
const sourceCode = context.
|
76
|
+
const sourceCode = context.sourceCode;
|
77
77
|
const text = sourceCode.getText();
|
78
78
|
|
79
79
|
/**
|
@@ -76,7 +76,7 @@ module.exports = {
|
|
76
76
|
docs: {
|
77
77
|
description: "Require function names to match the name of the variable or property to which they are assigned",
|
78
78
|
recommended: false,
|
79
|
-
url: "https://eslint.org/docs/rules/func-name-matching"
|
79
|
+
url: "https://eslint.org/docs/latest/rules/func-name-matching"
|
80
80
|
},
|
81
81
|
|
82
82
|
schema: {
|
package/lib/rules/func-names.js
CHANGED
@@ -32,7 +32,7 @@ module.exports = {
|
|
32
32
|
docs: {
|
33
33
|
description: "Require or disallow named `function` expressions",
|
34
34
|
recommended: false,
|
35
|
-
url: "https://eslint.org/docs/rules/func-names"
|
35
|
+
url: "https://eslint.org/docs/latest/rules/func-names"
|
36
36
|
},
|
37
37
|
|
38
38
|
schema: {
|
@@ -69,7 +69,7 @@ module.exports = {
|
|
69
69
|
|
70
70
|
create(context) {
|
71
71
|
|
72
|
-
const sourceCode = context.
|
72
|
+
const sourceCode = context.sourceCode;
|
73
73
|
|
74
74
|
/**
|
75
75
|
* Returns the config option for the given node.
|
package/lib/rules/func-style.js
CHANGED
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Enforce the consistent use of either `function` declarations or expressions",
|
18
18
|
recommended: false,
|
19
|
-
url: "https://eslint.org/docs/rules/func-style"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/func-style"
|
20
20
|
},
|
21
21
|
|
22
22
|
schema: [
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Enforce line breaks between arguments of a function call",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/function-call-argument-newline"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/function-call-argument-newline"
|
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
|
|
40
40
|
const checkers = {
|
41
41
|
unexpected: {
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Enforce consistent line breaks inside function parentheses",
|
24
24
|
recommended: false,
|
25
|
-
url: "https://eslint.org/docs/rules/function-paren-newline"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/function-paren-newline"
|
26
26
|
},
|
27
27
|
|
28
28
|
fixable: "whitespace",
|
@@ -57,7 +57,7 @@ module.exports = {
|
|
57
57
|
},
|
58
58
|
|
59
59
|
create(context) {
|
60
|
-
const sourceCode = context.
|
60
|
+
const sourceCode = context.sourceCode;
|
61
61
|
const rawOption = context.options[0] || "multiline";
|
62
62
|
const multilineOption = rawOption === "multiline";
|
63
63
|
const multilineArgumentsOption = rawOption === "multiline-arguments";
|
@@ -33,7 +33,7 @@ module.exports = {
|
|
33
33
|
docs: {
|
34
34
|
description: "Enforce consistent spacing around `*` operators in generator functions",
|
35
35
|
recommended: false,
|
36
|
-
url: "https://eslint.org/docs/rules/generator-star-spacing"
|
36
|
+
url: "https://eslint.org/docs/latest/rules/generator-star-spacing"
|
37
37
|
},
|
38
38
|
|
39
39
|
fixable: "whitespace",
|
@@ -102,7 +102,7 @@ module.exports = {
|
|
102
102
|
};
|
103
103
|
}(context.options[0] || {}));
|
104
104
|
|
105
|
-
const sourceCode = context.
|
105
|
+
const sourceCode = context.sourceCode;
|
106
106
|
|
107
107
|
/**
|
108
108
|
* Checks if the given token is a star token or not.
|
@@ -37,7 +37,7 @@ module.exports = {
|
|
37
37
|
docs: {
|
38
38
|
description: "Enforce `return` statements in getters",
|
39
39
|
recommended: true,
|
40
|
-
url: "https://eslint.org/docs/rules/getter-return"
|
40
|
+
url: "https://eslint.org/docs/latest/rules/getter-return"
|
41
41
|
},
|
42
42
|
|
43
43
|
fixable: null,
|
@@ -64,7 +64,7 @@ module.exports = {
|
|
64
64
|
create(context) {
|
65
65
|
|
66
66
|
const options = context.options[0] || { allowImplicit: false };
|
67
|
-
const sourceCode = context.
|
67
|
+
const sourceCode = context.sourceCode;
|
68
68
|
|
69
69
|
let funcInfo = {
|
70
70
|
upper: null,
|
@@ -61,7 +61,7 @@ module.exports = {
|
|
61
61
|
docs: {
|
62
62
|
description: "Require `require()` calls to be placed at top-level module scope",
|
63
63
|
recommended: false,
|
64
|
-
url: "https://eslint.org/docs/rules/global-require"
|
64
|
+
url: "https://eslint.org/docs/latest/rules/global-require"
|
65
65
|
},
|
66
66
|
|
67
67
|
schema: [],
|
@@ -71,7 +71,7 @@ module.exports = {
|
|
71
71
|
},
|
72
72
|
|
73
73
|
create(context) {
|
74
|
-
const sourceCode = context.
|
74
|
+
const sourceCode = context.sourceCode;
|
75
75
|
|
76
76
|
return {
|
77
77
|
CallExpression(node) {
|
@@ -98,7 +98,7 @@ module.exports = {
|
|
98
98
|
docs: {
|
99
99
|
description: "Require grouped accessor pairs in object literals and classes",
|
100
100
|
recommended: false,
|
101
|
-
url: "https://eslint.org/docs/rules/grouped-accessor-pairs"
|
101
|
+
url: "https://eslint.org/docs/latest/rules/grouped-accessor-pairs"
|
102
102
|
},
|
103
103
|
|
104
104
|
schema: [
|
@@ -115,7 +115,7 @@ module.exports = {
|
|
115
115
|
|
116
116
|
create(context) {
|
117
117
|
const order = context.options[0] || "anyOrder";
|
118
|
-
const sourceCode = context.
|
118
|
+
const sourceCode = context.sourceCode;
|
119
119
|
|
120
120
|
/**
|
121
121
|
* Reports the given accessor pair.
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require `for-in` loops to include an `if` statement",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/guard-for-in"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/guard-for-in"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Require error handling in callbacks",
|
24
24
|
recommended: false,
|
25
|
-
url: "https://eslint.org/docs/rules/handle-callback-err"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/handle-callback-err"
|
26
26
|
},
|
27
27
|
|
28
28
|
schema: [
|
@@ -38,7 +38,7 @@ module.exports = {
|
|
38
38
|
create(context) {
|
39
39
|
|
40
40
|
const errorArgument = context.options[0] || "err";
|
41
|
-
const sourceCode = context.
|
41
|
+
const sourceCode = context.sourceCode;
|
42
42
|
|
43
43
|
/**
|
44
44
|
* Checks if the given argument should be interpreted as a regexp pattern.
|
@@ -121,7 +121,7 @@ module.exports = {
|
|
121
121
|
docs: {
|
122
122
|
description: "Disallow specified identifiers",
|
123
123
|
recommended: false,
|
124
|
-
url: "https://eslint.org/docs/rules/id-blacklist"
|
124
|
+
url: "https://eslint.org/docs/latest/rules/id-blacklist"
|
125
125
|
},
|
126
126
|
|
127
127
|
schema: {
|
@@ -140,7 +140,7 @@ module.exports = {
|
|
140
140
|
|
141
141
|
const denyList = new Set(context.options);
|
142
142
|
const reportedNodes = new Set();
|
143
|
-
const sourceCode = context.
|
143
|
+
const sourceCode = context.sourceCode;
|
144
144
|
|
145
145
|
let globalScope;
|
146
146
|
|
package/lib/rules/id-denylist.js
CHANGED
@@ -101,7 +101,7 @@ module.exports = {
|
|
101
101
|
docs: {
|
102
102
|
description: "Disallow specified identifiers",
|
103
103
|
recommended: false,
|
104
|
-
url: "https://eslint.org/docs/rules/id-denylist"
|
104
|
+
url: "https://eslint.org/docs/latest/rules/id-denylist"
|
105
105
|
},
|
106
106
|
|
107
107
|
schema: {
|
@@ -121,7 +121,7 @@ module.exports = {
|
|
121
121
|
|
122
122
|
const denyList = new Set(context.options);
|
123
123
|
const reportedNodes = new Set();
|
124
|
-
const sourceCode = context.
|
124
|
+
const sourceCode = context.sourceCode;
|
125
125
|
|
126
126
|
let globalScope;
|
127
127
|
|
package/lib/rules/id-length.js
CHANGED
@@ -9,41 +9,8 @@
|
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
// Requirements
|
11
11
|
//------------------------------------------------------------------------------
|
12
|
-
const GraphemeSplitter = require("grapheme-splitter");
|
13
12
|
|
14
|
-
|
15
|
-
// Helpers
|
16
|
-
//------------------------------------------------------------------------------
|
17
|
-
|
18
|
-
/**
|
19
|
-
* Checks if the string given as argument is ASCII or not.
|
20
|
-
* @param {string} value A string that you want to know if it is ASCII or not.
|
21
|
-
* @returns {boolean} `true` if `value` is ASCII string.
|
22
|
-
*/
|
23
|
-
function isASCII(value) {
|
24
|
-
if (typeof value !== "string") {
|
25
|
-
return false;
|
26
|
-
}
|
27
|
-
return /^[\u0020-\u007f]*$/u.test(value);
|
28
|
-
}
|
29
|
-
|
30
|
-
/** @type {GraphemeSplitter | undefined} */
|
31
|
-
let splitter;
|
32
|
-
|
33
|
-
/**
|
34
|
-
* Gets the length of the string. If the string is not in ASCII, counts graphemes.
|
35
|
-
* @param {string} value A string that you want to get the length.
|
36
|
-
* @returns {number} The length of `value`.
|
37
|
-
*/
|
38
|
-
function getStringLength(value) {
|
39
|
-
if (isASCII(value)) {
|
40
|
-
return value.length;
|
41
|
-
}
|
42
|
-
if (!splitter) {
|
43
|
-
splitter = new GraphemeSplitter();
|
44
|
-
}
|
45
|
-
return splitter.countGraphemes(value);
|
46
|
-
}
|
13
|
+
const { getGraphemeCount } = require("../shared/string-utils");
|
47
14
|
|
48
15
|
//------------------------------------------------------------------------------
|
49
16
|
// Rule Definition
|
@@ -57,7 +24,7 @@ module.exports = {
|
|
57
24
|
docs: {
|
58
25
|
description: "Enforce minimum and maximum identifier lengths",
|
59
26
|
recommended: false,
|
60
|
-
url: "https://eslint.org/docs/rules/id-length"
|
27
|
+
url: "https://eslint.org/docs/latest/rules/id-length"
|
61
28
|
},
|
62
29
|
|
63
30
|
schema: [
|
@@ -169,7 +136,7 @@ module.exports = {
|
|
169
136
|
const name = node.name;
|
170
137
|
const parent = node.parent;
|
171
138
|
|
172
|
-
const nameLength =
|
139
|
+
const nameLength = getGraphemeCount(name);
|
173
140
|
|
174
141
|
const isShort = nameLength < minLength;
|
175
142
|
const isLong = nameLength > maxLength;
|
package/lib/rules/id-match.js
CHANGED
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require identifiers to match a specified regular expression",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/id-match"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/id-match"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [
|
@@ -67,7 +67,7 @@ module.exports = {
|
|
67
67
|
onlyDeclarations = !!options.onlyDeclarations,
|
68
68
|
ignoreDestructuring = !!options.ignoreDestructuring;
|
69
69
|
|
70
|
-
const sourceCode = context.
|
70
|
+
const sourceCode = context.sourceCode;
|
71
71
|
let globalScope;
|
72
72
|
|
73
73
|
//--------------------------------------------------------------------------
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Enforce the location of arrow function bodies",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/implicit-arrow-linebreak"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/implicit-arrow-linebreak"
|
21
21
|
},
|
22
22
|
|
23
23
|
fixable: "whitespace",
|
@@ -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
|
const option = context.options[0] || "beside";
|
39
39
|
|
40
40
|
/**
|
@@ -28,7 +28,7 @@ module.exports = {
|
|
28
28
|
docs: {
|
29
29
|
description: "Enforce consistent indentation",
|
30
30
|
recommended: false,
|
31
|
-
url: "https://eslint.org/docs/rules/indent-legacy"
|
31
|
+
url: "https://eslint.org/docs/latest/rules/indent-legacy"
|
32
32
|
},
|
33
33
|
|
34
34
|
deprecated: true,
|
@@ -206,7 +206,7 @@ module.exports = {
|
|
206
206
|
ObjectExpression: 1
|
207
207
|
};
|
208
208
|
|
209
|
-
const sourceCode = context.
|
209
|
+
const sourceCode = context.sourceCode;
|
210
210
|
|
211
211
|
if (context.options.length) {
|
212
212
|
if (context.options[0] === "tab") {
|
package/lib/rules/indent.js
CHANGED
@@ -12,8 +12,6 @@
|
|
12
12
|
// Requirements
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
|
15
|
-
const { OrderedMap } = require("js-sdsl");
|
16
|
-
|
17
15
|
const astUtils = require("./utils/ast-utils");
|
18
16
|
|
19
17
|
//------------------------------------------------------------------------------
|
@@ -125,43 +123,48 @@ const KNOWN_NODES = new Set([
|
|
125
123
|
|
126
124
|
|
127
125
|
/**
|
128
|
-
* A mutable
|
129
|
-
* This is intended to be a generic wrapper around a
|
126
|
+
* A mutable map that stores (key, value) pairs. The keys are numeric indices, and must be unique.
|
127
|
+
* This is intended to be a generic wrapper around a map with non-negative integer keys, so that the underlying implementation
|
130
128
|
* can easily be swapped out.
|
131
129
|
*/
|
132
|
-
class
|
130
|
+
class IndexMap {
|
133
131
|
|
134
132
|
/**
|
135
|
-
* Creates an empty
|
133
|
+
* Creates an empty map
|
134
|
+
* @param {number} maxKey The maximum key
|
136
135
|
*/
|
137
|
-
constructor() {
|
138
|
-
|
139
|
-
|
136
|
+
constructor(maxKey) {
|
137
|
+
|
138
|
+
// Initializing the array with the maximum expected size avoids dynamic reallocations that could degrade performance.
|
139
|
+
this._values = Array(maxKey + 1);
|
140
140
|
}
|
141
141
|
|
142
142
|
/**
|
143
|
-
* Inserts an entry into the
|
143
|
+
* Inserts an entry into the map.
|
144
144
|
* @param {number} key The entry's key
|
145
145
|
* @param {any} value The entry's value
|
146
146
|
* @returns {void}
|
147
147
|
*/
|
148
148
|
insert(key, value) {
|
149
|
-
this.
|
149
|
+
this._values[key] = value;
|
150
150
|
}
|
151
151
|
|
152
152
|
/**
|
153
|
-
* Finds the entry with the largest key less than or equal to the provided key
|
153
|
+
* Finds the value of the entry with the largest key less than or equal to the provided key
|
154
154
|
* @param {number} key The provided key
|
155
|
-
* @returns {
|
155
|
+
* @returns {*|undefined} The value of the found entry, or undefined if no such entry exists.
|
156
156
|
*/
|
157
|
-
|
158
|
-
const
|
157
|
+
findLastNotAfter(key) {
|
158
|
+
const values = this._values;
|
159
159
|
|
160
|
-
|
161
|
-
|
162
|
-
}
|
160
|
+
for (let index = key; index >= 0; index--) {
|
161
|
+
const value = values[index];
|
163
162
|
|
164
|
-
|
163
|
+
if (value) {
|
164
|
+
return value;
|
165
|
+
}
|
166
|
+
}
|
167
|
+
return void 0;
|
165
168
|
}
|
166
169
|
|
167
170
|
/**
|
@@ -171,26 +174,7 @@ class BinarySearchTree {
|
|
171
174
|
* @returns {void}
|
172
175
|
*/
|
173
176
|
deleteRange(start, end) {
|
174
|
-
|
175
|
-
// Exit without traversing the tree if the range has zero size.
|
176
|
-
if (start === end) {
|
177
|
-
return;
|
178
|
-
}
|
179
|
-
const iterator = this._orderedMap.lowerBound(start);
|
180
|
-
|
181
|
-
if (iterator.equals(this._orderedMapEnd)) {
|
182
|
-
return;
|
183
|
-
}
|
184
|
-
|
185
|
-
if (end > this._orderedMap.back()[0]) {
|
186
|
-
while (!iterator.equals(this._orderedMapEnd)) {
|
187
|
-
this._orderedMap.eraseElementByIterator(iterator);
|
188
|
-
}
|
189
|
-
} else {
|
190
|
-
while (iterator.pointer[0] < end) {
|
191
|
-
this._orderedMap.eraseElementByIterator(iterator);
|
192
|
-
}
|
193
|
-
}
|
177
|
+
this._values.fill(void 0, start, end);
|
194
178
|
}
|
195
179
|
}
|
196
180
|
|
@@ -252,14 +236,15 @@ class OffsetStorage {
|
|
252
236
|
* @param {TokenInfo} tokenInfo a TokenInfo instance
|
253
237
|
* @param {number} indentSize The desired size of each indentation level
|
254
238
|
* @param {string} indentType The indentation character
|
239
|
+
* @param {number} maxIndex The maximum end index of any token
|
255
240
|
*/
|
256
|
-
constructor(tokenInfo, indentSize, indentType) {
|
241
|
+
constructor(tokenInfo, indentSize, indentType, maxIndex) {
|
257
242
|
this._tokenInfo = tokenInfo;
|
258
243
|
this._indentSize = indentSize;
|
259
244
|
this._indentType = indentType;
|
260
245
|
|
261
|
-
this.
|
262
|
-
this.
|
246
|
+
this._indexMap = new IndexMap(maxIndex);
|
247
|
+
this._indexMap.insert(0, { offset: 0, from: null, force: false });
|
263
248
|
|
264
249
|
this._lockedFirstTokens = new WeakMap();
|
265
250
|
this._desiredIndentCache = new WeakMap();
|
@@ -267,7 +252,7 @@ class OffsetStorage {
|
|
267
252
|
}
|
268
253
|
|
269
254
|
_getOffsetDescriptor(token) {
|
270
|
-
return this.
|
255
|
+
return this._indexMap.findLastNotAfter(token.range[0]);
|
271
256
|
}
|
272
257
|
|
273
258
|
/**
|
@@ -388,37 +373,36 @@ class OffsetStorage {
|
|
388
373
|
* * key: 820, value: { offset: 1, from: bazToken }
|
389
374
|
*
|
390
375
|
* To find the offset descriptor for any given token, one needs to find the node with the largest key
|
391
|
-
* which is <= token.start. To make this operation fast, the nodes are stored in a
|
392
|
-
* search tree indexed by key.
|
376
|
+
* which is <= token.start. To make this operation fast, the nodes are stored in a map indexed by key.
|
393
377
|
*/
|
394
378
|
|
395
379
|
const descriptorToInsert = { offset, from: fromToken, force };
|
396
380
|
|
397
|
-
const descriptorAfterRange = this.
|
381
|
+
const descriptorAfterRange = this._indexMap.findLastNotAfter(range[1]);
|
398
382
|
|
399
383
|
const fromTokenIsInRange = fromToken && fromToken.range[0] >= range[0] && fromToken.range[1] <= range[1];
|
400
384
|
const fromTokenDescriptor = fromTokenIsInRange && this._getOffsetDescriptor(fromToken);
|
401
385
|
|
402
|
-
// First, remove any existing nodes in the range from the
|
403
|
-
this.
|
386
|
+
// First, remove any existing nodes in the range from the map.
|
387
|
+
this._indexMap.deleteRange(range[0] + 1, range[1]);
|
404
388
|
|
405
|
-
// Insert a new node into the
|
406
|
-
this.
|
389
|
+
// Insert a new node into the map for this range
|
390
|
+
this._indexMap.insert(range[0], descriptorToInsert);
|
407
391
|
|
408
392
|
/*
|
409
393
|
* To avoid circular offset dependencies, keep the `fromToken` token mapped to whatever it was mapped to previously,
|
410
394
|
* even if it's in the current range.
|
411
395
|
*/
|
412
396
|
if (fromTokenIsInRange) {
|
413
|
-
this.
|
414
|
-
this.
|
397
|
+
this._indexMap.insert(fromToken.range[0], fromTokenDescriptor);
|
398
|
+
this._indexMap.insert(fromToken.range[1], descriptorToInsert);
|
415
399
|
}
|
416
400
|
|
417
401
|
/*
|
418
402
|
* To avoid modifying the offset of tokens after the range, insert another node to keep the offset of the following
|
419
403
|
* tokens the same as it was before.
|
420
404
|
*/
|
421
|
-
this.
|
405
|
+
this._indexMap.insert(range[1], descriptorAfterRange);
|
422
406
|
}
|
423
407
|
|
424
408
|
/**
|
@@ -510,7 +494,7 @@ module.exports = {
|
|
510
494
|
docs: {
|
511
495
|
description: "Enforce consistent indentation",
|
512
496
|
recommended: false,
|
513
|
-
url: "https://eslint.org/docs/rules/indent"
|
497
|
+
url: "https://eslint.org/docs/latest/rules/indent"
|
514
498
|
},
|
515
499
|
|
516
500
|
fixable: "whitespace",
|
@@ -703,9 +687,9 @@ module.exports = {
|
|
703
687
|
}
|
704
688
|
}
|
705
689
|
|
706
|
-
const sourceCode = context.
|
690
|
+
const sourceCode = context.sourceCode;
|
707
691
|
const tokenInfo = new TokenInfo(sourceCode);
|
708
|
-
const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t");
|
692
|
+
const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t", sourceCode.text.length);
|
709
693
|
const parameterParens = new WeakSet();
|
710
694
|
|
711
695
|
/**
|
@@ -50,7 +50,7 @@ module.exports = {
|
|
50
50
|
docs: {
|
51
51
|
description: "Require or disallow initialization in variable declarations",
|
52
52
|
recommended: false,
|
53
|
-
url: "https://eslint.org/docs/rules/init-declarations"
|
53
|
+
url: "https://eslint.org/docs/latest/rules/init-declarations"
|
54
54
|
},
|
55
55
|
|
56
56
|
schema: {
|
package/lib/rules/jsx-quotes.js
CHANGED
@@ -44,7 +44,7 @@ module.exports = {
|
|
44
44
|
docs: {
|
45
45
|
description: "Enforce the consistent use of either double or single quotes in JSX attributes",
|
46
46
|
recommended: false,
|
47
|
-
url: "https://eslint.org/docs/rules/jsx-quotes"
|
47
|
+
url: "https://eslint.org/docs/latest/rules/jsx-quotes"
|
48
48
|
},
|
49
49
|
|
50
50
|
fixable: "whitespace",
|