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.
Files changed (320) hide show
  1. package/README.md +3 -2
  2. package/lib/cli-engine/cli-engine.js +2 -2
  3. package/lib/cli-engine/formatters/html.js +3 -3
  4. package/lib/cli-engine/formatters/stylish.js +1 -1
  5. package/lib/cli.js +98 -1
  6. package/lib/config/config-loader.js +108 -34
  7. package/lib/config/flat-config-helpers.js +7 -4
  8. package/lib/eslint/eslint-helpers.js +50 -5
  9. package/lib/eslint/eslint.js +17 -53
  10. package/lib/eslint/legacy-eslint.js +1 -1
  11. package/lib/languages/js/source-code/source-code.js +3 -3
  12. package/lib/languages/js/source-code/token-store/index.js +3 -3
  13. package/lib/linter/code-path-analysis/code-path-state.js +1 -1
  14. package/lib/linter/linter.js +1 -1
  15. package/lib/linter/node-event-generator.js +3 -1
  16. package/lib/linter/report-translator.js +1 -1
  17. package/lib/linter/rule-fixer.js +13 -5
  18. package/lib/linter/rules.js +1 -1
  19. package/lib/linter/source-code-fixer.js +2 -2
  20. package/lib/linter/timing.js +2 -2
  21. package/lib/options.js +29 -0
  22. package/lib/rule-tester/rule-tester.js +1 -1
  23. package/lib/rules/accessor-pairs.js +1 -1
  24. package/lib/rules/array-bracket-newline.js +1 -1
  25. package/lib/rules/array-bracket-spacing.js +1 -1
  26. package/lib/rules/array-callback-return.js +1 -1
  27. package/lib/rules/array-element-newline.js +1 -1
  28. package/lib/rules/arrow-body-style.js +1 -1
  29. package/lib/rules/arrow-parens.js +1 -1
  30. package/lib/rules/arrow-spacing.js +1 -1
  31. package/lib/rules/block-scoped-var.js +1 -1
  32. package/lib/rules/block-spacing.js +1 -1
  33. package/lib/rules/brace-style.js +1 -1
  34. package/lib/rules/callback-return.js +1 -1
  35. package/lib/rules/camelcase.js +1 -1
  36. package/lib/rules/capitalized-comments.js +1 -1
  37. package/lib/rules/class-methods-use-this.js +46 -2
  38. package/lib/rules/comma-dangle.js +1 -1
  39. package/lib/rules/comma-spacing.js +1 -1
  40. package/lib/rules/comma-style.js +1 -1
  41. package/lib/rules/complexity.js +1 -1
  42. package/lib/rules/computed-property-spacing.js +1 -1
  43. package/lib/rules/consistent-return.js +1 -1
  44. package/lib/rules/consistent-this.js +1 -1
  45. package/lib/rules/constructor-super.js +1 -1
  46. package/lib/rules/curly.js +1 -1
  47. package/lib/rules/default-case-last.js +1 -1
  48. package/lib/rules/default-case.js +1 -1
  49. package/lib/rules/default-param-last.js +1 -1
  50. package/lib/rules/dot-location.js +1 -1
  51. package/lib/rules/dot-notation.js +1 -1
  52. package/lib/rules/eol-last.js +1 -1
  53. package/lib/rules/eqeqeq.js +1 -1
  54. package/lib/rules/for-direction.js +5 -5
  55. package/lib/rules/func-call-spacing.js +1 -1
  56. package/lib/rules/func-name-matching.js +2 -2
  57. package/lib/rules/func-names.js +1 -1
  58. package/lib/rules/func-style.js +1 -1
  59. package/lib/rules/function-call-argument-newline.js +1 -1
  60. package/lib/rules/function-paren-newline.js +1 -1
  61. package/lib/rules/generator-star-spacing.js +1 -1
  62. package/lib/rules/getter-return.js +1 -1
  63. package/lib/rules/global-require.js +1 -1
  64. package/lib/rules/grouped-accessor-pairs.js +1 -1
  65. package/lib/rules/guard-for-in.js +1 -1
  66. package/lib/rules/handle-callback-err.js +1 -1
  67. package/lib/rules/id-blacklist.js +1 -1
  68. package/lib/rules/id-denylist.js +1 -1
  69. package/lib/rules/id-length.js +1 -1
  70. package/lib/rules/id-match.js +1 -1
  71. package/lib/rules/implicit-arrow-linebreak.js +1 -1
  72. package/lib/rules/indent-legacy.js +14 -14
  73. package/lib/rules/indent.js +4 -4
  74. package/lib/rules/init-declarations.js +22 -1
  75. package/lib/rules/jsx-quotes.js +1 -1
  76. package/lib/rules/key-spacing.js +3 -3
  77. package/lib/rules/keyword-spacing.js +1 -1
  78. package/lib/rules/line-comment-position.js +1 -1
  79. package/lib/rules/linebreak-style.js +10 -2
  80. package/lib/rules/lines-around-comment.js +1 -1
  81. package/lib/rules/lines-around-directive.js +1 -1
  82. package/lib/rules/lines-between-class-members.js +1 -1
  83. package/lib/rules/logical-assignment-operators.js +1 -1
  84. package/lib/rules/max-classes-per-file.js +1 -1
  85. package/lib/rules/max-depth.js +1 -1
  86. package/lib/rules/max-len.js +3 -3
  87. package/lib/rules/max-lines-per-function.js +1 -1
  88. package/lib/rules/max-lines.js +1 -1
  89. package/lib/rules/max-nested-callbacks.js +1 -1
  90. package/lib/rules/max-params.js +1 -1
  91. package/lib/rules/max-statements-per-line.js +1 -1
  92. package/lib/rules/max-statements.js +3 -3
  93. package/lib/rules/multiline-comment-style.js +1 -1
  94. package/lib/rules/multiline-ternary.js +1 -1
  95. package/lib/rules/new-cap.js +1 -1
  96. package/lib/rules/new-parens.js +1 -1
  97. package/lib/rules/newline-after-var.js +1 -1
  98. package/lib/rules/newline-before-return.js +1 -1
  99. package/lib/rules/newline-per-chained-call.js +1 -1
  100. package/lib/rules/no-alert.js +1 -1
  101. package/lib/rules/no-array-constructor.js +4 -1
  102. package/lib/rules/no-async-promise-executor.js +1 -1
  103. package/lib/rules/no-await-in-loop.js +1 -1
  104. package/lib/rules/no-bitwise.js +1 -1
  105. package/lib/rules/no-buffer-constructor.js +1 -1
  106. package/lib/rules/no-caller.js +1 -1
  107. package/lib/rules/no-case-declarations.js +1 -1
  108. package/lib/rules/no-catch-shadow.js +1 -1
  109. package/lib/rules/no-class-assign.js +1 -1
  110. package/lib/rules/no-compare-neg-zero.js +1 -1
  111. package/lib/rules/no-cond-assign.js +1 -1
  112. package/lib/rules/no-confusing-arrow.js +1 -1
  113. package/lib/rules/no-console.js +1 -1
  114. package/lib/rules/no-const-assign.js +1 -1
  115. package/lib/rules/no-constant-binary-expression.js +2 -2
  116. package/lib/rules/no-constant-condition.js +1 -1
  117. package/lib/rules/no-constructor-return.js +1 -1
  118. package/lib/rules/no-continue.js +1 -1
  119. package/lib/rules/no-control-regex.js +1 -1
  120. package/lib/rules/no-debugger.js +1 -1
  121. package/lib/rules/no-delete-var.js +1 -1
  122. package/lib/rules/no-div-regex.js +1 -1
  123. package/lib/rules/no-dupe-args.js +1 -1
  124. package/lib/rules/no-dupe-class-members.js +10 -1
  125. package/lib/rules/no-dupe-else-if.js +1 -1
  126. package/lib/rules/no-dupe-keys.js +1 -1
  127. package/lib/rules/no-duplicate-case.js +1 -1
  128. package/lib/rules/no-duplicate-imports.js +1 -1
  129. package/lib/rules/no-else-return.js +1 -1
  130. package/lib/rules/no-empty-character-class.js +1 -1
  131. package/lib/rules/no-empty-function.js +54 -3
  132. package/lib/rules/no-empty-pattern.js +1 -1
  133. package/lib/rules/no-empty-static-block.js +1 -1
  134. package/lib/rules/no-empty.js +1 -1
  135. package/lib/rules/no-eq-null.js +1 -1
  136. package/lib/rules/no-eval.js +1 -1
  137. package/lib/rules/no-ex-assign.js +1 -1
  138. package/lib/rules/no-extend-native.js +1 -1
  139. package/lib/rules/no-extra-bind.js +1 -1
  140. package/lib/rules/no-extra-boolean-cast.js +1 -1
  141. package/lib/rules/no-extra-label.js +1 -1
  142. package/lib/rules/no-extra-parens.js +1 -1
  143. package/lib/rules/no-extra-semi.js +1 -1
  144. package/lib/rules/no-fallthrough.js +1 -1
  145. package/lib/rules/no-floating-decimal.js +1 -1
  146. package/lib/rules/no-func-assign.js +1 -1
  147. package/lib/rules/no-global-assign.js +2 -2
  148. package/lib/rules/no-implicit-coercion.js +1 -1
  149. package/lib/rules/no-implicit-globals.js +1 -1
  150. package/lib/rules/no-implied-eval.js +1 -1
  151. package/lib/rules/no-import-assign.js +1 -1
  152. package/lib/rules/no-inline-comments.js +1 -1
  153. package/lib/rules/no-inner-declarations.js +1 -1
  154. package/lib/rules/no-invalid-regexp.js +1 -1
  155. package/lib/rules/no-invalid-this.js +23 -1
  156. package/lib/rules/no-irregular-whitespace.js +1 -1
  157. package/lib/rules/no-iterator.js +1 -1
  158. package/lib/rules/no-label-var.js +1 -1
  159. package/lib/rules/no-labels.js +1 -1
  160. package/lib/rules/no-lone-blocks.js +1 -1
  161. package/lib/rules/no-lonely-if.js +1 -1
  162. package/lib/rules/no-loop-func.js +10 -4
  163. package/lib/rules/no-loss-of-precision.js +3 -1
  164. package/lib/rules/no-magic-numbers.js +1 -1
  165. package/lib/rules/no-misleading-character-class.js +1 -1
  166. package/lib/rules/no-mixed-operators.js +1 -1
  167. package/lib/rules/no-mixed-requires.js +1 -1
  168. package/lib/rules/no-mixed-spaces-and-tabs.js +1 -1
  169. package/lib/rules/no-multi-assign.js +1 -1
  170. package/lib/rules/no-multi-spaces.js +1 -1
  171. package/lib/rules/no-multi-str.js +1 -1
  172. package/lib/rules/no-multiple-empty-lines.js +1 -1
  173. package/lib/rules/no-native-reassign.js +2 -2
  174. package/lib/rules/no-negated-condition.js +1 -1
  175. package/lib/rules/no-negated-in-lhs.js +1 -1
  176. package/lib/rules/no-nested-ternary.js +1 -1
  177. package/lib/rules/no-new-func.js +1 -1
  178. package/lib/rules/no-new-native-nonconstructor.js +1 -1
  179. package/lib/rules/no-new-object.js +1 -1
  180. package/lib/rules/no-new-require.js +1 -1
  181. package/lib/rules/no-new-symbol.js +1 -1
  182. package/lib/rules/no-new-wrappers.js +1 -1
  183. package/lib/rules/no-new.js +1 -1
  184. package/lib/rules/no-nonoctal-decimal-escape.js +10 -2
  185. package/lib/rules/no-obj-calls.js +1 -1
  186. package/lib/rules/no-object-constructor.js +1 -1
  187. package/lib/rules/no-octal-escape.js +1 -1
  188. package/lib/rules/no-octal.js +1 -1
  189. package/lib/rules/no-param-reassign.js +2 -2
  190. package/lib/rules/no-path-concat.js +1 -1
  191. package/lib/rules/no-plusplus.js +1 -1
  192. package/lib/rules/no-process-env.js +1 -1
  193. package/lib/rules/no-process-exit.js +1 -1
  194. package/lib/rules/no-promise-executor-return.js +1 -1
  195. package/lib/rules/no-proto.js +1 -1
  196. package/lib/rules/no-prototype-builtins.js +1 -1
  197. package/lib/rules/no-redeclare.js +1 -1
  198. package/lib/rules/no-regex-spaces.js +1 -1
  199. package/lib/rules/no-restricted-exports.js +1 -1
  200. package/lib/rules/no-restricted-globals.js +1 -1
  201. package/lib/rules/no-restricted-imports.js +1 -1
  202. package/lib/rules/no-restricted-modules.js +1 -1
  203. package/lib/rules/no-restricted-properties.js +43 -29
  204. package/lib/rules/no-restricted-syntax.js +1 -1
  205. package/lib/rules/no-return-assign.js +1 -1
  206. package/lib/rules/no-return-await.js +1 -2
  207. package/lib/rules/no-script-url.js +1 -1
  208. package/lib/rules/no-self-assign.js +1 -1
  209. package/lib/rules/no-self-compare.js +1 -1
  210. package/lib/rules/no-sequences.js +1 -1
  211. package/lib/rules/no-setter-return.js +1 -1
  212. package/lib/rules/no-shadow-restricted-names.js +1 -1
  213. package/lib/rules/no-shadow.js +1 -1
  214. package/lib/rules/no-spaced-func.js +1 -1
  215. package/lib/rules/no-sparse-arrays.js +1 -1
  216. package/lib/rules/no-sync.js +1 -1
  217. package/lib/rules/no-tabs.js +1 -1
  218. package/lib/rules/no-template-curly-in-string.js +1 -1
  219. package/lib/rules/no-ternary.js +1 -1
  220. package/lib/rules/no-this-before-super.js +1 -1
  221. package/lib/rules/no-throw-literal.js +1 -1
  222. package/lib/rules/no-trailing-spaces.js +11 -3
  223. package/lib/rules/no-undef-init.js +1 -1
  224. package/lib/rules/no-undef.js +1 -1
  225. package/lib/rules/no-undefined.js +1 -1
  226. package/lib/rules/no-underscore-dangle.js +1 -1
  227. package/lib/rules/no-unexpected-multiline.js +1 -1
  228. package/lib/rules/no-unmodified-loop-condition.js +1 -1
  229. package/lib/rules/no-unneeded-ternary.js +1 -1
  230. package/lib/rules/no-unreachable-loop.js +1 -1
  231. package/lib/rules/no-unreachable.js +1 -1
  232. package/lib/rules/no-unsafe-finally.js +1 -1
  233. package/lib/rules/no-unsafe-negation.js +1 -1
  234. package/lib/rules/no-unsafe-optional-chaining.js +1 -1
  235. package/lib/rules/no-unused-expressions.js +15 -57
  236. package/lib/rules/no-unused-labels.js +1 -1
  237. package/lib/rules/no-unused-private-class-members.js +1 -1
  238. package/lib/rules/no-unused-vars.js +3 -3
  239. package/lib/rules/no-use-before-define.js +1 -1
  240. package/lib/rules/no-useless-assignment.js +1 -1
  241. package/lib/rules/no-useless-backreference.js +1 -1
  242. package/lib/rules/no-useless-call.js +1 -1
  243. package/lib/rules/no-useless-catch.js +1 -1
  244. package/lib/rules/no-useless-computed-key.js +1 -1
  245. package/lib/rules/no-useless-concat.js +1 -1
  246. package/lib/rules/no-useless-constructor.js +1 -1
  247. package/lib/rules/no-useless-escape.js +1 -1
  248. package/lib/rules/no-useless-rename.js +1 -1
  249. package/lib/rules/no-useless-return.js +1 -1
  250. package/lib/rules/no-var.js +1 -1
  251. package/lib/rules/no-void.js +1 -1
  252. package/lib/rules/no-warning-comments.js +1 -1
  253. package/lib/rules/no-whitespace-before-property.js +1 -1
  254. package/lib/rules/no-with.js +1 -1
  255. package/lib/rules/nonblock-statement-body-position.js +1 -1
  256. package/lib/rules/object-curly-newline.js +1 -1
  257. package/lib/rules/object-curly-spacing.js +1 -1
  258. package/lib/rules/object-property-newline.js +1 -1
  259. package/lib/rules/object-shorthand.js +1 -1
  260. package/lib/rules/one-var-declaration-per-line.js +1 -1
  261. package/lib/rules/one-var.js +1 -1
  262. package/lib/rules/operator-assignment.js +1 -1
  263. package/lib/rules/operator-linebreak.js +1 -1
  264. package/lib/rules/padded-blocks.js +1 -1
  265. package/lib/rules/padding-line-between-statements.js +1 -1
  266. package/lib/rules/prefer-arrow-callback.js +1 -1
  267. package/lib/rules/prefer-const.js +1 -1
  268. package/lib/rules/prefer-destructuring.js +1 -1
  269. package/lib/rules/prefer-exponentiation-operator.js +1 -1
  270. package/lib/rules/prefer-named-capture-group.js +1 -1
  271. package/lib/rules/prefer-numeric-literals.js +1 -1
  272. package/lib/rules/prefer-object-has-own.js +1 -1
  273. package/lib/rules/prefer-object-spread.js +1 -1
  274. package/lib/rules/prefer-promise-reject-errors.js +1 -1
  275. package/lib/rules/prefer-reflect.js +1 -2
  276. package/lib/rules/prefer-regex-literals.js +1 -1
  277. package/lib/rules/prefer-rest-params.js +1 -1
  278. package/lib/rules/prefer-spread.js +1 -1
  279. package/lib/rules/prefer-template.js +1 -1
  280. package/lib/rules/quote-props.js +1 -1
  281. package/lib/rules/quotes.js +1 -1
  282. package/lib/rules/radix.js +1 -1
  283. package/lib/rules/require-atomic-updates.js +1 -1
  284. package/lib/rules/require-await.js +1 -1
  285. package/lib/rules/require-unicode-regexp.js +1 -1
  286. package/lib/rules/require-yield.js +1 -1
  287. package/lib/rules/rest-spread-spacing.js +1 -1
  288. package/lib/rules/semi-spacing.js +1 -1
  289. package/lib/rules/semi-style.js +1 -1
  290. package/lib/rules/semi.js +1 -1
  291. package/lib/rules/sort-imports.js +1 -1
  292. package/lib/rules/sort-keys.js +1 -1
  293. package/lib/rules/sort-vars.js +1 -1
  294. package/lib/rules/space-before-blocks.js +1 -1
  295. package/lib/rules/space-before-function-paren.js +1 -1
  296. package/lib/rules/space-in-parens.js +1 -1
  297. package/lib/rules/space-infix-ops.js +1 -1
  298. package/lib/rules/space-unary-ops.js +1 -1
  299. package/lib/rules/spaced-comment.js +1 -1
  300. package/lib/rules/strict.js +1 -1
  301. package/lib/rules/switch-colon-spacing.js +1 -1
  302. package/lib/rules/symbol-description.js +1 -1
  303. package/lib/rules/template-curly-spacing.js +1 -1
  304. package/lib/rules/template-tag-spacing.js +1 -1
  305. package/lib/rules/unicode-bom.js +1 -1
  306. package/lib/rules/use-isnan.js +1 -1
  307. package/lib/rules/utils/ast-utils.js +13 -2
  308. package/lib/rules/utils/fix-tracker.js +10 -2
  309. package/lib/rules/valid-typeof.js +1 -1
  310. package/lib/rules/vars-on-top.js +1 -1
  311. package/lib/rules/wrap-iife.js +1 -1
  312. package/lib/rules/wrap-regex.js +1 -1
  313. package/lib/rules/yield-star-spacing.js +1 -1
  314. package/lib/rules/yoda.js +1 -1
  315. package/lib/services/suppressions-service.js +289 -0
  316. package/lib/shared/flags.js +4 -0
  317. package/lib/shared/types.js +4 -27
  318. package/lib/types/index.d.ts +30 -7
  319. package/lib/types/rules.d.ts +14 -0
  320. 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 {int} [beforeCount] The number of characters before the node to retrieve.
