eslint 8.39.0 → 8.41.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/README.md +4 -3
  2. package/lib/cli-engine/cli-engine.js +3 -1
  3. package/lib/cli.js +2 -28
  4. package/lib/config/default-config.js +1 -1
  5. package/lib/config/flat-config-schema.js +57 -35
  6. package/lib/eslint/eslint-helpers.js +8 -7
  7. package/lib/eslint/flat-eslint.js +101 -46
  8. package/lib/linter/apply-disable-directives.js +11 -1
  9. package/lib/linter/config-comment-parser.js +9 -2
  10. package/lib/linter/linter.js +20 -11
  11. package/lib/linter/report-translator.js +4 -19
  12. package/lib/rules/accessor-pairs.js +2 -2
  13. package/lib/rules/array-bracket-newline.js +2 -2
  14. package/lib/rules/array-bracket-spacing.js +2 -2
  15. package/lib/rules/array-callback-return.js +2 -2
  16. package/lib/rules/array-element-newline.js +2 -2
  17. package/lib/rules/arrow-body-style.js +2 -2
  18. package/lib/rules/arrow-parens.js +2 -2
  19. package/lib/rules/arrow-spacing.js +2 -2
  20. package/lib/rules/block-scoped-var.js +2 -2
  21. package/lib/rules/block-spacing.js +2 -2
  22. package/lib/rules/brace-style.js +2 -2
  23. package/lib/rules/callback-return.js +2 -2
  24. package/lib/rules/camelcase.js +2 -2
  25. package/lib/rules/capitalized-comments.js +2 -2
  26. package/lib/rules/class-methods-use-this.js +2 -2
  27. package/lib/rules/comma-dangle.js +2 -2
  28. package/lib/rules/comma-spacing.js +2 -2
  29. package/lib/rules/comma-style.js +2 -2
  30. package/lib/rules/complexity.js +1 -1
  31. package/lib/rules/computed-property-spacing.js +2 -2
  32. package/lib/rules/consistent-return.js +3 -3
  33. package/lib/rules/consistent-this.js +2 -2
  34. package/lib/rules/constructor-super.js +1 -1
  35. package/lib/rules/curly.js +2 -2
  36. package/lib/rules/default-case-last.js +1 -1
  37. package/lib/rules/default-case.js +2 -2
  38. package/lib/rules/default-param-last.js +1 -1
  39. package/lib/rules/dot-location.js +2 -2
  40. package/lib/rules/dot-notation.js +2 -2
  41. package/lib/rules/eol-last.js +2 -2
  42. package/lib/rules/eqeqeq.js +2 -2
  43. package/lib/rules/for-direction.js +1 -1
  44. package/lib/rules/func-call-spacing.js +2 -2
  45. package/lib/rules/func-name-matching.js +1 -1
  46. package/lib/rules/func-names.js +2 -2
  47. package/lib/rules/func-style.js +1 -1
  48. package/lib/rules/function-call-argument-newline.js +2 -2
  49. package/lib/rules/function-paren-newline.js +2 -2
  50. package/lib/rules/generator-star-spacing.js +2 -2
  51. package/lib/rules/getter-return.js +2 -2
  52. package/lib/rules/global-require.js +2 -2
  53. package/lib/rules/grouped-accessor-pairs.js +2 -2
  54. package/lib/rules/guard-for-in.js +1 -1
  55. package/lib/rules/handle-callback-err.js +2 -2
  56. package/lib/rules/id-blacklist.js +2 -2
  57. package/lib/rules/id-denylist.js +2 -2
  58. package/lib/rules/id-length.js +3 -36
  59. package/lib/rules/id-match.js +2 -2
  60. package/lib/rules/implicit-arrow-linebreak.js +2 -2
  61. package/lib/rules/indent-legacy.js +2 -2
  62. package/lib/rules/indent.js +40 -56
  63. package/lib/rules/init-declarations.js +1 -1
  64. package/lib/rules/jsx-quotes.js +1 -1
  65. package/lib/rules/key-spacing.js +4 -10
  66. package/lib/rules/keyword-spacing.js +2 -2
  67. package/lib/rules/line-comment-position.js +2 -2
  68. package/lib/rules/linebreak-style.js +2 -2
  69. package/lib/rules/lines-around-comment.js +2 -2
  70. package/lib/rules/lines-around-directive.js +2 -2
  71. package/lib/rules/lines-between-class-members.js +2 -2
  72. package/lib/rules/logical-assignment-operators.js +2 -2
  73. package/lib/rules/max-classes-per-file.js +1 -1
  74. package/lib/rules/max-depth.js +1 -1
  75. package/lib/rules/max-len.js +2 -2
  76. package/lib/rules/max-lines-per-function.js +2 -2
  77. package/lib/rules/max-lines.js +2 -2
  78. package/lib/rules/max-nested-callbacks.js +1 -1
  79. package/lib/rules/max-params.js +2 -2
  80. package/lib/rules/max-statements-per-line.js +2 -2
  81. package/lib/rules/max-statements.js +1 -1
  82. package/lib/rules/multiline-comment-style.js +2 -2
  83. package/lib/rules/multiline-ternary.js +2 -2
  84. package/lib/rules/new-cap.js +2 -2
  85. package/lib/rules/new-parens.js +2 -2
  86. package/lib/rules/newline-after-var.js +2 -2
  87. package/lib/rules/newline-before-return.js +2 -2
  88. package/lib/rules/newline-per-chained-call.js +2 -2
  89. package/lib/rules/no-alert.js +2 -2
  90. package/lib/rules/no-array-constructor.js +1 -1
  91. package/lib/rules/no-async-promise-executor.js +2 -2
  92. package/lib/rules/no-await-in-loop.js +1 -1
  93. package/lib/rules/no-bitwise.js +1 -1
  94. package/lib/rules/no-buffer-constructor.js +1 -1
  95. package/lib/rules/no-caller.js +1 -1
  96. package/lib/rules/no-case-declarations.js +1 -1
  97. package/lib/rules/no-catch-shadow.js +2 -2
  98. package/lib/rules/no-class-assign.js +2 -2
  99. package/lib/rules/no-compare-neg-zero.js +1 -1
  100. package/lib/rules/no-cond-assign.js +2 -2
  101. package/lib/rules/no-confusing-arrow.js +2 -2
  102. package/lib/rules/no-console.js +2 -2
  103. package/lib/rules/no-const-assign.js +2 -2
  104. package/lib/rules/no-constant-binary-expression.js +2 -2
  105. package/lib/rules/no-constant-condition.js +2 -2
  106. package/lib/rules/no-constructor-return.js +1 -1
  107. package/lib/rules/no-continue.js +1 -1
  108. package/lib/rules/no-control-regex.js +1 -1
  109. package/lib/rules/no-debugger.js +1 -1
  110. package/lib/rules/no-delete-var.js +1 -1
  111. package/lib/rules/no-div-regex.js +2 -2
  112. package/lib/rules/no-dupe-args.js +2 -2
  113. package/lib/rules/no-dupe-class-members.js +1 -1
  114. package/lib/rules/no-dupe-else-if.js +2 -2
  115. package/lib/rules/no-dupe-keys.js +1 -1
  116. package/lib/rules/no-duplicate-case.js +2 -2
  117. package/lib/rules/no-duplicate-imports.js +1 -1
  118. package/lib/rules/no-else-return.js +2 -2
  119. package/lib/rules/no-empty-character-class.js +1 -1
  120. package/lib/rules/no-empty-function.js +2 -2
  121. package/lib/rules/no-empty-pattern.js +1 -1
  122. package/lib/rules/no-empty-static-block.js +2 -2
  123. package/lib/rules/no-empty.js +2 -2
  124. package/lib/rules/no-eq-null.js +1 -1
  125. package/lib/rules/no-eval.js +2 -2
  126. package/lib/rules/no-ex-assign.js +2 -2
  127. package/lib/rules/no-extend-native.js +2 -2
  128. package/lib/rules/no-extra-bind.js +2 -2
  129. package/lib/rules/no-extra-boolean-cast.js +2 -2
  130. package/lib/rules/no-extra-label.js +2 -2
  131. package/lib/rules/no-extra-parens.js +2 -2
  132. package/lib/rules/no-extra-semi.js +3 -3
  133. package/lib/rules/no-fallthrough.js +3 -3
  134. package/lib/rules/no-floating-decimal.js +2 -2
  135. package/lib/rules/no-func-assign.js +2 -2
  136. package/lib/rules/no-global-assign.js +2 -2
  137. package/lib/rules/no-implicit-coercion.js +2 -2
  138. package/lib/rules/no-implicit-globals.js +2 -2
  139. package/lib/rules/no-implied-eval.js +2 -2
  140. package/lib/rules/no-import-assign.js +2 -2
  141. package/lib/rules/no-inline-comments.js +2 -2
  142. package/lib/rules/no-inner-declarations.js +1 -1
  143. package/lib/rules/no-invalid-regexp.js +1 -1
  144. package/lib/rules/no-invalid-this.js +2 -2
  145. package/lib/rules/no-irregular-whitespace.js +2 -2
  146. package/lib/rules/no-iterator.js +1 -1
  147. package/lib/rules/no-label-var.js +2 -2
  148. package/lib/rules/no-labels.js +1 -1
  149. package/lib/rules/no-lone-blocks.js +2 -2
  150. package/lib/rules/no-lonely-if.js +2 -2
  151. package/lib/rules/no-loop-func.js +2 -2
  152. package/lib/rules/no-loss-of-precision.js +1 -1
  153. package/lib/rules/no-magic-numbers.js +1 -1
  154. package/lib/rules/no-misleading-character-class.js +2 -2
  155. package/lib/rules/no-mixed-operators.js +2 -2
  156. package/lib/rules/no-mixed-requires.js +1 -1
  157. package/lib/rules/no-mixed-spaces-and-tabs.js +2 -2
  158. package/lib/rules/no-multi-assign.js +1 -1
  159. package/lib/rules/no-multi-spaces.js +2 -2
  160. package/lib/rules/no-multi-str.js +1 -1
  161. package/lib/rules/no-multiple-empty-lines.js +2 -2
  162. package/lib/rules/no-native-reassign.js +2 -2
  163. package/lib/rules/no-negated-condition.js +1 -1
  164. package/lib/rules/no-negated-in-lhs.js +1 -1
  165. package/lib/rules/no-nested-ternary.js +1 -1
  166. package/lib/rules/no-new-func.js +2 -2
  167. package/lib/rules/no-new-native-nonconstructor.js +2 -2
  168. package/lib/rules/no-new-object.js +2 -2
  169. package/lib/rules/no-new-require.js +1 -1
  170. package/lib/rules/no-new-symbol.js +2 -2
  171. package/lib/rules/no-new-wrappers.js +1 -1
  172. package/lib/rules/no-new.js +1 -1
  173. package/lib/rules/no-nonoctal-decimal-escape.js +2 -2
  174. package/lib/rules/no-obj-calls.js +2 -2
  175. package/lib/rules/no-octal-escape.js +1 -1
  176. package/lib/rules/no-octal.js +1 -1
  177. package/lib/rules/no-param-reassign.js +2 -2
  178. package/lib/rules/no-path-concat.js +1 -1
  179. package/lib/rules/no-plusplus.js +1 -1
  180. package/lib/rules/no-process-env.js +1 -1
  181. package/lib/rules/no-process-exit.js +1 -1
  182. package/lib/rules/no-promise-executor-return.js +2 -2
  183. package/lib/rules/no-proto.js +1 -1
  184. package/lib/rules/no-prototype-builtins.js +1 -1
  185. package/lib/rules/no-redeclare.js +2 -2
  186. package/lib/rules/no-regex-spaces.js +2 -2
  187. package/lib/rules/no-restricted-exports.js +2 -2
  188. package/lib/rules/no-restricted-globals.js +2 -2
  189. package/lib/rules/no-restricted-imports.js +2 -2
  190. package/lib/rules/no-restricted-modules.js +1 -1
  191. package/lib/rules/no-restricted-properties.js +1 -1
  192. package/lib/rules/no-restricted-syntax.js +1 -1
  193. package/lib/rules/no-return-assign.js +2 -2
  194. package/lib/rules/no-return-await.js +3 -3
  195. package/lib/rules/no-script-url.js +1 -1
  196. package/lib/rules/no-self-assign.js +2 -2
  197. package/lib/rules/no-self-compare.js +2 -2
  198. package/lib/rules/no-sequences.js +2 -2
  199. package/lib/rules/no-setter-return.js +2 -2
  200. package/lib/rules/no-shadow-restricted-names.js +2 -2
  201. package/lib/rules/no-shadow.js +2 -2
  202. package/lib/rules/no-spaced-func.js +2 -2
  203. package/lib/rules/no-sparse-arrays.js +1 -1
  204. package/lib/rules/no-sync.js +1 -1
  205. package/lib/rules/no-tabs.js +2 -2
  206. package/lib/rules/no-template-curly-in-string.js +1 -1
  207. package/lib/rules/no-ternary.js +1 -1
  208. package/lib/rules/no-this-before-super.js +1 -1
  209. package/lib/rules/no-throw-literal.js +1 -1
  210. package/lib/rules/no-trailing-spaces.js +2 -2
  211. package/lib/rules/no-undef-init.js +2 -2
  212. package/lib/rules/no-undef.js +2 -2
  213. package/lib/rules/no-undefined.js +2 -2
  214. package/lib/rules/no-underscore-dangle.js +2 -2
  215. package/lib/rules/no-unexpected-multiline.js +2 -2
  216. package/lib/rules/no-unmodified-loop-condition.js +2 -2
  217. package/lib/rules/no-unneeded-ternary.js +2 -2
  218. package/lib/rules/no-unreachable-loop.js +1 -1
  219. package/lib/rules/no-unreachable.js +2 -2
  220. package/lib/rules/no-unsafe-finally.js +1 -1
  221. package/lib/rules/no-unsafe-negation.js +2 -2
  222. package/lib/rules/no-unsafe-optional-chaining.js +1 -1
  223. package/lib/rules/no-unused-expressions.js +1 -1
  224. package/lib/rules/no-unused-labels.js +2 -2
  225. package/lib/rules/no-unused-private-class-members.js +1 -1
  226. package/lib/rules/no-unused-vars.js +2 -2
  227. package/lib/rules/no-use-before-define.js +2 -2
  228. package/lib/rules/no-useless-backreference.js +2 -2
  229. package/lib/rules/no-useless-call.js +2 -2
  230. package/lib/rules/no-useless-catch.js +1 -1
  231. package/lib/rules/no-useless-computed-key.js +2 -2
  232. package/lib/rules/no-useless-concat.js +2 -2
  233. package/lib/rules/no-useless-constructor.js +1 -1
  234. package/lib/rules/no-useless-escape.js +2 -2
  235. package/lib/rules/no-useless-rename.js +2 -2
  236. package/lib/rules/no-useless-return.js +2 -2
  237. package/lib/rules/no-var.js +2 -2
  238. package/lib/rules/no-void.js +1 -1
  239. package/lib/rules/no-warning-comments.js +2 -2
  240. package/lib/rules/no-whitespace-before-property.js +2 -2
  241. package/lib/rules/no-with.js +1 -1
  242. package/lib/rules/nonblock-statement-body-position.js +2 -2
  243. package/lib/rules/object-curly-newline.js +2 -2
  244. package/lib/rules/object-curly-spacing.js +4 -4
  245. package/lib/rules/object-property-newline.js +2 -2
  246. package/lib/rules/object-shorthand.js +2 -2
  247. package/lib/rules/one-var-declaration-per-line.js +1 -1
  248. package/lib/rules/one-var.js +2 -2
  249. package/lib/rules/operator-assignment.js +2 -2
  250. package/lib/rules/operator-linebreak.js +2 -2
  251. package/lib/rules/padded-blocks.js +2 -2
  252. package/lib/rules/padding-line-between-statements.js +4 -4
  253. package/lib/rules/prefer-arrow-callback.js +2 -2
  254. package/lib/rules/prefer-const.js +2 -2
  255. package/lib/rules/prefer-destructuring.js +2 -2
  256. package/lib/rules/prefer-exponentiation-operator.js +2 -2
  257. package/lib/rules/prefer-named-capture-group.js +2 -2
  258. package/lib/rules/prefer-numeric-literals.js +2 -2
  259. package/lib/rules/prefer-object-has-own.js +2 -2
  260. package/lib/rules/prefer-object-spread.js +2 -2
  261. package/lib/rules/prefer-promise-reject-errors.js +2 -2
  262. package/lib/rules/prefer-reflect.js +1 -1
  263. package/lib/rules/prefer-regex-literals.js +2 -2
  264. package/lib/rules/prefer-rest-params.js +2 -2
  265. package/lib/rules/prefer-spread.js +2 -2
  266. package/lib/rules/prefer-template.js +2 -2
  267. package/lib/rules/quote-props.js +2 -2
  268. package/lib/rules/quotes.js +2 -2
  269. package/lib/rules/radix.js +2 -2
  270. package/lib/rules/require-atomic-updates.js +2 -2
  271. package/lib/rules/require-await.js +2 -2
  272. package/lib/rules/require-jsdoc.js +2 -2
  273. package/lib/rules/require-unicode-regexp.js +2 -2
  274. package/lib/rules/require-yield.js +1 -1
  275. package/lib/rules/rest-spread-spacing.js +2 -2
  276. package/lib/rules/semi-spacing.js +2 -2
  277. package/lib/rules/semi-style.js +2 -2
  278. package/lib/rules/semi.js +30 -5
  279. package/lib/rules/sort-imports.js +2 -2
  280. package/lib/rules/sort-keys.js +2 -2
  281. package/lib/rules/sort-vars.js +2 -2
  282. package/lib/rules/space-before-blocks.js +2 -2
  283. package/lib/rules/space-before-function-paren.js +2 -2
  284. package/lib/rules/space-in-parens.js +2 -2
  285. package/lib/rules/space-infix-ops.js +2 -2
  286. package/lib/rules/space-unary-ops.js +2 -2
  287. package/lib/rules/spaced-comment.js +2 -2
  288. package/lib/rules/strict.js +1 -1
  289. package/lib/rules/switch-colon-spacing.js +2 -2
  290. package/lib/rules/symbol-description.js +2 -2
  291. package/lib/rules/template-curly-spacing.js +2 -2
  292. package/lib/rules/template-tag-spacing.js +2 -2
  293. package/lib/rules/unicode-bom.js +2 -2
  294. package/lib/rules/use-isnan.js +1 -1
  295. package/lib/rules/valid-jsdoc.js +2 -2
  296. package/lib/rules/valid-typeof.js +2 -2
  297. package/lib/rules/vars-on-top.js +1 -1
  298. package/lib/rules/wrap-iife.js +2 -2
  299. package/lib/rules/wrap-regex.js +2 -2
  300. package/lib/rules/yield-star-spacing.js +2 -2
  301. package/lib/rules/yoda.js +2 -2
  302. package/lib/shared/string-utils.js +39 -1
  303. package/lib/shared/types.js +6 -2
  304. package/lib/unsupported-api.js +2 -1
  305. package/messages/invalid-rule-options.js +17 -0
  306. package/messages/invalid-rule-severity.js +13 -0
  307. package/messages/shared.js +18 -0
  308. package/package.json +6 -7
