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
package/lib/rules/valid-jsdoc.js
CHANGED
@@ -23,7 +23,7 @@ module.exports = {
|
|
23
23
|
docs: {
|
24
24
|
description: "Enforce valid JSDoc comments",
|
25
25
|
recommended: false,
|
26
|
-
url: "https://eslint.org/docs/rules/valid-jsdoc"
|
26
|
+
url: "https://eslint.org/docs/latest/rules/valid-jsdoc"
|
27
27
|
},
|
28
28
|
|
29
29
|
schema: [
|
@@ -96,7 +96,7 @@ module.exports = {
|
|
96
96
|
|
97
97
|
const options = context.options[0] || {},
|
98
98
|
prefer = options.prefer || {},
|
99
|
-
sourceCode = context.
|
99
|
+
sourceCode = context.sourceCode,
|
100
100
|
|
101
101
|
// these both default to true, so you have to explicitly make them false
|
102
102
|
requireReturn = options.requireReturn !== false,
|
@@ -16,7 +16,7 @@ module.exports = {
|
|
16
16
|
docs: {
|
17
17
|
description: "Enforce comparing `typeof` expressions against valid strings",
|
18
18
|
recommended: true,
|
19
|
-
url: "https://eslint.org/docs/rules/valid-typeof"
|
19
|
+
url: "https://eslint.org/docs/latest/rules/valid-typeof"
|
20
20
|
},
|
21
21
|
|
22
22
|
hasSuggestions: true,
|
@@ -44,7 +44,7 @@ module.exports = {
|
|
44
44
|
|
45
45
|
const VALID_TYPES = new Set(["symbol", "undefined", "object", "boolean", "number", "string", "function", "bigint"]),
|
46
46
|
OPERATORS = new Set(["==", "===", "!=", "!=="]);
|
47
|
-
const sourceCode = context.
|
47
|
+
const sourceCode = context.sourceCode;
|
48
48
|
const requireStringLiterals = context.options[0] && context.options[0].requireStringLiterals;
|
49
49
|
|
50
50
|
let globalScope;
|
package/lib/rules/vars-on-top.js
CHANGED
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require `var` declarations be placed at the top of their containing scope",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/vars-on-top"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/vars-on-top"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
package/lib/rules/wrap-iife.js
CHANGED
@@ -45,7 +45,7 @@ module.exports = {
|
|
45
45
|
docs: {
|
46
46
|
description: "Require parentheses around immediate `function` invocations",
|
47
47
|
recommended: false,
|
48
|
-
url: "https://eslint.org/docs/rules/wrap-iife"
|
48
|
+
url: "https://eslint.org/docs/latest/rules/wrap-iife"
|
49
49
|
},
|
50
50
|
|
51
51
|
schema: [
|
@@ -77,7 +77,7 @@ module.exports = {
|
|
77
77
|
const style = context.options[0] || "outside";
|
78
78
|
const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods;
|
79
79
|
|
80
|
-
const sourceCode = context.
|
80
|
+
const sourceCode = context.sourceCode;
|
81
81
|
|
82
82
|
/**
|
83
83
|
* Check if the node is wrapped in any (). All parens count: grouping parens and parens for constructs such as if()
|
package/lib/rules/wrap-regex.js
CHANGED
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require parenthesis around regex literals",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/wrap-regex"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/wrap-regex"
|
21
21
|
},
|
22
22
|
|
23
23
|
schema: [],
|
@@ -29,7 +29,7 @@ module.exports = {
|
|
29
29
|
},
|
30
30
|
|
31
31
|
create(context) {
|
32
|
-
const sourceCode = context.
|
32
|
+
const sourceCode = context.sourceCode;
|
33
33
|
|
34
34
|
return {
|
35
35
|
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
docs: {
|
18
18
|
description: "Require or disallow spacing around the `*` in `yield*` expressions",
|
19
19
|
recommended: false,
|
20
|
-
url: "https://eslint.org/docs/rules/yield-star-spacing"
|
20
|
+
url: "https://eslint.org/docs/latest/rules/yield-star-spacing"
|
21
21
|
},
|
22
22
|
|
23
23
|
fixable: "whitespace",
|
@@ -48,7 +48,7 @@ module.exports = {
|
|
48
48
|
},
|
49
49
|
|
50
50
|
create(context) {
|
51
|
-
const sourceCode = context.
|
51
|
+
const sourceCode = context.sourceCode;
|
52
52
|
|
53
53
|
const mode = (function(option) {
|
54
54
|
if (!option || typeof option === "string") {
|
package/lib/rules/yoda.js
CHANGED
@@ -123,7 +123,7 @@ module.exports = {
|
|
123
123
|
docs: {
|
124
124
|
description: 'Require or disallow "Yoda" conditions',
|
125
125
|
recommended: false,
|
126
|
-
url: "https://eslint.org/docs/rules/yoda"
|
126
|
+
url: "https://eslint.org/docs/latest/rules/yoda"
|
127
127
|
},
|
128
128
|
|
129
129
|
schema: [
|
@@ -162,7 +162,7 @@ module.exports = {
|
|
162
162
|
const onlyEquality =
|
163
163
|
context.options[1] && context.options[1].onlyEquality;
|
164
164
|
|
165
|
-
const sourceCode = context.
|
165
|
+
const sourceCode = context.sourceCode;
|
166
166
|
|
167
167
|
/**
|
168
168
|
* Determines whether node represents a range test.
|
@@ -5,6 +5,26 @@
|
|
5
5
|
|
6
6
|
"use strict";
|
7
7
|
|
8
|
+
//------------------------------------------------------------------------------
|
9
|
+
// Requirements
|
10
|
+
//------------------------------------------------------------------------------
|
11
|
+
|
12
|
+
const Graphemer = require("graphemer").default;
|
13
|
+
|
14
|
+
//------------------------------------------------------------------------------
|
15
|
+
// Helpers
|
16
|
+
//------------------------------------------------------------------------------
|
17
|
+
|
18
|
+
// eslint-disable-next-line no-control-regex -- intentionally including control characters
|
19
|
+
const ASCII_REGEX = /^[\u0000-\u007f]*$/u;
|
20
|
+
|
21
|
+
/** @type {Graphemer | undefined} */
|
22
|
+
let splitter;
|
23
|
+
|
24
|
+
//------------------------------------------------------------------------------
|
25
|
+
// Public Interface
|
26
|
+
//------------------------------------------------------------------------------
|
27
|
+
|
8
28
|
/**
|
9
29
|
* Converts the first letter of a string to uppercase.
|
10
30
|
* @param {string} string The string to operate on
|
@@ -17,6 +37,24 @@ function upperCaseFirst(string) {
|
|
17
37
|
return string[0].toUpperCase() + string.slice(1);
|
18
38
|
}
|
19
39
|
|
40
|
+
/**
|
41
|
+
* Counts graphemes in a given string.
|
42
|
+
* @param {string} value A string to count graphemes.
|
43
|
+
* @returns {number} The number of graphemes in `value`.
|
44
|
+
*/
|
45
|
+
function getGraphemeCount(value) {
|
46
|
+
if (ASCII_REGEX.test(value)) {
|
47
|
+
return value.length;
|
48
|
+
}
|
49
|
+
|
50
|
+
if (!splitter) {
|
51
|
+
splitter = new Graphemer();
|
52
|
+
}
|
53
|
+
|
54
|
+
return splitter.countGraphemes(value);
|
55
|
+
}
|
56
|
+
|
20
57
|
module.exports = {
|
21
|
-
upperCaseFirst
|
58
|
+
upperCaseFirst,
|
59
|
+
getGraphemeCount
|
22
60
|
};
|
package/lib/shared/types.js
CHANGED
@@ -96,10 +96,12 @@ module.exports = {};
|
|
96
96
|
* @property {number|undefined} column The 1-based column number.
|
97
97
|
* @property {number} [endColumn] The 1-based column number of the end location.
|
98
98
|
* @property {number} [endLine] The 1-based line number of the end location.
|
99
|
-
* @property {boolean} fatal If `true` then this is a fatal error.
|
99
|
+
* @property {boolean} [fatal] If `true` then this is a fatal error.
|
100
100
|
* @property {{range:[number,number], text:string}} [fix] Information for autofix.
|
101
101
|
* @property {number|undefined} line The 1-based line number.
|
102
102
|
* @property {string} message The error message.
|
103
|
+
* @property {string} [messageId] The ID of the message in the rule's meta.
|
104
|
+
* @property {(string|null)} nodeType Type of node
|
103
105
|
* @property {string|null} ruleId The ID of the rule which makes this message.
|
104
106
|
* @property {0|1|2} severity The severity of this message.
|
105
107
|
* @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions.
|
@@ -110,10 +112,12 @@ module.exports = {};
|
|
110
112
|
* @property {number|undefined} column The 1-based column number.
|
111
113
|
* @property {number} [endColumn] The 1-based column number of the end location.
|
112
114
|
* @property {number} [endLine] The 1-based line number of the end location.
|
113
|
-
* @property {boolean} fatal If `true` then this is a fatal error.
|
115
|
+
* @property {boolean} [fatal] If `true` then this is a fatal error.
|
114
116
|
* @property {{range:[number,number], text:string}} [fix] Information for autofix.
|
115
117
|
* @property {number|undefined} line The 1-based line number.
|
116
118
|
* @property {string} message The error message.
|
119
|
+
* @property {string} [messageId] The ID of the message in the rule's meta.
|
120
|
+
* @property {(string|null)} nodeType Type of node
|
117
121
|
* @property {string|null} ruleId The ID of the rule which makes this message.
|
118
122
|
* @property {0|1|2} severity The severity of this message.
|
119
123
|
* @property {Array<{kind: string, justification: string}>} suppressions The suppression info.
|
package/lib/unsupported-api.js
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
//-----------------------------------------------------------------------------
|
13
13
|
|
14
14
|
const { FileEnumerator } = require("./cli-engine/file-enumerator");
|
15
|
-
const { FlatESLint } = require("./eslint/flat-eslint");
|
15
|
+
const { FlatESLint, shouldUseFlatConfig } = require("./eslint/flat-eslint");
|
16
16
|
const FlatRuleTester = require("./rule-tester/flat-rule-tester");
|
17
17
|
|
18
18
|
//-----------------------------------------------------------------------------
|
@@ -22,6 +22,7 @@ const FlatRuleTester = require("./rule-tester/flat-rule-tester");
|
|
22
22
|
module.exports = {
|
23
23
|
builtinRules: require("./rules"),
|
24
24
|
FlatESLint,
|
25
|
+
shouldUseFlatConfig,
|
25
26
|
FlatRuleTester,
|
26
27
|
FileEnumerator
|
27
28
|
};
|
@@ -0,0 +1,17 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const { stringifyValueForError } = require("./shared");
|
4
|
+
|
5
|
+
module.exports = function({ ruleId, value }) {
|
6
|
+
return `
|
7
|
+
Configuration for rule "${ruleId}" is invalid. Each rule must have a severity ("off", 0, "warn", 1, "error", or 2) and may be followed by additional options for the rule.
|
8
|
+
|
9
|
+
You passed '${stringifyValueForError(value, 4)}', which doesn't contain a valid severity.
|
10
|
+
|
11
|
+
If you're attempting to configure rule options, perhaps you meant:
|
12
|
+
|
13
|
+
"${ruleId}": ["error", ${stringifyValueForError(value, 8)}]
|
14
|
+
|
15
|
+
See https://eslint.org/docs/latest/use/configure/rules#using-configuration-files for configuring rules.
|
16
|
+
`.trimStart();
|
17
|
+
};
|
@@ -0,0 +1,13 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
const { stringifyValueForError } = require("./shared");
|
4
|
+
|
5
|
+
module.exports = function({ ruleId, value }) {
|
6
|
+
return `
|
7
|
+
Configuration for rule "${ruleId}" is invalid. Expected severity of "off", 0, "warn", 1, "error", or 2.
|
8
|
+
|
9
|
+
You passed '${stringifyValueForError(value, 4)}'.
|
10
|
+
|
11
|
+
See https://eslint.org/docs/latest/use/configure/rules#using-configuration-files for configuring rules.
|
12
|
+
`.trimStart();
|
13
|
+
};
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* @fileoverview Shared utilities for error messages.
|
3
|
+
* @author Josh Goldberg
|
4
|
+
*/
|
5
|
+
|
6
|
+
"use strict";
|
7
|
+
|
8
|
+
/**
|
9
|
+
* Converts a value to a string that may be printed in errors.
|
10
|
+
* @param {any} value The invalid value.
|
11
|
+
* @param {number} indentation How many spaces to indent
|
12
|
+
* @returns {string} The value, stringified.
|
13
|
+
*/
|
14
|
+
function stringifyValueForError(value, indentation) {
|
15
|
+
return value ? JSON.stringify(value, null, 4).replace(/\n/gu, `\n${" ".repeat(indentation)}`) : `${value}`;
|
16
|
+
}
|
17
|
+
|
18
|
+
module.exports = { stringifyValueForError };
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "eslint",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.41.0",
|
4
4
|
"author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
|
5
5
|
"description": "An AST-based pattern checker for JavaScript.",
|
6
6
|
"bin": {
|
@@ -62,8 +62,8 @@
|
|
62
62
|
"dependencies": {
|
63
63
|
"@eslint-community/eslint-utils": "^4.2.0",
|
64
64
|
"@eslint-community/regexpp": "^4.4.0",
|
65
|
-
"@eslint/eslintrc": "^2.0.
|
66
|
-
"@eslint/js": "8.
|
65
|
+
"@eslint/eslintrc": "^2.0.3",
|
66
|
+
"@eslint/js": "8.41.0",
|
67
67
|
"@humanwhocodes/config-array": "^0.11.8",
|
68
68
|
"@humanwhocodes/module-importer": "^1.0.1",
|
69
69
|
"@nodelib/fs.walk": "^1.2.8",
|
@@ -74,8 +74,8 @@
|
|
74
74
|
"doctrine": "^3.0.0",
|
75
75
|
"escape-string-regexp": "^4.0.0",
|
76
76
|
"eslint-scope": "^7.2.0",
|
77
|
-
"eslint-visitor-keys": "^3.4.
|
78
|
-
"espree": "^9.5.
|
77
|
+
"eslint-visitor-keys": "^3.4.1",
|
78
|
+
"espree": "^9.5.2",
|
79
79
|
"esquery": "^1.4.2",
|
80
80
|
"esutils": "^2.0.2",
|
81
81
|
"fast-deep-equal": "^3.1.3",
|
@@ -83,13 +83,12 @@
|
|
83
83
|
"find-up": "^5.0.0",
|
84
84
|
"glob-parent": "^6.0.2",
|
85
85
|
"globals": "^13.19.0",
|
86
|
-
"
|
86
|
+
"graphemer": "^1.4.0",
|
87
87
|
"ignore": "^5.2.0",
|
88
88
|
"import-fresh": "^3.0.0",
|
89
89
|
"imurmurhash": "^0.1.4",
|
90
90
|
"is-glob": "^4.0.0",
|
91
91
|
"is-path-inside": "^3.0.3",
|
92
|
-
"js-sdsl": "^4.1.4",
|
93
92
|
"js-yaml": "^4.1.0",
|
94
93
|
"json-stable-stringify-without-jsonify": "^1.0.1",
|
95
94
|
"levn": "^0.4.1",
|