515
- * @param {int} [afterCount] The number of characters after the node to retrieve.
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 {int} index Range index of the desired node.
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 {int} [beforeCount=0] The number of tokens before the node to retrieve.
609
- * @param {int} [afterCount=0] The number of tokens after the node to retrieve.
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 {int} [padding=0] Number of extra tokens on either side of center.
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 expresion. This may change during the lifetime
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}
@@ -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("../shared/types").Rule} Rule */
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.type) || [];
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 {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
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) {
@@ -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 {int} index The 0-based index at which to insert the new text.
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 {int[]} range The range to replace, first item is start of range, second
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 {int[]} range The range to replace, first item is start of range, second
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 {int[]} range The range to replace, first item is start of range, second
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 {int[]} range The range to remove, first item is start of range, second
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
  */
@@ -16,7 +16,7 @@ const builtInRules = require("../rules");
16
16
  // Typedefs
17
17
  //------------------------------------------------------------------------------
18
18
 
19
- /** @typedef {import("../shared/types").Rule} Rule */
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 {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
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 {int} -1 if a comes before b, 1 if a comes after b, 0 if equal.
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) {
@@ -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 {int} len length of the string
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 {int} len length of the string
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("../shared/types").Rule} Rule */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
15
+ /** @type {import('../types').Rule.RuleModule} */
16
16
  module.exports = {
17
17
  meta: {
18
18
  deprecated: {
@@ -12,7 +12,7 @@ const astUtils = require("./utils/ast-utils");
12
12
  // Rule Definition
13
13
  //------------------------------------------------------------------------------
14
14
 
15
- /** @type {import('../shared/types').Rule} */
15
+ /** @type {import('../types').Rule.RuleModule} */
16
16
  module.exports = {
17
17
  meta: {
18
18
  deprecated: {
@@ -9,7 +9,7 @@
9
9
  // Rule Definition
10
10
  //------------------------------------------------------------------------------
11
11
 
12
- /** @type {import('../shared/types').Rule} */
12
+ /** @type {import('../types').Rule.RuleModule} */
13
13
  module.exports = {
14
14
  meta: {
15
15
  deprecated: {
@@ -15,7 +15,7 @@ const astUtils = require("./utils/ast-utils");
15
15
  // Rule Definition
16
16
  //------------------------------------------------------------------------------
17
17
 
18
- /** @type {import('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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 { enforceForClassFields } = options;
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
15
+ /** @type {import('../types').Rule.RuleModule} */
16
16
  module.exports = {
17
17
  meta: {
18
18
  deprecated: {
@@ -19,7 +19,7 @@ const { upperCaseFirst } = require("../shared/string-utils");
19
19
 
20
20
  const THRESHOLD_DEFAULT = 20;
21
21
 
22
- /** @type {import('../shared/types').Rule} */
22
+ /** @type {import('../types').Rule.RuleModule} */
23
23
  module.exports = {
24
24
  meta: {
25
25
  type: "suggestion",
@@ -11,7 +11,7 @@ const astUtils = require("./utils/ast-utils");
11
11
  // Rule Definition
12
12
  //------------------------------------------------------------------------------
13
13
 
14
- /** @type {import('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
132
+ /** @type {import('../types').Rule.RuleModule} */
133
133
  module.exports = {
134
134
  meta: {
135
135
  type: "problem",
@@ -14,7 +14,7 @@ const astUtils = require("./utils/ast-utils");
14
14
  // Rule Definition
15
15
  //------------------------------------------------------------------------------
16
16
 
17
- /** @type {import('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
13
+ /** @type {import('../types').Rule.RuleModule} */
14
14
  module.exports = {
15
15
  meta: {
16
16
  type: "suggestion",
@@ -18,7 +18,7 @@ function isRequiredParameter(node) {
18
18
  );
19
19
  }
20
20
 
21
- /** @type {import('../shared/types').Rule} */
21
+ /** @type {import('../types').Rule.RuleModule} */
22
22
  module.exports = {
23
23
  meta: {
24
24
  dialects: ["javascript", "typescript"],
@@ -12,7 +12,7 @@ const astUtils = require("./utils/ast-utils");
12
12
  // Rule Definition
13
13
  //------------------------------------------------------------------------------
14
14
 
15
- /** @type {import('../shared/types').Rule} */
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('../shared/types').Rule} */
23
+ /** @type {import('../types').Rule.RuleModule} */
24
24
  module.exports = {
25
25
  meta: {
26
26
  type: "suggestion",
@@ -9,7 +9,7 @@
9
9
  // Rule Definition
10
10
  //------------------------------------------------------------------------------
11
11
 
12
- /** @type {import('../shared/types').Rule} */
12
+ /** @type {import('../types').Rule.RuleModule} */
13
13
  module.exports = {
14
14
  meta: {
15
15
  deprecated: {
@@ -15,7 +15,7 @@ const astUtils = require("./utils/ast-utils");
15
15
  // Rule Definition
16
16
  //------------------------------------------------------------------------------
17
17
 
18
- /** @type {import('../shared/types').Rule} */
18
+ /** @type {import('../types').Rule.RuleModule} */
19
19
  module.exports = {
20
20
  meta: {
21
21
  type: "suggestion",