@@ -19,7 +19,7 @@ module.exports = {
19
19
  docs: {
20
20
  description: "Enforce consistent newlines before and after dots",
21
21
  recommended: false,
22
- url: "https://eslint.org/docs/rules/dot-location"
22
+ url: "https://eslint.org/docs/latest/rules/dot-location"
23
23
  },
24
24
 
25
25
  schema: [
@@ -43,7 +43,7 @@ module.exports = {
43
43
  // default to onObject if no preference is passed
44
44
  const onObject = config === "object" || !config;
45
45
 
46
- const sourceCode = context.getSourceCode();
46
+ const sourceCode = context.sourceCode;
47
47
 
48
48
  /**
49
49
  * Reports if the dot between object and property is on the correct location.
@@ -28,7 +28,7 @@ module.exports = {
28
28
  docs: {
29
29
  description: "Enforce dot notation whenever possible",
30
30
  recommended: false,
31
- url: "https://eslint.org/docs/rules/dot-notation"
31
+ url: "https://eslint.org/docs/latest/rules/dot-notation"
32
32
  },
33
33
 
34
34
  schema: [
@@ -59,7 +59,7 @@ module.exports = {
59
59
  create(context) {
60
60
  const options = context.options[0] || {};
61
61
  const allowKeywords = options.allowKeywords === void 0 || options.allowKeywords;
62
- const sourceCode = context.getSourceCode();
62
+ const sourceCode = context.sourceCode;
63
63
 
64
64
  let allowPattern;
65
65
 
@@ -16,7 +16,7 @@ module.exports = {
16
16
  docs: {
17
17
  description: "Require or disallow newline at the end of files",
18
18
  recommended: false,
19
- url: "https://eslint.org/docs/rules/eol-last"
19
+ url: "https://eslint.org/docs/latest/rules/eol-last"
20
20
  },
21
21
 
22
22
  fixable: "whitespace",
@@ -40,7 +40,7 @@ module.exports = {
40
40
 
41
41
  return {
42
42
  Program: function checkBadEOF(node) {
43
- const sourceCode = context.getSourceCode(),
43
+ const sourceCode = context.sourceCode,
44
44
  src = sourceCode.getText(),
45
45
  lastLine = sourceCode.lines[sourceCode.lines.length - 1],
46
46
  location = {
@@ -23,7 +23,7 @@ module.exports = {
23
23
  docs: {
24
24
  description: "Require the use of `===` and `!==`",
25
25
  recommended: false,
26
- url: "https://eslint.org/docs/rules/eqeqeq"
26
+ url: "https://eslint.org/docs/latest/rules/eqeqeq"
27
27
  },
28
28
 
29
29
  schema: {
@@ -68,7 +68,7 @@ module.exports = {
68
68
  create(context) {
69
69
  const config = context.options[0] || "always";
70
70
  const options = context.options[1] || {};
71
- const sourceCode = context.getSourceCode();
71
+ const sourceCode = context.sourceCode;
72
72
 
73
73
  const nullOption = (config === "always")
74
74
  ? options.null || "always"
@@ -17,7 +17,7 @@ module.exports = {
17
17
  docs: {
18
18
  description: "Enforce \"for\" loop update clause moving the counter in the right direction",
19
19
  recommended: true,
20
- url: "https://eslint.org/docs/rules/for-direction"
20
+ url: "https://eslint.org/docs/latest/rules/for-direction"
21
21
  },
22
22
 
23
23
  fixable: null,
@@ -23,7 +23,7 @@ module.exports = {
23
23
  docs: {
24
24
  description: "Require or disallow spacing between function identifiers and their invocations",
25
25
  recommended: false,
26
- url: "https://eslint.org/docs/rules/func-call-spacing"
26
+ url: "https://eslint.org/docs/latest/rules/func-call-spacing"
27
27
  },
28
28
 
29
29
  fixable: "whitespace",
@@ -73,7 +73,7 @@ module.exports = {
73
73
 
74
74
  const never = context.options[0] !== "always";
75
75
  const allowNewlines = !never && context.options[1] && context.options[1].allowNewlines;
76
- const sourceCode = context.getSourceCode();
76
+ const sourceCode = context.sourceCode;
77
77
  const text = sourceCode.getText();
78
78
 
79
79
  /**
@@ -76,7 +76,7 @@ module.exports = {
76
76
  docs: {
77
77
  description: "Require function names to match the name of the variable or property to which they are assigned",
78
78
  recommended: false,
79
- url: "https://eslint.org/docs/rules/func-name-matching"
79
+ url: "https://eslint.org/docs/latest/rules/func-name-matching"
80
80
  },
81
81
 
82
82
  schema: {
@@ -32,7 +32,7 @@ module.exports = {
32
32
  docs: {
33
33
  description: "Require or disallow named `function` expressions",
34
34
  recommended: false,
35
- url: "https://eslint.org/docs/rules/func-names"
35
+ url: "https://eslint.org/docs/latest/rules/func-names"
36
36
  },
37
37
 
38
38
  schema: {
@@ -69,7 +69,7 @@ module.exports = {
69
69
 
70
70
  create(context) {
71
71
 
72
- const sourceCode = context.getSourceCode();
72
+ const sourceCode = context.sourceCode;
73
73
 
74
74
  /**
75
75
  * Returns the config option for the given node.
@@ -16,7 +16,7 @@ module.exports = {
16
16
  docs: {
17
17
  description: "Enforce the consistent use of either `function` declarations or expressions",
18
18
  recommended: false,
19
- url: "https://eslint.org/docs/rules/func-style"
19
+ url: "https://eslint.org/docs/latest/rules/func-style"
20
20
  },
21
21
 
22
22
  schema: [
@@ -17,7 +17,7 @@ module.exports = {
17
17
  docs: {
18
18
  description: "Enforce line breaks between arguments of a function call",
19
19
  recommended: false,
20
- url: "https://eslint.org/docs/rules/function-call-argument-newline"
20
+ url: "https://eslint.org/docs/latest/rules/function-call-argument-newline"
21
21
  },
22
22
 
23
23
  fixable: "whitespace",
@@ -35,7 +35,7 @@ module.exports = {
35
35
  },
36
36
 
37
37
  create(context) {
38
- const sourceCode = context.getSourceCode();
38
+ const sourceCode = context.sourceCode;
39
39
 
40
40
  const checkers = {
41
41
  unexpected: {
@@ -22,7 +22,7 @@ module.exports = {
22
22
  docs: {
23
23
  description: "Enforce consistent line breaks inside function parentheses",
24
24
  recommended: false,
25
- url: "https://eslint.org/docs/rules/function-paren-newline"
25
+ url: "https://eslint.org/docs/latest/rules/function-paren-newline"
26
26
  },
27
27
 
28
28
  fixable: "whitespace",
@@ -57,7 +57,7 @@ module.exports = {
57
57
  },
58
58
 
59
59
  create(context) {
60
- const sourceCode = context.getSourceCode();
60
+ const sourceCode = context.sourceCode;
61
61
  const rawOption = context.options[0] || "multiline";
62
62
  const multilineOption = rawOption === "multiline";
63
63
  const multilineArgumentsOption = rawOption === "multiline-arguments";
@@ -33,7 +33,7 @@ module.exports = {
33
33
  docs: {
34
34
  description: "Enforce consistent spacing around `*` operators in generator functions",
35
35
  recommended: false,
36
- url: "https://eslint.org/docs/rules/generator-star-spacing"
36
+ url: "https://eslint.org/docs/latest/rules/generator-star-spacing"
37
37
  },
38
38
 
39
39
  fixable: "whitespace",
@@ -102,7 +102,7 @@ module.exports = {
102
102
  };
103
103
  }(context.options[0] || {}));
104
104
 
105
- const sourceCode = context.getSourceCode();
105
+ const sourceCode = context.sourceCode;
106
106
 
107
107
  /**
108
108
  * Checks if the given token is a star token or not.
@@ -37,7 +37,7 @@ module.exports = {
37
37
  docs: {
38
38
  description: "Enforce `return` statements in getters",
39
39
  recommended: true,
40
- url: "https://eslint.org/docs/rules/getter-return"
40
+ url: "https://eslint.org/docs/latest/rules/getter-return"
41
41
  },
42
42
 
43
43
  fixable: null,
@@ -64,7 +64,7 @@ module.exports = {
64
64
  create(context) {
65
65
 
66
66
  const options = context.options[0] || { allowImplicit: false };
67
- const sourceCode = context.getSourceCode();
67
+ const sourceCode = context.sourceCode;
68
68
 
69
69
  let funcInfo = {
70
70
  upper: null,
@@ -61,7 +61,7 @@ module.exports = {
61
61
  docs: {
62
62
  description: "Require `require()` calls to be placed at top-level module scope",
63
63
  recommended: false,
64
- url: "https://eslint.org/docs/rules/global-require"
64
+ url: "https://eslint.org/docs/latest/rules/global-require"
65
65
  },
66
66
 
67
67
  schema: [],
@@ -71,7 +71,7 @@ module.exports = {
71
71
  },
72
72
 
73
73
  create(context) {
74
- const sourceCode = context.getSourceCode();
74
+ const sourceCode = context.sourceCode;
75
75
 
76
76
  return {
77
77
  CallExpression(node) {
@@ -98,7 +98,7 @@ module.exports = {
98
98
  docs: {
99
99
  description: "Require grouped accessor pairs in object literals and classes",
100
100
  recommended: false,
101
- url: "https://eslint.org/docs/rules/grouped-accessor-pairs"
101
+ url: "https://eslint.org/docs/latest/rules/grouped-accessor-pairs"
102
102
  },
103
103
 
104
104
  schema: [
@@ -115,7 +115,7 @@ module.exports = {
115
115
 
116
116
  create(context) {
117
117
  const order = context.options[0] || "anyOrder";
118
- const sourceCode = context.getSourceCode();
118
+ const sourceCode = context.sourceCode;
119
119
 
120
120
  /**
121
121
  * Reports the given accessor pair.
@@ -17,7 +17,7 @@ module.exports = {
17
17
  docs: {
18
18
  description: "Require `for-in` loops to include an `if` statement",
19
19
  recommended: false,
20
- url: "https://eslint.org/docs/rules/guard-for-in"
20
+ url: "https://eslint.org/docs/latest/rules/guard-for-in"
21
21
  },
22
22
 
23
23
  schema: [],
@@ -22,7 +22,7 @@ module.exports = {
22
22
  docs: {
23
23
  description: "Require error handling in callbacks",
24
24
  recommended: false,
25
- url: "https://eslint.org/docs/rules/handle-callback-err"
25
+ url: "https://eslint.org/docs/latest/rules/handle-callback-err"
26
26
  },
27
27
 
28
28
  schema: [
@@ -38,7 +38,7 @@ module.exports = {
38
38
  create(context) {
39
39
 
40
40
  const errorArgument = context.options[0] || "err";
41
- const sourceCode = context.getSourceCode();
41
+ const sourceCode = context.sourceCode;
42
42
 
43
43
  /**
44
44
  * Checks if the given argument should be interpreted as a regexp pattern.
@@ -121,7 +121,7 @@ module.exports = {
121
121
  docs: {
122
122
  description: "Disallow specified identifiers",
123
123
  recommended: false,
124
- url: "https://eslint.org/docs/rules/id-blacklist"
124
+ url: "https://eslint.org/docs/latest/rules/id-blacklist"
125
125
  },
126
126
 
127
127
  schema: {
@@ -140,7 +140,7 @@ module.exports = {
140
140
 
141
141
  const denyList = new Set(context.options);
142
142
  const reportedNodes = new Set();
143
- const sourceCode = context.getSourceCode();
143
+ const sourceCode = context.sourceCode;
144
144
 
145
145
  let globalScope;
146
146
 
@@ -101,7 +101,7 @@ module.exports = {
101
101
  docs: {
102
102
  description: "Disallow specified identifiers",
103
103
  recommended: false,
104
- url: "https://eslint.org/docs/rules/id-denylist"
104
+ url: "https://eslint.org/docs/latest/rules/id-denylist"
105
105
  },
106
106
 
107
107
  schema: {
@@ -121,7 +121,7 @@ module.exports = {
121
121
 
122
122
  const denyList = new Set(context.options);
123
123
  const reportedNodes = new Set();
124
- const sourceCode = context.getSourceCode();
124
+ const sourceCode = context.sourceCode;
125
125
 
126
126
  let globalScope;
127
127
 
@@ -9,41 +9,8 @@
9
9
  //------------------------------------------------------------------------------
10
10
  // Requirements
11
11
  //------------------------------------------------------------------------------
12
- const GraphemeSplitter = require("grapheme-splitter");
13
12
 
14
- //------------------------------------------------------------------------------
15
- // Helpers
16
- //------------------------------------------------------------------------------
17
-
18
- /**
19
- * Checks if the string given as argument is ASCII or not.
20
- * @param {string} value A string that you want to know if it is ASCII or not.
21
- * @returns {boolean} `true` if `value` is ASCII string.
22
- */
23
- function isASCII(value) {
24
- if (typeof value !== "string") {
25
- return false;
26
- }
27
- return /^[\u0020-\u007f]*$/u.test(value);
28
- }
29
-
30
- /** @type {GraphemeSplitter | undefined} */
31
- let splitter;
32
-
33
- /**
34
- * Gets the length of the string. If the string is not in ASCII, counts graphemes.
35
- * @param {string} value A string that you want to get the length.
36
- * @returns {number} The length of `value`.
37
- */
38
- function getStringLength(value) {
39
- if (isASCII(value)) {
40
- return value.length;
41
- }
42
- if (!splitter) {
43
- splitter = new GraphemeSplitter();
44
- }
45
- return splitter.countGraphemes(value);
46
- }
13
+ const { getGraphemeCount } = require("../shared/string-utils");
47
14
 
48
15
  //------------------------------------------------------------------------------
49
16
  // Rule Definition
@@ -57,7 +24,7 @@ module.exports = {
57
24
  docs: {
58
25
  description: "Enforce minimum and maximum identifier lengths",
59
26
  recommended: false,
60
- url: "https://eslint.org/docs/rules/id-length"
27
+ url: "https://eslint.org/docs/latest/rules/id-length"
61
28
  },
62
29
 
63
30
  schema: [
@@ -169,7 +136,7 @@ module.exports = {
169
136
  const name = node.name;
170
137
  const parent = node.parent;
171
138
 
172
- const nameLength = getStringLength(name);
139
+ const nameLength = getGraphemeCount(name);
173
140
 
174
141
  const isShort = nameLength < minLength;
175
142
  const isLong = nameLength > maxLength;
@@ -17,7 +17,7 @@ module.exports = {
17
17
  docs: {
18
18
  description: "Require identifiers to match a specified regular expression",
19
19
  recommended: false,
20
- url: "https://eslint.org/docs/rules/id-match"
20
+ url: "https://eslint.org/docs/latest/rules/id-match"
21
21
  },
22
22
 
23
23
  schema: [
@@ -67,7 +67,7 @@ module.exports = {
67
67
  onlyDeclarations = !!options.onlyDeclarations,
68
68
  ignoreDestructuring = !!options.ignoreDestructuring;
69
69
 
70
- const sourceCode = context.getSourceCode();
70
+ const sourceCode = context.sourceCode;
71
71
  let globalScope;
72
72
 
73
73
  //--------------------------------------------------------------------------
@@ -17,7 +17,7 @@ module.exports = {
17
17
  docs: {
18
18
  description: "Enforce the location of arrow function bodies",
19
19
  recommended: false,
20
- url: "https://eslint.org/docs/rules/implicit-arrow-linebreak"
20
+ url: "https://eslint.org/docs/latest/rules/implicit-arrow-linebreak"
21
21
  },
22
22
 
23
23
  fixable: "whitespace",
@@ -34,7 +34,7 @@ module.exports = {
34
34
  },
35
35
 
36
36
  create(context) {
37
- const sourceCode = context.getSourceCode();
37
+ const sourceCode = context.sourceCode;
38
38
  const option = context.options[0] || "beside";
39
39
 
40
40
  /**
@@ -28,7 +28,7 @@ module.exports = {
28
28
  docs: {
29
29
  description: "Enforce consistent indentation",
30
30
  recommended: false,
31
- url: "https://eslint.org/docs/rules/indent-legacy"
31
+ url: "https://eslint.org/docs/latest/rules/indent-legacy"
32
32
  },
33
33
 
34
34
  deprecated: true,
@@ -206,7 +206,7 @@ module.exports = {
206
206
  ObjectExpression: 1
207
207
  };
208
208
 
209
- const sourceCode = context.getSourceCode();
209
+ const sourceCode = context.sourceCode;
210
210
 
211
211
  if (context.options.length) {
212
212
  if (context.options[0] === "tab") {
@@ -12,8 +12,6 @@
12
12
  // Requirements
13
13
  //------------------------------------------------------------------------------
14
14
 
15
- const { OrderedMap } = require("js-sdsl");
16
-
17
15
  const astUtils = require("./utils/ast-utils");
18
16
 
19
17
  //------------------------------------------------------------------------------
@@ -125,43 +123,48 @@ const KNOWN_NODES = new Set([
125
123
 
126
124
 
127
125
  /**
128
- * A mutable balanced binary search tree that stores (key, value) pairs. The keys are numeric, and must be unique.
129
- * This is intended to be a generic wrapper around a balanced binary search tree library, so that the underlying implementation
126
+ * A mutable map that stores (key, value) pairs. The keys are numeric indices, and must be unique.
127
+ * This is intended to be a generic wrapper around a map with non-negative integer keys, so that the underlying implementation
130
128
  * can easily be swapped out.
131
129
  */
132
- class BinarySearchTree {
130
+ class IndexMap {
133
131
 
134
132
  /**
135
- * Creates an empty tree
133
+ * Creates an empty map
134
+ * @param {number} maxKey The maximum key
136
135
  */
137
- constructor() {
138
- this._orderedMap = new OrderedMap();
139
- this._orderedMapEnd = this._orderedMap.end();
136
+ constructor(maxKey) {
137
+
138
+ // Initializing the array with the maximum expected size avoids dynamic reallocations that could degrade performance.
139
+ this._values = Array(maxKey + 1);
140
140
  }
141
141
 
142
142
  /**
143
- * Inserts an entry into the tree.
143
+ * Inserts an entry into the map.
144
144
  * @param {number} key The entry's key
145
145
  * @param {any} value The entry's value
146
146
  * @returns {void}
147
147
  */
148
148
  insert(key, value) {
149
- this._orderedMap.setElement(key, value);
149
+ this._values[key] = value;
150
150
  }
151
151
 
152
152
  /**
153
- * Finds the entry with the largest key less than or equal to the provided key
153
+ * Finds the value of the entry with the largest key less than or equal to the provided key
154
154
  * @param {number} key The provided key
155
- * @returns {{key: number, value: *}|null} The found entry, or null if no such entry exists.
155
+ * @returns {*|undefined} The value of the found entry, or undefined if no such entry exists.
156
156
  */
157
- findLe(key) {
158
- const iterator = this._orderedMap.reverseLowerBound(key);
157
+ findLastNotAfter(key) {
158
+ const values = this._values;
159
159
 
160
- if (iterator.equals(this._orderedMapEnd)) {
161
- return {};
162
- }
160
+ for (let index = key; index >= 0; index--) {
161
+ const value = values[index];
163
162
 
164
- return { key: iterator.pointer[0], value: iterator.pointer[1] };
163
+ if (value) {
164
+ return value;
165
+ }
166
+ }
167
+ return void 0;
165
168
  }
166
169
 
167
170
  /**
@@ -171,26 +174,7 @@ class BinarySearchTree {
171
174
  * @returns {void}
172
175
  */
173
176
  deleteRange(start, end) {
174
-
175
- // Exit without traversing the tree if the range has zero size.
176
- if (start === end) {
177
- return;
178
- }
179
- const iterator = this._orderedMap.lowerBound(start);
180
-
181
- if (iterator.equals(this._orderedMapEnd)) {
182
- return;
183
- }
184
-
185
- if (end > this._orderedMap.back()[0]) {
186
- while (!iterator.equals(this._orderedMapEnd)) {
187
- this._orderedMap.eraseElementByIterator(iterator);
188
- }
189
- } else {
190
- while (iterator.pointer[0] < end) {
191
- this._orderedMap.eraseElementByIterator(iterator);
192
- }
193
- }
177
+ this._values.fill(void 0, start, end);
194
178
  }
195
179
  }
196
180
 
@@ -252,14 +236,15 @@ class OffsetStorage {
252
236
  * @param {TokenInfo} tokenInfo a TokenInfo instance
253
237
  * @param {number} indentSize The desired size of each indentation level
254
238
  * @param {string} indentType The indentation character
239
+ * @param {number} maxIndex The maximum end index of any token
255
240
  */
256
- constructor(tokenInfo, indentSize, indentType) {
241
+ constructor(tokenInfo, indentSize, indentType, maxIndex) {
257
242
  this._tokenInfo = tokenInfo;
258
243
  this._indentSize = indentSize;
259
244
  this._indentType = indentType;
260
245
 
261
- this._tree = new BinarySearchTree();
262
- this._tree.insert(0, { offset: 0, from: null, force: false });
246
+ this._indexMap = new IndexMap(maxIndex);
247
+ this._indexMap.insert(0, { offset: 0, from: null, force: false });
263
248
 
264
249
  this._lockedFirstTokens = new WeakMap();
265
250
  this._desiredIndentCache = new WeakMap();
@@ -267,7 +252,7 @@ class OffsetStorage {
267
252
  }
268
253
 
269
254
  _getOffsetDescriptor(token) {
270
- return this._tree.findLe(token.range[0]).value;
255
+ return this._indexMap.findLastNotAfter(token.range[0]);
271
256
  }
272
257
 
273
258
  /**
@@ -388,37 +373,36 @@ class OffsetStorage {
388
373
  * * key: 820, value: { offset: 1, from: bazToken }
389
374
  *
390
375
  * To find the offset descriptor for any given token, one needs to find the node with the largest key
391
- * which is <= token.start. To make this operation fast, the nodes are stored in a balanced binary
392
- * search tree indexed by key.
376
+ * which is <= token.start. To make this operation fast, the nodes are stored in a map indexed by key.
393
377
  */
394
378
 
395
379
  const descriptorToInsert = { offset, from: fromToken, force };
396
380
 
397
- const descriptorAfterRange = this._tree.findLe(range[1]).value;
381
+ const descriptorAfterRange = this._indexMap.findLastNotAfter(range[1]);
398
382
 
399
383
  const fromTokenIsInRange = fromToken && fromToken.range[0] >= range[0] && fromToken.range[1] <= range[1];
400
384
  const fromTokenDescriptor = fromTokenIsInRange && this._getOffsetDescriptor(fromToken);
401
385
 
402
- // First, remove any existing nodes in the range from the tree.
403
- this._tree.deleteRange(range[0] + 1, range[1]);
386
+ // First, remove any existing nodes in the range from the map.
387
+ this._indexMap.deleteRange(range[0] + 1, range[1]);
404
388
 
405
- // Insert a new node into the tree for this range
406
- this._tree.insert(range[0], descriptorToInsert);
389
+ // Insert a new node into the map for this range
390
+ this._indexMap.insert(range[0], descriptorToInsert);
407
391
 
408
392
  /*
409
393
  * To avoid circular offset dependencies, keep the `fromToken` token mapped to whatever it was mapped to previously,
410
394
  * even if it's in the current range.
411
395
  */
412
396
  if (fromTokenIsInRange) {
413
- this._tree.insert(fromToken.range[0], fromTokenDescriptor);
414
- this._tree.insert(fromToken.range[1], descriptorToInsert);
397
+ this._indexMap.insert(fromToken.range[0], fromTokenDescriptor);
398
+ this._indexMap.insert(fromToken.range[1], descriptorToInsert);
415
399
  }
416
400
 
417
401
  /*
418
402
  * To avoid modifying the offset of tokens after the range, insert another node to keep the offset of the following
419
403
  * tokens the same as it was before.
420
404
  */
421
- this._tree.insert(range[1], descriptorAfterRange);
405
+ this._indexMap.insert(range[1], descriptorAfterRange);
422
406
  }
423
407
 
424
408
  /**
@@ -510,7 +494,7 @@ module.exports = {
510
494
  docs: {
511
495
  description: "Enforce consistent indentation",
512
496
  recommended: false,
513
- url: "https://eslint.org/docs/rules/indent"
497
+ url: "https://eslint.org/docs/latest/rules/indent"
514
498
  },
515
499
 
516
500
  fixable: "whitespace",
@@ -703,9 +687,9 @@ module.exports = {
703
687
  }
704
688
  }
705
689
 
706
- const sourceCode = context.getSourceCode();
690
+ const sourceCode = context.sourceCode;
707
691
  const tokenInfo = new TokenInfo(sourceCode);
708
- const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t");
692
+ const offsets = new OffsetStorage(tokenInfo, indentSize, indentType === "space" ? " " : "\t", sourceCode.text.length);
709
693
  const parameterParens = new WeakSet();
710
694
 
711
695
  /**
@@ -50,7 +50,7 @@ module.exports = {
50
50
  docs: {
51
51
  description: "Require or disallow initialization in variable declarations",
52
52
  recommended: false,
53
- url: "https://eslint.org/docs/rules/init-declarations"
53
+ url: "https://eslint.org/docs/latest/rules/init-declarations"
54
54
  },
55
55
 
56
56
  schema: {
@@ -44,7 +44,7 @@ module.exports = {
44
44
  docs: {
45
45
  description: "Enforce the consistent use of either double or single quotes in JSX attributes",
46
46
  recommended: false,
47
- url: "https://eslint.org/docs/rules/jsx-quotes"
47
+ url: "https://eslint.org/docs/latest/rules/jsx-quotes"
48
48
  },
49
49
 
50
50
  fixable: "whitespace",