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
@@ -15,7 +15,7 @@ const { getStaticValue } = require("@eslint-community/eslint-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: "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 {int} dir expected direction that could either be turned around or invalidated
58
- * @returns {int} return dir, the negated dir, or zero if the counter does not change or the direction is not clear
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 {int} if add return 1, if sub return -1, if nochange, return 0
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 {int} if add return 1, if sub return -1, if nochange, return 0
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('../shared/types').Rule} */
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 {int} ecmaVersion The ECMAScript version if specified in the parserOptions config
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('../shared/types').Rule} */
80
+ /** @type {import('../types').Rule.RuleModule} */
81
81
  module.exports = {
82
82
  meta: {
83
83
  type: "suggestion",
@@ -24,7 +24,7 @@ function isFunctionName(variable) {
24
24
  // Rule Definition
25
25
  //------------------------------------------------------------------------------
26
26
 
27
- /** @type {import('../shared/types').Rule} */
27
+ /** @type {import('../types').Rule.RuleModule} */
28
28
  module.exports = {
29
29
  meta: {
30
30
  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",
@@ -10,7 +10,7 @@
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
  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: {
@@ -26,7 +26,7 @@ const OVERRIDE_SCHEMA = {
26
26
  ],
27
27
  };
28
28
 
29
- /** @type {import('../shared/types').Rule} */
29
+ /** @type {import('../types').Rule.RuleModule} */
30
30
  module.exports = {
31
31
  meta: {
32
32
  deprecated: {
@@ -36,7 +36,7 @@ function isAnySegmentReachable(segments) {
36
36
  // Rule Definition
37
37
  //------------------------------------------------------------------------------
38
38
 
39
- /** @type {import('../shared/types').Rule} */
39
+ /** @type {import('../types').Rule.RuleModule} */
40
40
  module.exports = {
41
41
  meta: {
42
42
  type: "problem",
@@ -53,7 +53,7 @@ function isShadowed(scope, node) {
53
53
  );
54
54
  }
55
55
 
56
- /** @type {import('../shared/types').Rule} */
56
+ /** @type {import('../types').Rule.RuleModule} */
57
57
  module.exports = {
58
58
  meta: {
59
59
  deprecated: {
@@ -91,7 +91,7 @@ function isAccessorKind(node) {
91
91
  // Rule Definition
92
92
  //------------------------------------------------------------------------------
93
93
 
94
- /** @type {import('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
97
+ /** @type {import('../types').Rule.RuleModule} */
98
98
  module.exports = {
99
99
  meta: {
100
100
  deprecated: {
@@ -83,7 +83,7 @@ function isPropertyNameInDestructuring(node) {
83
83
  // Rule Definition
84
84
  //------------------------------------------------------------------------------
85
85
 
86
- /** @type {import('../shared/types').Rule} */
86
+ /** @type {import('../types').Rule.RuleModule} */
87
87
  module.exports = {
88
88
  meta: {
89
89
  type: "suggestion",
@@ -20,7 +20,7 @@ const {
20
20
  // Rule Definition
21
21
  //------------------------------------------------------------------------------
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",
@@ -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",
@@ -10,7 +10,7 @@ const { isCommentToken, isNotOpeningParenToken } = require("./utils/ast-utils");
10
10
  //------------------------------------------------------------------------------
11
11
  // Rule Definition
12
12
  //------------------------------------------------------------------------------
13
- /** @type {import('../shared/types').Rule} */
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('../shared/types').Rule} */
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 {int} expectedAmount The expected amount of indentation characters for this line
306
- * @param {int} actualSpaces The actual number of indentation spaces that were found on this line
307
- * @param {int} actualTabs The actual number of indentation tabs that were found on this line
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 {int} needed Expected indentation character count
349
- * @param {int} gottenSpaces Indentation space count in the actual node/code
350
- * @param {int} gottenTabs Indentation tab count in the actual node/code
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 {int} neededIndent needed indent
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 {int} indent needed indent
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 {int} lastLineIndent needed indent
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 {int} firstLineIndent first line needed indent
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 {int} firstLineIndent needed indent
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 {int} [providedSwitchIndent] indent for switch statement
1134
- * @returns {int} indent size
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 =
@@ -505,7 +505,7 @@ const ELEMENT_LIST_SCHEMA = {
505
505
  ],
506
506
  };
507
507
 
508
- /** @type {import('../shared/types').Rule} */
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 {int} expectedAmount The expected amount of indentation characters for this line
747
- * @param {int} actualSpaces The actual number of indentation spaces that were found on this line
748
- * @param {int} actualTabs The actual number of indentation tabs that were found on this line
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('../shared/types').Rule} */
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,
@@ -37,7 +37,7 @@ const QUOTE_SETTINGS = {
37
37
  // Rule Definition
38
38
  //------------------------------------------------------------------------------
39
39
 
40
- /** @type {import('../shared/types').Rule} */
40
+ /** @type {import('../types').Rule.RuleModule} */
41
41
  module.exports = {
42
42
  meta: {
43
43
  deprecated: {
@@ -144,7 +144,7 @@ function initOptions(toOptions, fromOptions) {
144
144
  // Rule Definition
145
145
  //------------------------------------------------------------------------------
146
146
 
147
- /** @type {import('../shared/types').Rule} */
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 {int} expected Expected whitespace length.
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 {int} Width of the key.
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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 {int[]} range The range to replace
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
15
+ /** @type {import('../types').Rule.RuleModule} */
16
16
  module.exports = {
17
17
  meta: {
18
18
  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",
@@ -64,7 +64,7 @@ const OPTIONS_OR_INTEGER_SCHEMA = {
64
64
  // Rule Definition
65
65
  //------------------------------------------------------------------------------
66
66
 
67
- /** @type {import('../shared/types').Rule} */
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 {int} tabWidth The width of each tab stop in spaces.
129
- * @returns {int} The computed line length.
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('../shared/types').Rule} */
68
+ /** @type {import('../types').Rule.RuleModule} */
69
69
  module.exports = {
70
70
  meta: {
71
71
  type: "suggestion",
@@ -28,7 +28,7 @@ function range(start, end) {
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
  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",
@@ -16,7 +16,7 @@ const { upperCaseFirst } = require("../shared/string-utils");
16
16
  // Rule Definition
17
17
  //------------------------------------------------------------------------------
18
18
 
19
- /** @type {import('../shared/types').Rule} */
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('../shared/types').Rule} */
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('../shared/types').Rule} */
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 {int} count Number of statements in node
96
- * @param {int} max Maximum number of statements allowed
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('../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: {