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
@@ -511,8 +511,8 @@ class SourceCode extends TokenStore {
|
|
511
511
|
/**
|
512
512
|
* Gets the source code for the given node.
|
513
513
|
* @param {ASTNode} [node] The AST node to get the text for.
|
514
|
-
* @param {
|
515
|
-
* @param {
|
514
|
+
* @param {number} [beforeCount] The number of characters before the node to retrieve.
|
515
|
+
* @param {number} [afterCount] The number of characters after the node to retrieve.
|
516
516
|
* @returns {string} The text representing the AST node.
|
517
517
|
* @public
|
518
518
|
*/
|
@@ -627,7 +627,7 @@ class SourceCode extends TokenStore {
|
|
627
627
|
|
628
628
|
/**
|
629
629
|
* Gets the deepest node containing a range index.
|
630
|
-
* @param {
|
630
|
+
* @param {number} index Range index of the desired node.
|
631
631
|
* @returns {ASTNode} The node if found or null if not found.
|
632
632
|
* @public
|
633
633
|
*/
|
@@ -605,8 +605,8 @@ module.exports = class TokenStore {
|
|
605
605
|
/**
|
606
606
|
* Gets all tokens that are related to the given node.
|
607
607
|
* @param {ASTNode} node The AST node.
|
608
|
-
* @param {
|
609
|
-
* @param {
|
608
|
+
* @param {number} [beforeCount=0] The number of tokens before the node to retrieve.
|
609
|
+
* @param {number} [afterCount=0] The number of tokens after the node to retrieve.
|
610
610
|
* @returns {Token[]} Array of objects representing tokens.
|
611
611
|
*/
|
612
612
|
getTokens(node, beforeCount, afterCount) {
|
@@ -635,7 +635,7 @@ module.exports = class TokenStore {
|
|
635
635
|
* Gets all of the tokens between two non-overlapping nodes.
|
636
636
|
* @param {ASTNode|Token|Comment} left Node before the desired token range.
|
637
637
|
* @param {ASTNode|Token|Comment} right Node after the desired token range.
|
638
|
-
* @param {
|
638
|
+
* @param {number} [padding=0] Number of extra tokens on either side of center.
|
639
639
|
* @returns {Token[]} Tokens between left and right.
|
640
640
|
*/
|
641
641
|
getTokensBetween(left, right, padding) {
|
@@ -335,7 +335,7 @@ class ForLoopContext extends LoopContextBase {
|
|
335
335
|
this.updateSegments = null;
|
336
336
|
|
337
337
|
/**
|
338
|
-
* The end of the update
|
338
|
+
* The end of the update expression. This may change during the lifetime
|
339
339
|
* of the instance as we traverse the loop because some loops don't have
|
340
340
|
* an update expression.
|
341
341
|
* @type {Array<CodePathSegment>|null}
|
package/lib/linter/linter.js
CHANGED
@@ -81,7 +81,7 @@ const STEP_KIND_CALL = 2;
|
|
81
81
|
/** @typedef {import("../shared/types").ParserOptions} ParserOptions */
|
82
82
|
/** @typedef {import("../shared/types").LanguageOptions} LanguageOptions */
|
83
83
|
/** @typedef {import("../shared/types").Processor} Processor */
|
84
|
-
/** @typedef {import("../
|
84
|
+
/** @typedef {import("../types").Rule.RuleModule} Rule */
|
85
85
|
/** @typedef {import("../shared/types").Times} Times */
|
86
86
|
/** @typedef {import("@eslint/core").Language} Language */
|
87
87
|
/** @typedef {import("@eslint/core").RuleSeverity} RuleSeverity */
|
@@ -346,11 +346,13 @@ class NodeEventGenerator {
|
|
346
346
|
* @returns {void}
|
347
347
|
*/
|
348
348
|
applySelectors(node, isExit) {
|
349
|
+
const nodeTypeKey = this.esqueryOptions?.nodeTypeKey || "type";
|
350
|
+
|
349
351
|
const selectorsByNodeType =
|
350
352
|
(isExit
|
351
353
|
? this.exitSelectorsByNodeType
|
352
354
|
: this.enterSelectorsByNodeType
|
353
|
-
).get(node
|
355
|
+
).get(node[nodeTypeKey]) || [];
|
354
356
|
const anyTypeSelectors = isExit
|
355
357
|
? this.anyTypeExitSelectors
|
356
358
|
: this.anyTypeEnterSelectors;
|
@@ -133,7 +133,7 @@ function assertValidFix(fix) {
|
|
133
133
|
* Compares items in a fixes array by range.
|
134
134
|
* @param {Fix} a The first message.
|
135
135
|
* @param {Fix} b The second message.
|
136
|
-
* @returns {
|
136
|
+
* @returns {number} -1 if a comes before b, 1 if a comes after b, 0 if equal.
|
137
137
|
* @private
|
138
138
|
*/
|
139
139
|
function compareFixesByRange(a, b) {
|
package/lib/linter/rule-fixer.js
CHANGED
@@ -4,6 +4,14 @@
|
|
4
4
|
*/
|
5
5
|
"use strict";
|
6
6
|
|
7
|
+
//------------------------------------------------------------------------------
|
8
|
+
// Typedefs
|
9
|
+
//------------------------------------------------------------------------------
|
10
|
+
|
11
|
+
/**
|
12
|
+
* @import { SourceRange } from "@eslint/core";
|
13
|
+
*/
|
14
|
+
|
7
15
|
/* eslint class-methods-use-this: off -- Methods desired on instance */
|
8
16
|
|
9
17
|
//------------------------------------------------------------------------------
|
@@ -18,7 +26,7 @@
|
|
18
26
|
|
19
27
|
/**
|
20
28
|
* Creates a fix command that inserts text at the specified index in the source text.
|
21
|
-
* @param {
|
29
|
+
* @param {number} index The 0-based index at which to insert the new text.
|
22
30
|
* @param {string} text The text to insert.
|
23
31
|
* @returns {Object} The fix command.
|
24
32
|
* @private
|
@@ -69,7 +77,7 @@ class RuleFixer {
|
|
69
77
|
/**
|
70
78
|
* Creates a fix command that inserts text after the specified range in the source text.
|
71
79
|
* The fix is not applied until applyFixes() is called.
|
72
|
-
* @param {
|
80
|
+
* @param {SourceRange} range The range to replace, first item is start of range, second
|
73
81
|
* is end of range.
|
74
82
|
* @param {string} text The text to insert.
|
75
83
|
* @returns {Object} The fix command.
|
@@ -94,7 +102,7 @@ class RuleFixer {
|
|
94
102
|
/**
|
95
103
|
* Creates a fix command that inserts text before the specified range in the source text.
|
96
104
|
* The fix is not applied until applyFixes() is called.
|
97
|
-
* @param {
|
105
|
+
* @param {SourceRange} range The range to replace, first item is start of range, second
|
98
106
|
* is end of range.
|
99
107
|
* @param {string} text The text to insert.
|
100
108
|
* @returns {Object} The fix command.
|
@@ -119,7 +127,7 @@ class RuleFixer {
|
|
119
127
|
/**
|
120
128
|
* Creates a fix command that replaces text at the specified range in the source text.
|
121
129
|
* The fix is not applied until applyFixes() is called.
|
122
|
-
* @param {
|
130
|
+
* @param {SourceRange} range The range to replace, first item is start of range, second
|
123
131
|
* is end of range.
|
124
132
|
* @param {string} text The text to insert.
|
125
133
|
* @returns {Object} The fix command.
|
@@ -146,7 +154,7 @@ class RuleFixer {
|
|
146
154
|
/**
|
147
155
|
* Creates a fix command that removes the specified range of text from the source.
|
148
156
|
* The fix is not applied until applyFixes() is called.
|
149
|
-
* @param {
|
157
|
+
* @param {SourceRange} range The range to remove, first item is start of range, second
|
150
158
|
* is end of range.
|
151
159
|
* @returns {Object} The fix command.
|
152
160
|
*/
|
package/lib/linter/rules.js
CHANGED
@@ -16,7 +16,7 @@ const builtInRules = require("../rules");
|
|
16
16
|
// Typedefs
|
17
17
|
//------------------------------------------------------------------------------
|
18
18
|
|
19
|
-
/** @typedef {import("../
|
19
|
+
/** @typedef {import("../types").Rule.RuleModule} Rule */
|
20
20
|
|
21
21
|
//------------------------------------------------------------------------------
|
22
22
|
// Public Interface
|
@@ -20,7 +20,7 @@ const BOM = "\uFEFF";
|
|
20
20
|
* Compares items in a messages array by range.
|
21
21
|
* @param {Message} a The first message.
|
22
22
|
* @param {Message} b The second message.
|
23
|
-
* @returns {
|
23
|
+
* @returns {number} -1 if a comes before b, 1 if a comes after b, 0 if equal.
|
24
24
|
* @private
|
25
25
|
*/
|
26
26
|
function compareMessagesByFixRange(a, b) {
|
@@ -31,7 +31,7 @@ function compareMessagesByFixRange(a, b) {
|
|
31
31
|
* Compares items in a messages array by line and column.
|
32
32
|
* @param {Message} a The first message.
|
33
33
|
* @param {Message} b The second message.
|
34
|
-
* @returns {
|
34
|
+
* @returns {number} -1 if a comes before b, 1 if a comes after b, 0 if equal.
|
35
35
|
* @private
|
36
36
|
*/
|
37
37
|
function compareMessagesByLocation(a, b) {
|
package/lib/linter/timing.js
CHANGED
@@ -15,7 +15,7 @@ const { startTime, endTime } = require("../shared/stats");
|
|
15
15
|
/**
|
16
16
|
* Align the string to left
|
17
17
|
* @param {string} str string to evaluate
|
18
|
-
* @param {
|
18
|
+
* @param {number} len length of the string
|
19
19
|
* @param {string} ch delimiter character
|
20
20
|
* @returns {string} modified string
|
21
21
|
* @private
|
@@ -28,7 +28,7 @@ function alignLeft(str, len, ch) {
|
|
28
28
|
/**
|
29
29
|
* Align the string to right
|
30
30
|
* @param {string} str string to evaluate
|
31
|
-
* @param {
|
31
|
+
* @param {number} len length of the string
|
32
32
|
* @param {string} ch delimiter character
|
33
33
|
* @returns {string} modified string
|
34
34
|
* @private
|
package/lib/options.js
CHANGED
@@ -62,6 +62,10 @@ const optionator = require("optionator");
|
|
62
62
|
* the linting operation to short circuit and not report any failures.
|
63
63
|
* @property {string[]} _ Positional filenames or patterns
|
64
64
|
* @property {boolean} [stats] Report additional statistics
|
65
|
+
* @property {boolean} [suppressAll] Suppress all error violations
|
66
|
+
* @property {string[]} [suppressRule] Suppress specific rules
|
67
|
+
* @property {string} [suppressionsLocation] Path to the suppressions file or directory
|
68
|
+
* @property {boolean} [pruneSuppressions] Prune unused suppressions
|
65
69
|
*/
|
66
70
|
|
67
71
|
//------------------------------------------------------------------------------
|
@@ -410,6 +414,31 @@ module.exports = function (usingFlatConfig) {
|
|
410
414
|
description:
|
411
415
|
"Strategy to use for detecting changed files in the cache",
|
412
416
|
},
|
417
|
+
{
|
418
|
+
heading: "Suppressing Violations",
|
419
|
+
},
|
420
|
+
{
|
421
|
+
option: "suppress-all",
|
422
|
+
type: "Boolean",
|
423
|
+
default: "false",
|
424
|
+
description: "Suppress all violations",
|
425
|
+
},
|
426
|
+
{
|
427
|
+
option: "suppress-rule",
|
428
|
+
type: "[String]",
|
429
|
+
description: "Suppress specific rules",
|
430
|
+
},
|
431
|
+
{
|
432
|
+
option: "suppressions-location",
|
433
|
+
type: "path::String",
|
434
|
+
description: "Specify the location of the suppressions file",
|
435
|
+
},
|
436
|
+
{
|
437
|
+
option: "prune-suppressions",
|
438
|
+
type: "Boolean",
|
439
|
+
default: "false",
|
440
|
+
description: "Prune unused suppressions",
|
441
|
+
},
|
413
442
|
{
|
414
443
|
heading: "Miscellaneous",
|
415
444
|
},
|
@@ -41,7 +41,7 @@ const { SourceCode } = require("../languages/js/source-code");
|
|
41
41
|
|
42
42
|
/** @typedef {import("../shared/types").Parser} Parser */
|
43
43
|
/** @typedef {import("../shared/types").LanguageOptions} LanguageOptions */
|
44
|
-
/** @typedef {import("../
|
44
|
+
/** @typedef {import("../types").Rule.RuleModule} Rule */
|
45
45
|
|
46
46
|
/**
|
47
47
|
* A test case that is expected to pass lint.
|
@@ -141,7 +141,7 @@ function isPropertyDescriptor(node) {
|
|
141
141
|
// Rule Definition
|
142
142
|
//------------------------------------------------------------------------------
|
143
143
|
|
144
|
-
/** @type {import('../
|
144
|
+
/** @type {import('../types').Rule.RuleModule} */
|
145
145
|
module.exports = {
|
146
146
|
meta: {
|
147
147
|
type: "suggestion",
|
@@ -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: {
|
@@ -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: {
|
@@ -213,7 +213,7 @@ function curlyWrapFixer(sourceCode, node, fixer) {
|
|
213
213
|
// Rule Definition
|
214
214
|
//------------------------------------------------------------------------------
|
215
215
|
|
216
|
-
/** @type {import('../
|
216
|
+
/** @type {import('../types').Rule.RuleModule} */
|
217
217
|
module.exports = {
|
218
218
|
meta: {
|
219
219
|
type: "problem",
|
@@ -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: {
|
@@ -14,7 +14,7 @@ const astUtils = require("./utils/ast-utils");
|
|
14
14
|
// Rule Definition
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
|
17
|
-
/** @type {import('../
|
17
|
+
/** @type {import('../types').Rule.RuleModule} */
|
18
18
|
module.exports = {
|
19
19
|
meta: {
|
20
20
|
type: "suggestion",
|
@@ -28,7 +28,7 @@ function hasBlockBody(node) {
|
|
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
|
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: {
|
@@ -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",
|
@@ -12,7 +12,7 @@ const util = 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: {
|
package/lib/rules/brace-style.js
CHANGED
@@ -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: {
|
package/lib/rules/camelcase.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",
|
@@ -99,7 +99,7 @@ function createRegExpForIgnorePatterns(normalizedOptions) {
|
|
99
99
|
// Rule Definition
|
100
100
|
//------------------------------------------------------------------------------
|
101
101
|
|
102
|
-
/** @type {import('../
|
102
|
+
/** @type {import('../types').Rule.RuleModule} */
|
103
103
|
module.exports = {
|
104
104
|
meta: {
|
105
105
|
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
|
dialects: ["javascript", "typescript"],
|
@@ -26,6 +26,7 @@ module.exports = {
|
|
26
26
|
{
|
27
27
|
enforceForClassFields: true,
|
28
28
|
exceptMethods: [],
|
29
|
+
ignoreOverrideMethods: false,
|
29
30
|
},
|
30
31
|
],
|
31
32
|
|
@@ -48,6 +49,12 @@ module.exports = {
|
|
48
49
|
enforceForClassFields: {
|
49
50
|
type: "boolean",
|
50
51
|
},
|
52
|
+
ignoreOverrideMethods: {
|
53
|
+
type: "boolean",
|
54
|
+
},
|
55
|
+
ignoreClassesWithImplements: {
|
56
|
+
enum: ["all", "public-fields"],
|
57
|
+
},
|
51
58
|
},
|
52
59
|
additionalProperties: false,
|
53
60
|
},
|
@@ -59,7 +66,11 @@ module.exports = {
|
|
59
66
|
},
|
60
67
|
create(context) {
|
61
68
|
const [options] = context.options;
|
62
|
-
const {
|
69
|
+
const {
|
70
|
+
enforceForClassFields,
|
71
|
+
ignoreOverrideMethods,
|
72
|
+
ignoreClassesWithImplements,
|
73
|
+
} = options;
|
63
74
|
const exceptMethods = new Set(options.exceptMethods);
|
64
75
|
|
65
76
|
const stack = [];
|
@@ -107,6 +118,20 @@ module.exports = {
|
|
107
118
|
}
|
108
119
|
}
|
109
120
|
|
121
|
+
/**
|
122
|
+
* Check if the node's parent class implements any interfaces
|
123
|
+
* @param {ASTNode} node node to check
|
124
|
+
* @returns {boolean} True if parent class implements interfaces
|
125
|
+
* @private
|
126
|
+
*/
|
127
|
+
function hasImplements(node) {
|
128
|
+
const classNode = node.parent.parent;
|
129
|
+
return (
|
130
|
+
classNode?.type === "ClassDeclaration" &&
|
131
|
+
classNode.implements?.length > 0
|
132
|
+
);
|
133
|
+
}
|
134
|
+
|
110
135
|
/**
|
111
136
|
* Check if the node is an instance method not excluded by config
|
112
137
|
* @param {ASTNode} node node to check
|
@@ -119,6 +144,25 @@ module.exports = {
|
|
119
144
|
return true;
|
120
145
|
}
|
121
146
|
|
147
|
+
if (ignoreOverrideMethods && node.override) {
|
148
|
+
return false;
|
149
|
+
}
|
150
|
+
|
151
|
+
if (ignoreClassesWithImplements) {
|
152
|
+
const implementsInterfaces = hasImplements(node);
|
153
|
+
if (implementsInterfaces) {
|
154
|
+
if (
|
155
|
+
ignoreClassesWithImplements === "all" ||
|
156
|
+
(ignoreClassesWithImplements === "public-fields" &&
|
157
|
+
node.key.type !== "PrivateIdentifier" &&
|
158
|
+
(!node.accessibility ||
|
159
|
+
node.accessibility === "public"))
|
160
|
+
) {
|
161
|
+
return false;
|
162
|
+
}
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
122
166
|
const hashIfNeeded =
|
123
167
|
node.key.type === "PrivateIdentifier" ? "#" : "";
|
124
168
|
const name =
|
@@ -71,7 +71,7 @@ function normalizeOptions(optionValue, ecmaVersion) {
|
|
71
71
|
// Rule Definition
|
72
72
|
//------------------------------------------------------------------------------
|
73
73
|
|
74
|
-
/** @type {import('../
|
74
|
+
/** @type {import('../types').Rule.RuleModule} */
|
75
75
|
module.exports = {
|
76
76
|
meta: {
|
77
77
|
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: {
|
package/lib/rules/comma-style.js
CHANGED
@@ -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: {
|
package/lib/rules/complexity.js
CHANGED
@@ -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: {
|
@@ -48,7 +48,7 @@ function isClassConstructor(node) {
|
|
48
48
|
// Rule Definition
|
49
49
|
//------------------------------------------------------------------------------
|
50
50
|
|
51
|
-
/** @type {import('../
|
51
|
+
/** @type {import('../types').Rule.RuleModule} */
|
52
52
|
module.exports = {
|
53
53
|
meta: {
|
54
54
|
type: "suggestion",
|
@@ -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",
|
@@ -129,7 +129,7 @@ class SegmentInfo {
|
|
129
129
|
// Rule Definition
|
130
130
|
//------------------------------------------------------------------------------
|
131
131
|
|
132
|
-
/** @type {import('../
|
132
|
+
/** @type {import('../types').Rule.RuleModule} */
|
133
133
|
module.exports = {
|
134
134
|
meta: {
|
135
135
|
type: "problem",
|
package/lib/rules/curly.js
CHANGED
@@ -14,7 +14,7 @@ const astUtils = require("./utils/ast-utils");
|
|
14
14
|
// Rule Definition
|
15
15
|
//------------------------------------------------------------------------------
|
16
16
|
|
17
|
-
/** @type {import('../
|
17
|
+
/** @type {import('../types').Rule.RuleModule} */
|
18
18
|
module.exports = {
|
19
19
|
meta: {
|
20
20
|
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 @@ const DEFAULT_COMMENT_PATTERN = /^no default$/iu;
|
|
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
|
type: "suggestion",
|
@@ -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: {
|
@@ -20,7 +20,7 @@ const validIdentifier = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/u;
|
|
20
20
|
// `null` literal must be handled separately.
|
21
21
|
const literalTypesToCheck = new Set(["string", "boolean"]);
|
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/eol-last.js
CHANGED
package/lib/rules/eqeqeq.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",
|