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
package/lib/rules/comma-style.js
CHANGED
@@ -19,7 +19,7 @@ module.exports = {
|
|
19
19
|
docs: {
|
20
20
|
description: "Enforce consistent comma style",
|
21
21
|
recommended: false,
|
22
|
-
url: "https://eslint.org/docs/rules/comma-style"
|
22
|
+
url: "https://eslint.org/docs/latest/rules/comma-style"
|
23
23
|
},
|
24
24
|
|
25
25
|
fixable: "code",
|
@@ -51,7 +51,7 @@ module.exports = {
|
|
51
51
|
|
52
52
|
create(context) {
|
53
53
|
const style = context.options[0] || "last",
|
54
|
-
sourceCode = context.
|
54
|
+
sourceCode = context.sourceCode;
|
55
55
|
const exceptions = {
|
56
56
|
ArrayPattern: true,
|
57
57
|
ArrowFunctionExpression: true,
|
package/lib/rules/complexity.js
CHANGED
@@ -25,7 +25,7 @@ module.exports = {
|
|
25
25
|
docs: {
|
26
26
|
description: "Enforce a maximum cyclomatic complexity allowed in a program",
|
27
27
|
recommended: false,
|
28
|
-
url: "https://eslint.org/docs/rules/complexity"
|
28
|
+
url: "https://eslint.org/docs/latest/rules/complexity"
|
29
29
|
},
|
30
30
|
|
31
31
|
schema: [
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Enforce consistent spacing inside computed property brackets",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/computed-property-spacing"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/computed-property-spacing"
|
22
22
|
},
|
23
23
|
|
24
24
|
fixable: "whitespace",
|
@@ -49,7 +49,7 @@ module.exports = {
|
|
49
49
|
},
|
50
50
|
|
51
51
|
create(context) {
|
52
|
-
const sourceCode = context.
|
52
|
+
const sourceCode = context.sourceCode;
|
53
53
|
const propertyNameMustBeSpaced = context.options[0] === "always"; // default is "never"
|
54
54
|
const enforceForClassMembers = !context.options[1] || context.options[1].enforceForClassMembers;
|
55
55
|
|
@@ -48,7 +48,7 @@ module.exports = {
|
|
48
48
|
docs: {
|
49
49
|
description: "Require `return` statements to either always or never specify values",
|
50
50
|
recommended: false,
|
51
|
-
url: "https://eslint.org/docs/rules/consistent-return"
|
51
|
+
url: "https://eslint.org/docs/latest/rules/consistent-return"
|
52
52
|
},
|
53
53
|
|
54
54
|
schema: [{
|
@@ -104,7 +104,7 @@ module.exports = {
|
|
104
104
|
} else if (node.type === "ArrowFunctionExpression") {
|
105
105
|
|
106
106
|
// `=>` token
|
107
|
-
loc = context.
|
107
|
+
loc = context.sourceCode.getTokenBefore(node.body, astUtils.isArrowToken).loc;
|
108
108
|
} else if (
|
109
109
|
node.parent.type === "MethodDefinition" ||
|
110
110
|
(node.parent.type === "Property" && node.parent.method)
|
@@ -115,7 +115,7 @@ module.exports = {
|
|
115
115
|
} else {
|
116
116
|
|
117
117
|
// Function name or `function` keyword.
|
118
|
-
loc = (node.id || context.
|
118
|
+
loc = (node.id || context.sourceCode.getFirstToken(node)).loc;
|
119
119
|
}
|
120
120
|
|
121
121
|
if (!name) {
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Enforce consistent naming when capturing the current execution context",
|
18
18
|
recommended: false,
|
19
|
-
url: "https://eslint.org/docs/rules/consistent-this"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/consistent-this"
|
20
20
|
},
|
21
21
|
|
22
22
|
schema: {
|
@@ -36,7 +36,7 @@ module.exports = {
|
|
36
36
|
|
37
37
|
create(context) {
|
38
38
|
let aliases = [];
|
39
|
-
const sourceCode = context.
|
39
|
+
const sourceCode = context.sourceCode;
|
40
40
|
|
41
41
|
if (context.options.length === 0) {
|
42
42
|
aliases.push("that");
|
@@ -124,7 +124,7 @@ module.exports = {
|
|
124
124
|
docs: {
|
125
125
|
description: "Require `super()` calls in constructors",
|
126
126
|
recommended: true,
|
127
|
-
url: "https://eslint.org/docs/rules/constructor-super"
|
127
|
+
url: "https://eslint.org/docs/latest/rules/constructor-super"
|
128
128
|
},
|
129
129
|
|
130
130
|
schema: [],
|
package/lib/rules/curly.js
CHANGED
@@ -22,7 +22,7 @@ module.exports = {
|
|
22
22
|
docs: {
|
23
23
|
description: "Enforce consistent brace style for all control statements",
|
24
24
|
recommended: false,
|
25
|
-
url: "https://eslint.org/docs/rules/curly"
|
25
|
+
url: "https://eslint.org/docs/latest/rules/curly"
|
26
26
|
},
|
27
27
|
|
28
28
|
schema: {
|
@@ -70,7 +70,7 @@ module.exports = {
|
|
70
70
|
const multiOrNest = (context.options[0] === "multi-or-nest");
|
71
71
|
const consistent = (context.options[1] === "consistent");
|
72
72
|
|
73
|
-
const sourceCode = context.
|
73
|
+
const sourceCode = context.sourceCode;
|
74
74
|
|
75
75
|
//--------------------------------------------------------------------------
|
76
76
|
// Helpers
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Enforce default clauses in switch statements to be last",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/default-case-last"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/default-case-last"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
@@ -18,7 +18,7 @@ module.exports = {
|
|
18
18
|
docs: {
|
19
19
|
description: "Require `default` cases in `switch` statements",
|
20
20
|
recommended: false,
|
21
|
-
url: "https://eslint.org/docs/rules/default-case"
|
21
|
+
url: "https://eslint.org/docs/latest/rules/default-case"
|
22
22
|
},
|
23
23
|
|
24
24
|
schema: [{
|
@@ -42,7 +42,7 @@ module.exports = {
|
|
42
42
|
? new RegExp(options.commentPattern, "u")
|
43
43
|
: DEFAULT_COMMENT_PATTERN;
|
44
44
|
|
45
|
-
const sourceCode = context.
|
45
|
+
const sourceCode = context.sourceCode;
|
46
46
|
|
47
47
|
//--------------------------------------------------------------------------
|
48
48
|
// Helpers
|
@@ -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
@@ -510,7 +510,7 @@ module.exports = {
|
|
510
510
|
docs: {
|
511
511
|
description: "Enforce consistent indentation",
|
512
512
|
recommended: false,
|
513
|
-
url: "https://eslint.org/docs/rules/indent"
|
513
|
+
url: "https://eslint.org/docs/latest/rules/indent"
|
514
514
|
},
|
515
515
|
|
516
516
|
fixable: "whitespace",
|
@@ -703,7 +703,7 @@ module.exports = {
|
|
703
703
|
}
|
704
704
|
}
|
705
705
|
|
706
|
-
const sourceCode = context.
|
706
|
+
const sourceCode = context.sourceCode;
|
707
707
|
const tokenInfo = new TokenInfo(sourceCode);
|
708
708
|
const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t");
|
709
709
|
const parameterParens = new WeakSet();
|
@@ -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",
|