eslint 9.23.0 → 9.25.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 -2
- package/lib/cli-engine/cli-engine.js +2 -2
- package/lib/cli-engine/formatters/html.js +3 -3
- package/lib/cli-engine/formatters/stylish.js +1 -1
- package/lib/cli.js +98 -1
- package/lib/config/config-loader.js +108 -34
- package/lib/config/flat-config-helpers.js +7 -4
- package/lib/eslint/eslint-helpers.js +50 -5
- package/lib/eslint/eslint.js +17 -53
- package/lib/eslint/legacy-eslint.js +1 -1
- package/lib/languages/js/source-code/source-code.js +3 -3
- package/lib/languages/js/source-code/token-store/index.js +3 -3
- package/lib/linter/code-path-analysis/code-path-state.js +1 -1
- package/lib/linter/linter.js +1 -1
- package/lib/linter/node-event-generator.js +3 -1
- package/lib/linter/report-translator.js +1 -1
- package/lib/linter/rule-fixer.js +13 -5
- package/lib/linter/rules.js +1 -1
- package/lib/linter/source-code-fixer.js +2 -2
- package/lib/linter/timing.js +2 -2
- package/lib/options.js +29 -0
- package/lib/rule-tester/rule-tester.js +1 -1
- package/lib/rules/accessor-pairs.js +1 -1
- package/lib/rules/array-bracket-newline.js +1 -1
- package/lib/rules/array-bracket-spacing.js +1 -1
- package/lib/rules/array-callback-return.js +1 -1
- package/lib/rules/array-element-newline.js +1 -1
- package/lib/rules/arrow-body-style.js +1 -1
- package/lib/rules/arrow-parens.js +1 -1
- package/lib/rules/arrow-spacing.js +1 -1
- package/lib/rules/block-scoped-var.js +1 -1
- package/lib/rules/block-spacing.js +1 -1
- package/lib/rules/brace-style.js +1 -1
- package/lib/rules/callback-return.js +1 -1
- package/lib/rules/camelcase.js +1 -1
- package/lib/rules/capitalized-comments.js +1 -1
- package/lib/rules/class-methods-use-this.js +46 -2
- package/lib/rules/comma-dangle.js +1 -1
- package/lib/rules/comma-spacing.js +1 -1
- package/lib/rules/comma-style.js +1 -1
- package/lib/rules/complexity.js +1 -1
- package/lib/rules/computed-property-spacing.js +1 -1
- package/lib/rules/consistent-return.js +1 -1
- package/lib/rules/consistent-this.js +1 -1
- package/lib/rules/constructor-super.js +1 -1
- package/lib/rules/curly.js +1 -1
- package/lib/rules/default-case-last.js +1 -1
- package/lib/rules/default-case.js +1 -1
- package/lib/rules/default-param-last.js +1 -1
- package/lib/rules/dot-location.js +1 -1
- package/lib/rules/dot-notation.js +1 -1
- package/lib/rules/eol-last.js +1 -1
- package/lib/rules/eqeqeq.js +1 -1
- package/lib/rules/for-direction.js +5 -5
- package/lib/rules/func-call-spacing.js +1 -1
- package/lib/rules/func-name-matching.js +2 -2
- package/lib/rules/func-names.js +1 -1
- package/lib/rules/func-style.js +1 -1
- package/lib/rules/function-call-argument-newline.js +1 -1
- package/lib/rules/function-paren-newline.js +1 -1
- package/lib/rules/generator-star-spacing.js +1 -1
- package/lib/rules/getter-return.js +1 -1
- package/lib/rules/global-require.js +1 -1
- package/lib/rules/grouped-accessor-pairs.js +1 -1
- package/lib/rules/guard-for-in.js +1 -1
- package/lib/rules/handle-callback-err.js +1 -1
- package/lib/rules/id-blacklist.js +1 -1
- package/lib/rules/id-denylist.js +1 -1
- package/lib/rules/id-length.js +1 -1
- package/lib/rules/id-match.js +1 -1
- package/lib/rules/implicit-arrow-linebreak.js +1 -1
- package/lib/rules/indent-legacy.js +14 -14
- package/lib/rules/indent.js +4 -4
- package/lib/rules/init-declarations.js +22 -1
- package/lib/rules/jsx-quotes.js +1 -1
- package/lib/rules/key-spacing.js +3 -3
- package/lib/rules/keyword-spacing.js +1 -1
- package/lib/rules/line-comment-position.js +1 -1
- package/lib/rules/linebreak-style.js +10 -2
- package/lib/rules/lines-around-comment.js +1 -1
- package/lib/rules/lines-around-directive.js +1 -1
- package/lib/rules/lines-between-class-members.js +1 -1
- package/lib/rules/logical-assignment-operators.js +1 -1
- package/lib/rules/max-classes-per-file.js +1 -1
- package/lib/rules/max-depth.js +1 -1
- package/lib/rules/max-len.js +3 -3
- package/lib/rules/max-lines-per-function.js +1 -1
- package/lib/rules/max-lines.js +1 -1
- package/lib/rules/max-nested-callbacks.js +1 -1
- package/lib/rules/max-params.js +1 -1
- package/lib/rules/max-statements-per-line.js +1 -1
- package/lib/rules/max-statements.js +3 -3
- package/lib/rules/multiline-comment-style.js +1 -1
- package/lib/rules/multiline-ternary.js +1 -1
- package/lib/rules/new-cap.js +1 -1
- package/lib/rules/new-parens.js +1 -1
- package/lib/rules/newline-after-var.js +1 -1
- package/lib/rules/newline-before-return.js +1 -1
- package/lib/rules/newline-per-chained-call.js +1 -1
- package/lib/rules/no-alert.js +1 -1
- package/lib/rules/no-array-constructor.js +4 -1
- package/lib/rules/no-async-promise-executor.js +1 -1
- 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 +1 -1
- package/lib/rules/no-class-assign.js +1 -1
- package/lib/rules/no-compare-neg-zero.js +1 -1
- package/lib/rules/no-cond-assign.js +1 -1
- package/lib/rules/no-confusing-arrow.js +1 -1
- package/lib/rules/no-console.js +1 -1
- package/lib/rules/no-const-assign.js +1 -1
- package/lib/rules/no-constant-binary-expression.js +2 -2
- package/lib/rules/no-constant-condition.js +1 -1
- 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 +1 -1
- package/lib/rules/no-dupe-args.js +1 -1
- package/lib/rules/no-dupe-class-members.js +10 -1
- package/lib/rules/no-dupe-else-if.js +1 -1
- package/lib/rules/no-dupe-keys.js +1 -1
- package/lib/rules/no-duplicate-case.js +1 -1
- package/lib/rules/no-duplicate-imports.js +1 -1
- package/lib/rules/no-else-return.js +1 -1
- package/lib/rules/no-empty-character-class.js +1 -1
- package/lib/rules/no-empty-function.js +54 -3
- package/lib/rules/no-empty-pattern.js +1 -1
- package/lib/rules/no-empty-static-block.js +1 -1
- package/lib/rules/no-empty.js +1 -1
- package/lib/rules/no-eq-null.js +1 -1
- package/lib/rules/no-eval.js +1 -1
- package/lib/rules/no-ex-assign.js +1 -1
- package/lib/rules/no-extend-native.js +1 -1
- package/lib/rules/no-extra-bind.js +1 -1
- package/lib/rules/no-extra-boolean-cast.js +1 -1
- package/lib/rules/no-extra-label.js +1 -1
- package/lib/rules/no-extra-parens.js +1 -1
- package/lib/rules/no-extra-semi.js +1 -1
- package/lib/rules/no-fallthrough.js +1 -1
- package/lib/rules/no-floating-decimal.js +1 -1
- package/lib/rules/no-func-assign.js +1 -1
- package/lib/rules/no-global-assign.js +2 -2
- package/lib/rules/no-implicit-coercion.js +1 -1
- package/lib/rules/no-implicit-globals.js +1 -1
- package/lib/rules/no-implied-eval.js +1 -1
- package/lib/rules/no-import-assign.js +1 -1
- package/lib/rules/no-inline-comments.js +1 -1
- 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 +23 -1
- package/lib/rules/no-irregular-whitespace.js +1 -1
- package/lib/rules/no-iterator.js +1 -1
- package/lib/rules/no-label-var.js +1 -1
- package/lib/rules/no-labels.js +1 -1
- package/lib/rules/no-lone-blocks.js +1 -1
- package/lib/rules/no-lonely-if.js +1 -1
- package/lib/rules/no-loop-func.js +10 -4
- package/lib/rules/no-loss-of-precision.js +3 -1
- package/lib/rules/no-magic-numbers.js +1 -1
- package/lib/rules/no-misleading-character-class.js +1 -1
- package/lib/rules/no-mixed-operators.js +1 -1
- package/lib/rules/no-mixed-requires.js +1 -1
- package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
- package/lib/rules/no-multi-assign.js +1 -1
- package/lib/rules/no-multi-spaces.js +1 -1
- package/lib/rules/no-multi-str.js +1 -1
- package/lib/rules/no-multiple-empty-lines.js +1 -1
- 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 +1 -1
- package/lib/rules/no-new-native-nonconstructor.js +1 -1
- package/lib/rules/no-new-object.js +1 -1
- package/lib/rules/no-new-require.js +1 -1
- package/lib/rules/no-new-symbol.js +1 -1
- 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 +10 -2
- package/lib/rules/no-obj-calls.js +1 -1
- package/lib/rules/no-object-constructor.js +1 -1
- 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 +1 -1
- package/lib/rules/no-proto.js +1 -1
- package/lib/rules/no-prototype-builtins.js +1 -1
- package/lib/rules/no-redeclare.js +1 -1
- package/lib/rules/no-regex-spaces.js +1 -1
- package/lib/rules/no-restricted-exports.js +1 -1
- package/lib/rules/no-restricted-globals.js +1 -1
- package/lib/rules/no-restricted-imports.js +1 -1
- package/lib/rules/no-restricted-modules.js +1 -1
- package/lib/rules/no-restricted-properties.js +43 -29
- package/lib/rules/no-restricted-syntax.js +1 -1
- package/lib/rules/no-return-assign.js +1 -1
- package/lib/rules/no-return-await.js +1 -2
- package/lib/rules/no-script-url.js +1 -1
- package/lib/rules/no-self-assign.js +1 -1
- package/lib/rules/no-self-compare.js +1 -1
- package/lib/rules/no-sequences.js +1 -1
- package/lib/rules/no-setter-return.js +1 -1
- package/lib/rules/no-shadow-restricted-names.js +1 -1
- package/lib/rules/no-shadow.js +1 -1
- package/lib/rules/no-spaced-func.js +1 -1
- package/lib/rules/no-sparse-arrays.js +1 -1
- package/lib/rules/no-sync.js +1 -1
- package/lib/rules/no-tabs.js +1 -1
- 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 +11 -3
- package/lib/rules/no-undef-init.js +1 -1
- package/lib/rules/no-undef.js +1 -1
- package/lib/rules/no-undefined.js +1 -1
- package/lib/rules/no-underscore-dangle.js +1 -1
- package/lib/rules/no-unexpected-multiline.js +1 -1
- package/lib/rules/no-unmodified-loop-condition.js +1 -1
- package/lib/rules/no-unneeded-ternary.js +1 -1
- package/lib/rules/no-unreachable-loop.js +1 -1
- package/lib/rules/no-unreachable.js +1 -1
- package/lib/rules/no-unsafe-finally.js +1 -1
- package/lib/rules/no-unsafe-negation.js +1 -1
- package/lib/rules/no-unsafe-optional-chaining.js +1 -1
- package/lib/rules/no-unused-expressions.js +15 -57
- package/lib/rules/no-unused-labels.js +1 -1
- package/lib/rules/no-unused-private-class-members.js +1 -1
- package/lib/rules/no-unused-vars.js +3 -3
- package/lib/rules/no-use-before-define.js +1 -1
- package/lib/rules/no-useless-assignment.js +1 -1
- package/lib/rules/no-useless-backreference.js +1 -1
- package/lib/rules/no-useless-call.js +1 -1
- package/lib/rules/no-useless-catch.js +1 -1
- package/lib/rules/no-useless-computed-key.js +1 -1
- package/lib/rules/no-useless-concat.js +1 -1
- package/lib/rules/no-useless-constructor.js +1 -1
- package/lib/rules/no-useless-escape.js +1 -1
- package/lib/rules/no-useless-rename.js +1 -1
- package/lib/rules/no-useless-return.js +1 -1
- package/lib/rules/no-var.js +1 -1
- package/lib/rules/no-void.js +1 -1
- package/lib/rules/no-warning-comments.js +1 -1
- package/lib/rules/no-whitespace-before-property.js +1 -1
- package/lib/rules/no-with.js +1 -1
- package/lib/rules/nonblock-statement-body-position.js +1 -1
- package/lib/rules/object-curly-newline.js +1 -1
- package/lib/rules/object-curly-spacing.js +1 -1
- package/lib/rules/object-property-newline.js +1 -1
- package/lib/rules/object-shorthand.js +1 -1
- package/lib/rules/one-var-declaration-per-line.js +1 -1
- package/lib/rules/one-var.js +1 -1
- package/lib/rules/operator-assignment.js +1 -1
- package/lib/rules/operator-linebreak.js +1 -1
- package/lib/rules/padded-blocks.js +1 -1
- package/lib/rules/padding-line-between-statements.js +1 -1
- package/lib/rules/prefer-arrow-callback.js +1 -1
- package/lib/rules/prefer-const.js +1 -1
- package/lib/rules/prefer-destructuring.js +1 -1
- package/lib/rules/prefer-exponentiation-operator.js +1 -1
- package/lib/rules/prefer-named-capture-group.js +1 -1
- package/lib/rules/prefer-numeric-literals.js +1 -1
- package/lib/rules/prefer-object-has-own.js +1 -1
- package/lib/rules/prefer-object-spread.js +1 -1
- package/lib/rules/prefer-promise-reject-errors.js +1 -1
- package/lib/rules/prefer-reflect.js +1 -2
- package/lib/rules/prefer-regex-literals.js +1 -1
- package/lib/rules/prefer-rest-params.js +1 -1
- package/lib/rules/prefer-spread.js +1 -1
- package/lib/rules/prefer-template.js +1 -1
- package/lib/rules/quote-props.js +1 -1
- package/lib/rules/quotes.js +1 -1
- package/lib/rules/radix.js +1 -1
- package/lib/rules/require-atomic-updates.js +1 -1
- package/lib/rules/require-await.js +1 -1
- package/lib/rules/require-unicode-regexp.js +1 -1
- package/lib/rules/require-yield.js +1 -1
- package/lib/rules/rest-spread-spacing.js +1 -1
- package/lib/rules/semi-spacing.js +1 -1
- package/lib/rules/semi-style.js +1 -1
- package/lib/rules/semi.js +1 -1
- package/lib/rules/sort-imports.js +1 -1
- package/lib/rules/sort-keys.js +1 -1
- package/lib/rules/sort-vars.js +1 -1
- package/lib/rules/space-before-blocks.js +1 -1
- package/lib/rules/space-before-function-paren.js +1 -1
- package/lib/rules/space-in-parens.js +1 -1
- package/lib/rules/space-infix-ops.js +1 -1
- package/lib/rules/space-unary-ops.js +1 -1
- package/lib/rules/spaced-comment.js +1 -1
- package/lib/rules/strict.js +1 -1
- package/lib/rules/switch-colon-spacing.js +1 -1
- package/lib/rules/symbol-description.js +1 -1
- package/lib/rules/template-curly-spacing.js +1 -1
- package/lib/rules/template-tag-spacing.js +1 -1
- package/lib/rules/unicode-bom.js +1 -1
- package/lib/rules/use-isnan.js +1 -1
- package/lib/rules/utils/ast-utils.js +13 -2
- package/lib/rules/utils/fix-tracker.js +10 -2
- package/lib/rules/valid-typeof.js +1 -1
- package/lib/rules/vars-on-top.js +1 -1
- package/lib/rules/wrap-iife.js +1 -1
- package/lib/rules/wrap-regex.js +1 -1
- package/lib/rules/yield-star-spacing.js +1 -1
- package/lib/rules/yoda.js +1 -1
- package/lib/services/suppressions-service.js +289 -0
- package/lib/shared/flags.js +4 -0
- package/lib/shared/types.js +4 -27
- package/lib/types/index.d.ts +30 -7
- package/lib/types/rules.d.ts +14 -0
- package/package.json +9 -9
@@ -15,7 +15,7 @@ const { getStaticValue } = require("@eslint-community/eslint-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
/** @type {import('../
|
18
|
+
/** @type {import('../types').Rule.RuleModule} */
|
19
19
|
module.exports = {
|
20
20
|
meta: {
|
21
21
|
type: "problem",
|
@@ -54,8 +54,8 @@ module.exports = {
|
|
54
54
|
/**
|
55
55
|
* check the right side of the assignment
|
56
56
|
* @param {ASTNode} update UpdateExpression to check
|
57
|
-
* @param {
|
58
|
-
* @returns {
|
57
|
+
* @param {number} dir expected direction that could either be turned around or invalidated
|
58
|
+
* @returns {number} return dir, the negated dir, or zero if the counter does not change or the direction is not clear
|
59
59
|
*/
|
60
60
|
function getRightDirection(update, dir) {
|
61
61
|
const staticValue = getStaticValue(
|
@@ -80,7 +80,7 @@ module.exports = {
|
|
80
80
|
* check UpdateExpression add/sub the counter
|
81
81
|
* @param {ASTNode} update UpdateExpression to check
|
82
82
|
* @param {string} counter variable name to check
|
83
|
-
* @returns {
|
83
|
+
* @returns {number} if add return 1, if sub return -1, if nochange, return 0
|
84
84
|
*/
|
85
85
|
function getUpdateDirection(update, counter) {
|
86
86
|
if (
|
@@ -101,7 +101,7 @@ module.exports = {
|
|
101
101
|
* check AssignmentExpression add/sub the counter
|
102
102
|
* @param {ASTNode} update AssignmentExpression to check
|
103
103
|
* @param {string} counter variable name to check
|
104
|
-
* @returns {
|
104
|
+
* @returns {number} if add return 1, if sub return -1, if nochange, return 0
|
105
105
|
*/
|
106
106
|
function getAssignmentDirection(update, counter) {
|
107
107
|
if (update.left.name === counter) {
|
@@ -16,7 +16,7 @@ const astUtils = require("./utils/ast-utils");
|
|
16
16
|
// Rule Definition
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
|
19
|
-
/** @type {import('../
|
19
|
+
/** @type {import('../types').Rule.RuleModule} */
|
20
20
|
module.exports = {
|
21
21
|
meta: {
|
22
22
|
deprecated: {
|
@@ -49,7 +49,7 @@ function isModuleExports(pattern) {
|
|
49
49
|
/**
|
50
50
|
* Determines if a string name is a valid identifier
|
51
51
|
* @param {string} name The string to be checked
|
52
|
-
* @param {
|
52
|
+
* @param {number} ecmaVersion The ECMAScript version if specified in the parserOptions config
|
53
53
|
* @returns {boolean} True if the string is a valid identifier
|
54
54
|
*/
|
55
55
|
function isIdentifier(name, ecmaVersion) {
|
@@ -77,7 +77,7 @@ const optionsObject = {
|
|
77
77
|
additionalProperties: false,
|
78
78
|
};
|
79
79
|
|
80
|
-
/** @type {import('../
|
80
|
+
/** @type {import('../types').Rule.RuleModule} */
|
81
81
|
module.exports = {
|
82
82
|
meta: {
|
83
83
|
type: "suggestion",
|
package/lib/rules/func-names.js
CHANGED
@@ -24,7 +24,7 @@ function isFunctionName(variable) {
|
|
24
24
|
// Rule Definition
|
25
25
|
//------------------------------------------------------------------------------
|
26
26
|
|
27
|
-
/** @type {import('../
|
27
|
+
/** @type {import('../types').Rule.RuleModule} */
|
28
28
|
module.exports = {
|
29
29
|
meta: {
|
30
30
|
type: "suggestion",
|
package/lib/rules/func-style.js
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
// Rule Definition
|
9
9
|
//------------------------------------------------------------------------------
|
10
10
|
|
11
|
-
/** @type {import('../
|
11
|
+
/** @type {import('../types').Rule.RuleModule} */
|
12
12
|
module.exports = {
|
13
13
|
meta: {
|
14
14
|
type: "suggestion",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
// Rule Definition
|
11
11
|
//------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
/** @type {import('../
|
13
|
+
/** @type {import('../types').Rule.RuleModule} */
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
16
|
deprecated: {
|
@@ -15,7 +15,7 @@ const astUtils = require("./utils/ast-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
/** @type {import('../
|
18
|
+
/** @type {import('../types').Rule.RuleModule} */
|
19
19
|
module.exports = {
|
20
20
|
meta: {
|
21
21
|
deprecated: {
|
@@ -36,7 +36,7 @@ function isAnySegmentReachable(segments) {
|
|
36
36
|
// Rule Definition
|
37
37
|
//------------------------------------------------------------------------------
|
38
38
|
|
39
|
-
/** @type {import('../
|
39
|
+
/** @type {import('../types').Rule.RuleModule} */
|
40
40
|
module.exports = {
|
41
41
|
meta: {
|
42
42
|
type: "problem",
|
@@ -91,7 +91,7 @@ function isAccessorKind(node) {
|
|
91
91
|
// Rule Definition
|
92
92
|
//------------------------------------------------------------------------------
|
93
93
|
|
94
|
-
/** @type {import('../
|
94
|
+
/** @type {import('../types').Rule.RuleModule} */
|
95
95
|
module.exports = {
|
96
96
|
meta: {
|
97
97
|
type: "suggestion",
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Rule Definition
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
/** @type {import('../
|
12
|
+
/** @type {import('../types').Rule.RuleModule} */
|
13
13
|
module.exports = {
|
14
14
|
meta: {
|
15
15
|
type: "suggestion",
|
@@ -10,7 +10,7 @@
|
|
10
10
|
// Rule Definition
|
11
11
|
//------------------------------------------------------------------------------
|
12
12
|
|
13
|
-
/** @type {import('../
|
13
|
+
/** @type {import('../types').Rule.RuleModule} */
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
16
|
deprecated: {
|
@@ -94,7 +94,7 @@ function isShorthandPropertyDefinition(node) {
|
|
94
94
|
// Rule Definition
|
95
95
|
//------------------------------------------------------------------------------
|
96
96
|
|
97
|
-
/** @type {import('../
|
97
|
+
/** @type {import('../types').Rule.RuleModule} */
|
98
98
|
module.exports = {
|
99
99
|
meta: {
|
100
100
|
deprecated: {
|
package/lib/rules/id-denylist.js
CHANGED
@@ -83,7 +83,7 @@ function isPropertyNameInDestructuring(node) {
|
|
83
83
|
// Rule Definition
|
84
84
|
//------------------------------------------------------------------------------
|
85
85
|
|
86
|
-
/** @type {import('../
|
86
|
+
/** @type {import('../types').Rule.RuleModule} */
|
87
87
|
module.exports = {
|
88
88
|
meta: {
|
89
89
|
type: "suggestion",
|
package/lib/rules/id-length.js
CHANGED
@@ -20,7 +20,7 @@ const {
|
|
20
20
|
// Rule Definition
|
21
21
|
//------------------------------------------------------------------------------
|
22
22
|
|
23
|
-
/** @type {import('../
|
23
|
+
/** @type {import('../types').Rule.RuleModule} */
|
24
24
|
module.exports = {
|
25
25
|
meta: {
|
26
26
|
type: "suggestion",
|
package/lib/rules/id-match.js
CHANGED
@@ -15,7 +15,7 @@ const astUtils = require("./utils/ast-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
/** @type {import('../
|
18
|
+
/** @type {import('../types').Rule.RuleModule} */
|
19
19
|
module.exports = {
|
20
20
|
meta: {
|
21
21
|
type: "suggestion",
|
@@ -10,7 +10,7 @@ const { isCommentToken, isNotOpeningParenToken } = require("./utils/ast-utils");
|
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
// Rule Definition
|
12
12
|
//------------------------------------------------------------------------------
|
13
|
-
/** @type {import('../
|
13
|
+
/** @type {import('../types').Rule.RuleModule} */
|
14
14
|
module.exports = {
|
15
15
|
meta: {
|
16
16
|
deprecated: {
|
@@ -20,7 +20,7 @@ const astUtils = require("./utils/ast-utils");
|
|
20
20
|
//------------------------------------------------------------------------------
|
21
21
|
// this rule has known coverage issues, but it's deprecated and shouldn't be updated in the future anyway.
|
22
22
|
/* c8 ignore next */
|
23
|
-
/** @type {import('../
|
23
|
+
/** @type {import('../types').Rule.RuleModule} */
|
24
24
|
module.exports = {
|
25
25
|
meta: {
|
26
26
|
type: "layout",
|
@@ -302,9 +302,9 @@ module.exports = {
|
|
302
302
|
|
303
303
|
/**
|
304
304
|
* Creates an error message for a line, given the expected/actual indentation.
|
305
|
-
* @param {
|
306
|
-
* @param {
|
307
|
-
* @param {
|
305
|
+
* @param {number} expectedAmount The expected amount of indentation characters for this line
|
306
|
+
* @param {number} actualSpaces The actual number of indentation spaces that were found on this line
|
307
|
+
* @param {number} actualTabs The actual number of indentation tabs that were found on this line
|
308
308
|
* @returns {string} An error message for this line
|
309
309
|
*/
|
310
310
|
function createErrorMessageData(
|
@@ -345,9 +345,9 @@ module.exports = {
|
|
345
345
|
/**
|
346
346
|
* Reports a given indent violation
|
347
347
|
* @param {ASTNode} node Node violating the indent rule
|
348
|
-
* @param {
|
349
|
-
* @param {
|
350
|
-
* @param {
|
348
|
+
* @param {number} needed Expected indentation character count
|
349
|
+
* @param {number} gottenSpaces Indentation space count in the actual node/code
|
350
|
+
* @param {number} gottenTabs Indentation tab count in the actual node/code
|
351
351
|
* @param {Object} [loc] Error line and column location
|
352
352
|
* @param {boolean} isLastNodeCheck Is the error for last node check
|
353
353
|
* @returns {void}
|
@@ -449,7 +449,7 @@ module.exports = {
|
|
449
449
|
/**
|
450
450
|
* Check indent for node
|
451
451
|
* @param {ASTNode} node Node to check
|
452
|
-
* @param {
|
452
|
+
* @param {number} neededIndent needed indent
|
453
453
|
* @returns {void}
|
454
454
|
*/
|
455
455
|
function checkNodeIndent(node, neededIndent) {
|
@@ -502,7 +502,7 @@ module.exports = {
|
|
502
502
|
/**
|
503
503
|
* Check indent for nodes list
|
504
504
|
* @param {ASTNode[]} nodes list of node objects
|
505
|
-
* @param {
|
505
|
+
* @param {number} indent needed indent
|
506
506
|
* @returns {void}
|
507
507
|
*/
|
508
508
|
function checkNodesIndent(nodes, indent) {
|
@@ -512,7 +512,7 @@ module.exports = {
|
|
512
512
|
/**
|
513
513
|
* Check last node line indent this detects, that block closed correctly
|
514
514
|
* @param {ASTNode} node Node to examine
|
515
|
-
* @param {
|
515
|
+
* @param {number} lastLineIndent needed indent
|
516
516
|
* @returns {void}
|
517
517
|
*/
|
518
518
|
function checkLastNodeLineIndent(node, lastLineIndent) {
|
@@ -542,7 +542,7 @@ module.exports = {
|
|
542
542
|
* Check last node line indent this detects, that block closed correctly
|
543
543
|
* This function for more complicated return statement case, where closing parenthesis may be followed by ';'
|
544
544
|
* @param {ASTNode} node Node to examine
|
545
|
-
* @param {
|
545
|
+
* @param {number} firstLineIndent first line needed indent
|
546
546
|
* @returns {void}
|
547
547
|
*/
|
548
548
|
function checkLastReturnStatementLineIndent(node, firstLineIndent) {
|
@@ -583,7 +583,7 @@ module.exports = {
|
|
583
583
|
/**
|
584
584
|
* Check first node line indent is correct
|
585
585
|
* @param {ASTNode} node Node to examine
|
586
|
-
* @param {
|
586
|
+
* @param {number} firstLineIndent needed indent
|
587
587
|
* @returns {void}
|
588
588
|
*/
|
589
589
|
function checkFirstNodeLineIndent(node, firstLineIndent) {
|
@@ -1130,8 +1130,8 @@ module.exports = {
|
|
1130
1130
|
/**
|
1131
1131
|
* Returns the expected indentation for the case statement
|
1132
1132
|
* @param {ASTNode} node node to examine
|
1133
|
-
* @param {
|
1134
|
-
* @returns {
|
1133
|
+
* @param {number} [providedSwitchIndent] indent for switch statement
|
1134
|
+
* @returns {number} indent size
|
1135
1135
|
*/
|
1136
1136
|
function expectedCaseIndent(node, providedSwitchIndent) {
|
1137
1137
|
const switchNode =
|
package/lib/rules/indent.js
CHANGED
@@ -505,7 +505,7 @@ const ELEMENT_LIST_SCHEMA = {
|
|
505
505
|
],
|
506
506
|
};
|
507
507
|
|
508
|
-
/** @type {import('../
|
508
|
+
/** @type {import('../types').Rule.RuleModule} */
|
509
509
|
module.exports = {
|
510
510
|
meta: {
|
511
511
|
deprecated: {
|
@@ -743,9 +743,9 @@ module.exports = {
|
|
743
743
|
|
744
744
|
/**
|
745
745
|
* Creates an error message for a line, given the expected/actual indentation.
|
746
|
-
* @param {
|
747
|
-
* @param {
|
748
|
-
* @param {
|
746
|
+
* @param {number} expectedAmount The expected amount of indentation characters for this line
|
747
|
+
* @param {number} actualSpaces The actual number of indentation spaces that were found on this line
|
748
|
+
* @param {number} actualTabs The actual number of indentation tabs that were found on this line
|
749
749
|
* @returns {string} An error message for this line
|
750
750
|
*/
|
751
751
|
function createErrorMessageData(
|
@@ -44,10 +44,12 @@ function isInitialized(node) {
|
|
44
44
|
// Rule Definition
|
45
45
|
//------------------------------------------------------------------------------
|
46
46
|
|
47
|
-
/** @type {import('../
|
47
|
+
/** @type {import('../types').Rule.RuleModule} */
|
48
48
|
module.exports = {
|
49
49
|
meta: {
|
50
50
|
type: "suggestion",
|
51
|
+
dialects: ["typescript", "javascript"],
|
52
|
+
language: "javascript",
|
51
53
|
|
52
54
|
docs: {
|
53
55
|
description:
|
@@ -105,15 +107,34 @@ module.exports = {
|
|
105
107
|
const mode = context.options[0] || MODE_ALWAYS;
|
106
108
|
const params = context.options[1] || {};
|
107
109
|
|
110
|
+
// Track whether we're inside a declared namespace
|
111
|
+
let insideDeclaredNamespace = false;
|
112
|
+
|
108
113
|
//--------------------------------------------------------------------------
|
109
114
|
// Public API
|
110
115
|
//--------------------------------------------------------------------------
|
111
116
|
|
112
117
|
return {
|
118
|
+
TSModuleDeclaration(node) {
|
119
|
+
if (node.declare) {
|
120
|
+
insideDeclaredNamespace = true;
|
121
|
+
}
|
122
|
+
},
|
123
|
+
|
124
|
+
"TSModuleDeclaration:exit"(node) {
|
125
|
+
if (node.declare) {
|
126
|
+
insideDeclaredNamespace = false;
|
127
|
+
}
|
128
|
+
},
|
129
|
+
|
113
130
|
"VariableDeclaration:exit"(node) {
|
114
131
|
const kind = node.kind,
|
115
132
|
declarations = node.declarations;
|
116
133
|
|
134
|
+
if (node.declare || insideDeclaredNamespace) {
|
135
|
+
return;
|
136
|
+
}
|
137
|
+
|
117
138
|
for (let i = 0; i < declarations.length; ++i) {
|
118
139
|
const declaration = declarations[i],
|
119
140
|
id = declaration.id,
|
package/lib/rules/jsx-quotes.js
CHANGED
@@ -37,7 +37,7 @@ const QUOTE_SETTINGS = {
|
|
37
37
|
// Rule Definition
|
38
38
|
//------------------------------------------------------------------------------
|
39
39
|
|
40
|
-
/** @type {import('../
|
40
|
+
/** @type {import('../types').Rule.RuleModule} */
|
41
41
|
module.exports = {
|
42
42
|
meta: {
|
43
43
|
deprecated: {
|
package/lib/rules/key-spacing.js
CHANGED
@@ -144,7 +144,7 @@ function initOptions(toOptions, fromOptions) {
|
|
144
144
|
// Rule Definition
|
145
145
|
//------------------------------------------------------------------------------
|
146
146
|
|
147
|
-
/** @type {import('../
|
147
|
+
/** @type {import('../types').Rule.RuleModule} */
|
148
148
|
module.exports = {
|
149
149
|
meta: {
|
150
150
|
deprecated: {
|
@@ -489,7 +489,7 @@ module.exports = {
|
|
489
489
|
* @param {ASTNode} property Key-value pair in an object literal.
|
490
490
|
* @param {string} side Side being verified - either "key" or "value".
|
491
491
|
* @param {string} whitespace Actual whitespace string.
|
492
|
-
* @param {
|
492
|
+
* @param {number} expected Expected whitespace length.
|
493
493
|
* @param {string} mode Value of the mode as "strict" or "minimum"
|
494
494
|
* @returns {void}
|
495
495
|
*/
|
@@ -591,7 +591,7 @@ module.exports = {
|
|
591
591
|
* Gets the number of characters in a key, including quotes around string
|
592
592
|
* keys and braces around computed property keys.
|
593
593
|
* @param {ASTNode} property Property of on object literal.
|
594
|
-
* @returns {
|
594
|
+
* @returns {number} Width of the key.
|
595
595
|
*/
|
596
596
|
function getKeyWidth(property) {
|
597
597
|
const startToken = sourceCode.getFirstToken(property);
|
@@ -75,7 +75,7 @@ function isCloseParenOfTemplate(token) {
|
|
75
75
|
// Rule Definition
|
76
76
|
//------------------------------------------------------------------------------
|
77
77
|
|
78
|
-
/** @type {import('../
|
78
|
+
/** @type {import('../types').Rule.RuleModule} */
|
79
79
|
module.exports = {
|
80
80
|
meta: {
|
81
81
|
deprecated: {
|
@@ -11,7 +11,7 @@ const astUtils = require("./utils/ast-utils");
|
|
11
11
|
// Rule Definition
|
12
12
|
//------------------------------------------------------------------------------
|
13
13
|
|
14
|
-
/** @type {import('../
|
14
|
+
/** @type {import('../types').Rule.RuleModule} */
|
15
15
|
module.exports = {
|
16
16
|
meta: {
|
17
17
|
deprecated: {
|
@@ -6,6 +6,14 @@
|
|
6
6
|
|
7
7
|
"use strict";
|
8
8
|
|
9
|
+
//------------------------------------------------------------------------------
|
10
|
+
// Typedefs
|
11
|
+
//------------------------------------------------------------------------------
|
12
|
+
|
13
|
+
/**
|
14
|
+
* @import { SourceRange } from "@eslint/core";
|
15
|
+
*/
|
16
|
+
|
9
17
|
//------------------------------------------------------------------------------
|
10
18
|
// Requirements
|
11
19
|
//------------------------------------------------------------------------------
|
@@ -16,7 +24,7 @@ const astUtils = require("./utils/ast-utils");
|
|
16
24
|
// Rule Definition
|
17
25
|
//------------------------------------------------------------------------------
|
18
26
|
|
19
|
-
/** @type {import('../
|
27
|
+
/** @type {import('../types').Rule.RuleModule} */
|
20
28
|
module.exports = {
|
21
29
|
meta: {
|
22
30
|
deprecated: {
|
@@ -70,7 +78,7 @@ module.exports = {
|
|
70
78
|
|
71
79
|
/**
|
72
80
|
* Builds a fix function that replaces text at the specified range in the source text.
|
73
|
-
* @param {
|
81
|
+
* @param {SourceRange} range The range to replace
|
74
82
|
* @param {string} text The text to insert.
|
75
83
|
* @returns {Function} Fixer function
|
76
84
|
* @private
|
@@ -53,7 +53,7 @@ function getCommentLineNums(comments) {
|
|
53
53
|
// Rule Definition
|
54
54
|
//------------------------------------------------------------------------------
|
55
55
|
|
56
|
-
/** @type {import('../
|
56
|
+
/** @type {import('../types').Rule.RuleModule} */
|
57
57
|
module.exports = {
|
58
58
|
meta: {
|
59
59
|
deprecated: {
|
@@ -12,7 +12,7 @@ const astUtils = require("./utils/ast-utils");
|
|
12
12
|
// Rule Definition
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
|
15
|
-
/** @type {import('../
|
15
|
+
/** @type {import('../types').Rule.RuleModule} */
|
16
16
|
module.exports = {
|
17
17
|
meta: {
|
18
18
|
type: "layout",
|
@@ -30,7 +30,7 @@ const ClassMemberTypes = {
|
|
30
30
|
// Rule Definition
|
31
31
|
//------------------------------------------------------------------------------
|
32
32
|
|
33
|
-
/** @type {import('../
|
33
|
+
/** @type {import('../types').Rule.RuleModule} */
|
34
34
|
module.exports = {
|
35
35
|
meta: {
|
36
36
|
deprecated: {
|
@@ -220,7 +220,7 @@ function getLeftmostOperand(sourceCode, node) {
|
|
220
220
|
//------------------------------------------------------------------------------
|
221
221
|
// Rule Definition
|
222
222
|
//------------------------------------------------------------------------------
|
223
|
-
/** @type {import('../
|
223
|
+
/** @type {import('../types').Rule.RuleModule} */
|
224
224
|
module.exports = {
|
225
225
|
meta: {
|
226
226
|
type: "suggestion",
|
@@ -12,7 +12,7 @@
|
|
12
12
|
// Rule Definition
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
|
15
|
-
/** @type {import('../
|
15
|
+
/** @type {import('../types').Rule.RuleModule} */
|
16
16
|
module.exports = {
|
17
17
|
meta: {
|
18
18
|
type: "suggestion",
|
package/lib/rules/max-depth.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
// Rule Definition
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
/** @type {import('../
|
12
|
+
/** @type {import('../types').Rule.RuleModule} */
|
13
13
|
module.exports = {
|
14
14
|
meta: {
|
15
15
|
type: "suggestion",
|
package/lib/rules/max-len.js
CHANGED
@@ -64,7 +64,7 @@ const OPTIONS_OR_INTEGER_SCHEMA = {
|
|
64
64
|
// Rule Definition
|
65
65
|
//------------------------------------------------------------------------------
|
66
66
|
|
67
|
-
/** @type {import('../
|
67
|
+
/** @type {import('../types').Rule.RuleModule} */
|
68
68
|
module.exports = {
|
69
69
|
meta: {
|
70
70
|
deprecated: {
|
@@ -125,8 +125,8 @@ module.exports = {
|
|
125
125
|
* Computes the length of a line that may contain tabs. The width of each
|
126
126
|
* tab will be the number of spaces to the next tab stop.
|
127
127
|
* @param {string} line The line.
|
128
|
-
* @param {
|
129
|
-
* @returns {
|
128
|
+
* @param {number} tabWidth The width of each tab stop in spaces.
|
129
|
+
* @returns {number} The computed line length.
|
130
130
|
* @private
|
131
131
|
*/
|
132
132
|
function computeLineLength(line, tabWidth) {
|
@@ -65,7 +65,7 @@ function getCommentLineNumbers(comments) {
|
|
65
65
|
// Rule Definition
|
66
66
|
//------------------------------------------------------------------------------
|
67
67
|
|
68
|
-
/** @type {import('../
|
68
|
+
/** @type {import('../types').Rule.RuleModule} */
|
69
69
|
module.exports = {
|
70
70
|
meta: {
|
71
71
|
type: "suggestion",
|
package/lib/rules/max-lines.js
CHANGED
@@ -28,7 +28,7 @@ function range(start, end) {
|
|
28
28
|
// Rule Definition
|
29
29
|
//------------------------------------------------------------------------------
|
30
30
|
|
31
|
-
/** @type {import('../
|
31
|
+
/** @type {import('../types').Rule.RuleModule} */
|
32
32
|
module.exports = {
|
33
33
|
meta: {
|
34
34
|
type: "suggestion",
|
@@ -9,7 +9,7 @@
|
|
9
9
|
// Rule Definition
|
10
10
|
//------------------------------------------------------------------------------
|
11
11
|
|
12
|
-
/** @type {import('../
|
12
|
+
/** @type {import('../types').Rule.RuleModule} */
|
13
13
|
module.exports = {
|
14
14
|
meta: {
|
15
15
|
type: "suggestion",
|
package/lib/rules/max-params.js
CHANGED
@@ -16,7 +16,7 @@ const { upperCaseFirst } = require("../shared/string-utils");
|
|
16
16
|
// Rule Definition
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
|
19
|
-
/** @type {import('../
|
19
|
+
/** @type {import('../types').Rule.RuleModule} */
|
20
20
|
module.exports = {
|
21
21
|
meta: {
|
22
22
|
type: "suggestion",
|
@@ -15,7 +15,7 @@ const astUtils = require("./utils/ast-utils");
|
|
15
15
|
// Rule Definition
|
16
16
|
//------------------------------------------------------------------------------
|
17
17
|
|
18
|
-
/** @type {import('../
|
18
|
+
/** @type {import('../types').Rule.RuleModule} */
|
19
19
|
module.exports = {
|
20
20
|
meta: {
|
21
21
|
deprecated: {
|
@@ -16,7 +16,7 @@ const { upperCaseFirst } = require("../shared/string-utils");
|
|
16
16
|
// Rule Definition
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
|
19
|
-
/** @type {import('../
|
19
|
+
/** @type {import('../types').Rule.RuleModule} */
|
20
20
|
module.exports = {
|
21
21
|
meta: {
|
22
22
|
type: "suggestion",
|
@@ -92,8 +92,8 @@ module.exports = {
|
|
92
92
|
/**
|
93
93
|
* Reports a node if it has too many statements
|
94
94
|
* @param {ASTNode} node node to evaluate
|
95
|
-
* @param {
|
96
|
-
* @param {
|
95
|
+
* @param {number} count Number of statements in node
|
96
|
+
* @param {number} max Maximum number of statements allowed
|
97
97
|
* @returns {void}
|
98
98
|
* @private
|
99
99
|
*/
|
@@ -11,7 +11,7 @@ const astUtils = require("./utils/ast-utils");
|
|
11
11
|
// Rule Definition
|
12
12
|
//------------------------------------------------------------------------------
|
13
13
|
|
14
|
-
/** @type {import('../
|
14
|
+
/** @type {import('../types').Rule.RuleModule} */
|
15
15
|
module.exports = {
|
16
16
|
meta: {
|
17
17
|
deprecated: {
|
@@ -12,7 +12,7 @@ const astUtils = require("./utils/ast-utils");
|
|
12
12
|
// Rule Definition
|
13
13
|
//------------------------------------------------------------------------------
|
14
14
|
|
15
|
-
/** @type {import('../
|
15
|
+
/** @type {import('../types').Rule.RuleModule} */
|
16
16
|
module.exports = {
|
17
17
|
meta: {
|
18
18
|
deprecated: {
|