eslint 8.39.0 → 8.47.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 (317) hide show
  1. package/README.md +10 -4
  2. package/conf/globals.js +6 -1
  3. package/lib/cli-engine/cli-engine.js +30 -19
  4. package/lib/cli.js +2 -28
  5. package/lib/config/default-config.js +1 -1
  6. package/lib/config/flat-config-schema.js +127 -35
  7. package/lib/eslint/eslint-helpers.js +11 -10
  8. package/lib/eslint/eslint.js +1 -1
  9. package/lib/eslint/flat-eslint.js +119 -161
  10. package/lib/linter/apply-disable-directives.js +11 -1
  11. package/lib/linter/code-path-analysis/debug-helpers.js +1 -1
  12. package/lib/linter/config-comment-parser.js +9 -2
  13. package/lib/linter/linter.js +20 -11
  14. package/lib/linter/report-translator.js +22 -21
  15. package/lib/rule-tester/flat-rule-tester.js +1 -2
  16. package/lib/rule-tester/rule-tester.js +1 -2
  17. package/lib/rules/accessor-pairs.js +35 -43
  18. package/lib/rules/array-bracket-newline.js +2 -2
  19. package/lib/rules/array-bracket-spacing.js +2 -2
  20. package/lib/rules/array-callback-return.js +2 -2
  21. package/lib/rules/array-element-newline.js +12 -6
  22. package/lib/rules/arrow-body-style.js +2 -2
  23. package/lib/rules/arrow-parens.js +2 -2
  24. package/lib/rules/arrow-spacing.js +2 -2
  25. package/lib/rules/block-scoped-var.js +17 -7
  26. package/lib/rules/block-spacing.js +2 -2
  27. package/lib/rules/brace-style.js +2 -2
  28. package/lib/rules/callback-return.js +2 -2
  29. package/lib/rules/camelcase.js +2 -2
  30. package/lib/rules/capitalized-comments.js +2 -2
  31. package/lib/rules/class-methods-use-this.js +2 -2
  32. package/lib/rules/comma-dangle.js +2 -2
  33. package/lib/rules/comma-spacing.js +2 -2
  34. package/lib/rules/comma-style.js +2 -2
  35. package/lib/rules/complexity.js +1 -1
  36. package/lib/rules/computed-property-spacing.js +2 -2
  37. package/lib/rules/consistent-return.js +3 -3
  38. package/lib/rules/consistent-this.js +2 -2
  39. package/lib/rules/constructor-super.js +1 -1
  40. package/lib/rules/curly.js +2 -2
  41. package/lib/rules/default-case-last.js +1 -1
  42. package/lib/rules/default-case.js +2 -2
  43. package/lib/rules/default-param-last.js +1 -1
  44. package/lib/rules/dot-location.js +2 -2
  45. package/lib/rules/dot-notation.js +3 -4
  46. package/lib/rules/eol-last.js +2 -2
  47. package/lib/rules/eqeqeq.js +2 -2
  48. package/lib/rules/for-direction.js +1 -1
  49. package/lib/rules/func-call-spacing.js +2 -2
  50. package/lib/rules/func-name-matching.js +1 -1
  51. package/lib/rules/func-names.js +2 -2
  52. package/lib/rules/func-style.js +1 -1
  53. package/lib/rules/function-call-argument-newline.js +2 -2
  54. package/lib/rules/function-paren-newline.js +2 -2
  55. package/lib/rules/generator-star-spacing.js +2 -2
  56. package/lib/rules/getter-return.js +2 -2
  57. package/lib/rules/global-require.js +2 -2
  58. package/lib/rules/grouped-accessor-pairs.js +35 -44
  59. package/lib/rules/guard-for-in.js +1 -1
  60. package/lib/rules/handle-callback-err.js +2 -2
  61. package/lib/rules/id-blacklist.js +2 -2
  62. package/lib/rules/id-denylist.js +2 -2
  63. package/lib/rules/id-length.js +3 -36
  64. package/lib/rules/id-match.js +2 -2
  65. package/lib/rules/implicit-arrow-linebreak.js +2 -2
  66. package/lib/rules/indent-legacy.js +2 -2
  67. package/lib/rules/indent.js +84 -88
  68. package/lib/rules/init-declarations.js +1 -1
  69. package/lib/rules/jsx-quotes.js +1 -1
  70. package/lib/rules/key-spacing.js +4 -10
  71. package/lib/rules/keyword-spacing.js +2 -2
  72. package/lib/rules/line-comment-position.js +2 -2
  73. package/lib/rules/linebreak-style.js +2 -2
  74. package/lib/rules/lines-around-comment.js +2 -2
  75. package/lib/rules/lines-around-directive.js +2 -2
  76. package/lib/rules/lines-between-class-members.js +2 -2
  77. package/lib/rules/logical-assignment-operators.js +7 -5
  78. package/lib/rules/max-classes-per-file.js +1 -1
  79. package/lib/rules/max-depth.js +1 -1
  80. package/lib/rules/max-len.js +19 -15
  81. package/lib/rules/max-lines-per-function.js +2 -2
  82. package/lib/rules/max-lines.js +2 -2
  83. package/lib/rules/max-nested-callbacks.js +1 -1
  84. package/lib/rules/max-params.js +2 -2
  85. package/lib/rules/max-statements-per-line.js +2 -2
  86. package/lib/rules/max-statements.js +1 -1
  87. package/lib/rules/multiline-comment-style.js +2 -2
  88. package/lib/rules/multiline-ternary.js +2 -2
  89. package/lib/rules/new-cap.js +2 -2
  90. package/lib/rules/new-parens.js +2 -2
  91. package/lib/rules/newline-after-var.js +2 -4
  92. package/lib/rules/newline-before-return.js +2 -2
  93. package/lib/rules/newline-per-chained-call.js +2 -2
  94. package/lib/rules/no-alert.js +2 -2
  95. package/lib/rules/no-array-constructor.js +1 -1
  96. package/lib/rules/no-async-promise-executor.js +2 -2
  97. package/lib/rules/no-await-in-loop.js +1 -1
  98. package/lib/rules/no-bitwise.js +1 -1
  99. package/lib/rules/no-buffer-constructor.js +1 -1
  100. package/lib/rules/no-caller.js +1 -1
  101. package/lib/rules/no-case-declarations.js +1 -1
  102. package/lib/rules/no-catch-shadow.js +2 -2
  103. package/lib/rules/no-class-assign.js +2 -2
  104. package/lib/rules/no-compare-neg-zero.js +1 -1
  105. package/lib/rules/no-cond-assign.js +2 -2
  106. package/lib/rules/no-confusing-arrow.js +2 -2
  107. package/lib/rules/no-console.js +2 -2
  108. package/lib/rules/no-const-assign.js +2 -2
  109. package/lib/rules/no-constant-binary-expression.js +2 -2
  110. package/lib/rules/no-constant-condition.js +2 -2
  111. package/lib/rules/no-constructor-return.js +1 -1
  112. package/lib/rules/no-continue.js +1 -1
  113. package/lib/rules/no-control-regex.js +16 -3
  114. package/lib/rules/no-debugger.js +1 -1
  115. package/lib/rules/no-delete-var.js +1 -1
  116. package/lib/rules/no-div-regex.js +2 -2
  117. package/lib/rules/no-dupe-args.js +2 -2
  118. package/lib/rules/no-dupe-class-members.js +1 -1
  119. package/lib/rules/no-dupe-else-if.js +2 -2
  120. package/lib/rules/no-dupe-keys.js +1 -1
  121. package/lib/rules/no-duplicate-case.js +2 -2
  122. package/lib/rules/no-duplicate-imports.js +1 -1
  123. package/lib/rules/no-else-return.js +2 -2
  124. package/lib/rules/no-empty-character-class.js +34 -13
  125. package/lib/rules/no-empty-function.js +2 -2
  126. package/lib/rules/no-empty-pattern.js +39 -4
  127. package/lib/rules/no-empty-static-block.js +2 -2
  128. package/lib/rules/no-empty.js +2 -2
  129. package/lib/rules/no-eq-null.js +1 -1
  130. package/lib/rules/no-eval.js +2 -2
  131. package/lib/rules/no-ex-assign.js +2 -2
  132. package/lib/rules/no-extend-native.js +2 -2
  133. package/lib/rules/no-extra-bind.js +2 -2
  134. package/lib/rules/no-extra-boolean-cast.js +2 -2
  135. package/lib/rules/no-extra-label.js +2 -2
  136. package/lib/rules/no-extra-parens.js +48 -12
  137. package/lib/rules/no-extra-semi.js +31 -13
  138. package/lib/rules/no-fallthrough.js +3 -3
  139. package/lib/rules/no-floating-decimal.js +2 -2
  140. package/lib/rules/no-func-assign.js +2 -2
  141. package/lib/rules/no-global-assign.js +2 -2
  142. package/lib/rules/no-implicit-coercion.js +2 -2
  143. package/lib/rules/no-implicit-globals.js +2 -2
  144. package/lib/rules/no-implied-eval.js +2 -2
  145. package/lib/rules/no-import-assign.js +2 -2
  146. package/lib/rules/no-inline-comments.js +2 -2
  147. package/lib/rules/no-inner-declarations.js +1 -1
  148. package/lib/rules/no-invalid-regexp.js +23 -8
  149. package/lib/rules/no-invalid-this.js +2 -2
  150. package/lib/rules/no-irregular-whitespace.js +23 -6
  151. package/lib/rules/no-iterator.js +1 -1
  152. package/lib/rules/no-label-var.js +2 -2
  153. package/lib/rules/no-labels.js +1 -1
  154. package/lib/rules/no-lone-blocks.js +2 -2
  155. package/lib/rules/no-lonely-if.js +2 -2
  156. package/lib/rules/no-loop-func.js +3 -3
  157. package/lib/rules/no-loss-of-precision.js +15 -7
  158. package/lib/rules/no-magic-numbers.js +1 -1
  159. package/lib/rules/no-misleading-character-class.js +10 -4
  160. package/lib/rules/no-mixed-operators.js +2 -2
  161. package/lib/rules/no-mixed-requires.js +1 -1
  162. package/lib/rules/no-mixed-spaces-and-tabs.js +2 -2
  163. package/lib/rules/no-multi-assign.js +1 -1
  164. package/lib/rules/no-multi-spaces.js +2 -2
  165. package/lib/rules/no-multi-str.js +1 -1
  166. package/lib/rules/no-multiple-empty-lines.js +2 -2
  167. package/lib/rules/no-native-reassign.js +2 -2
  168. package/lib/rules/no-negated-condition.js +1 -1
  169. package/lib/rules/no-negated-in-lhs.js +1 -1
  170. package/lib/rules/no-nested-ternary.js +1 -1
  171. package/lib/rules/no-new-func.js +2 -2
  172. package/lib/rules/no-new-native-nonconstructor.js +2 -2
  173. package/lib/rules/no-new-object.js +2 -2
  174. package/lib/rules/no-new-require.js +1 -1
  175. package/lib/rules/no-new-symbol.js +2 -2
  176. package/lib/rules/no-new-wrappers.js +20 -8
  177. package/lib/rules/no-new.js +1 -1
  178. package/lib/rules/no-nonoctal-decimal-escape.js +2 -2
  179. package/lib/rules/no-obj-calls.js +2 -2
  180. package/lib/rules/no-octal-escape.js +1 -1
  181. package/lib/rules/no-octal.js +1 -1
  182. package/lib/rules/no-param-reassign.js +2 -2
  183. package/lib/rules/no-path-concat.js +1 -1
  184. package/lib/rules/no-plusplus.js +1 -1
  185. package/lib/rules/no-process-env.js +1 -1
  186. package/lib/rules/no-process-exit.js +1 -1
  187. package/lib/rules/no-promise-executor-return.js +2 -2
  188. package/lib/rules/no-proto.js +1 -1
  189. package/lib/rules/no-prototype-builtins.js +1 -1
  190. package/lib/rules/no-redeclare.js +2 -2
  191. package/lib/rules/no-regex-spaces.js +20 -5
  192. package/lib/rules/no-restricted-exports.js +2 -2
  193. package/lib/rules/no-restricted-globals.js +2 -2
  194. package/lib/rules/no-restricted-imports.js +2 -2
  195. package/lib/rules/no-restricted-modules.js +8 -11
  196. package/lib/rules/no-restricted-properties.js +1 -1
  197. package/lib/rules/no-restricted-syntax.js +1 -1
  198. package/lib/rules/no-return-assign.js +2 -2
  199. package/lib/rules/no-return-await.js +8 -3
  200. package/lib/rules/no-script-url.js +1 -1
  201. package/lib/rules/no-self-assign.js +2 -2
  202. package/lib/rules/no-self-compare.js +2 -2
  203. package/lib/rules/no-sequences.js +2 -2
  204. package/lib/rules/no-setter-return.js +2 -2
  205. package/lib/rules/no-shadow-restricted-names.js +2 -2
  206. package/lib/rules/no-shadow.js +2 -2
  207. package/lib/rules/no-spaced-func.js +2 -2
  208. package/lib/rules/no-sparse-arrays.js +1 -1
  209. package/lib/rules/no-sync.js +1 -1
  210. package/lib/rules/no-tabs.js +2 -2
  211. package/lib/rules/no-template-curly-in-string.js +1 -1
  212. package/lib/rules/no-ternary.js +1 -1
  213. package/lib/rules/no-this-before-super.js +1 -1
  214. package/lib/rules/no-throw-literal.js +1 -1
  215. package/lib/rules/no-trailing-spaces.js +2 -2
  216. package/lib/rules/no-undef-init.js +2 -2
  217. package/lib/rules/no-undef.js +2 -2
  218. package/lib/rules/no-undefined.js +2 -2
  219. package/lib/rules/no-underscore-dangle.js +2 -2
  220. package/lib/rules/no-unexpected-multiline.js +2 -2
  221. package/lib/rules/no-unmodified-loop-condition.js +2 -2
  222. package/lib/rules/no-unneeded-ternary.js +2 -2
  223. package/lib/rules/no-unreachable-loop.js +1 -1
  224. package/lib/rules/no-unreachable.js +2 -2
  225. package/lib/rules/no-unsafe-finally.js +1 -1
  226. package/lib/rules/no-unsafe-negation.js +2 -2
  227. package/lib/rules/no-unsafe-optional-chaining.js +1 -1
  228. package/lib/rules/no-unused-expressions.js +4 -6
  229. package/lib/rules/no-unused-labels.js +48 -15
  230. package/lib/rules/no-unused-private-class-members.js +1 -1
  231. package/lib/rules/no-unused-vars.js +4 -3
  232. package/lib/rules/no-use-before-define.js +2 -2
  233. package/lib/rules/no-useless-backreference.js +3 -3
  234. package/lib/rules/no-useless-call.js +2 -2
  235. package/lib/rules/no-useless-catch.js +1 -1
  236. package/lib/rules/no-useless-computed-key.js +2 -2
  237. package/lib/rules/no-useless-concat.js +2 -2
  238. package/lib/rules/no-useless-constructor.js +1 -1
  239. package/lib/rules/no-useless-escape.js +162 -83
  240. package/lib/rules/no-useless-rename.js +2 -2
  241. package/lib/rules/no-useless-return.js +37 -9
  242. package/lib/rules/no-var.js +2 -2
  243. package/lib/rules/no-void.js +1 -1
  244. package/lib/rules/no-warning-comments.js +2 -2
  245. package/lib/rules/no-whitespace-before-property.js +2 -2
  246. package/lib/rules/no-with.js +1 -1
  247. package/lib/rules/nonblock-statement-body-position.js +2 -2
  248. package/lib/rules/object-curly-newline.js +2 -2
  249. package/lib/rules/object-curly-spacing.js +4 -4
  250. package/lib/rules/object-property-newline.js +2 -2
  251. package/lib/rules/object-shorthand.js +2 -2
  252. package/lib/rules/one-var-declaration-per-line.js +1 -1
  253. package/lib/rules/one-var.js +2 -2
  254. package/lib/rules/operator-assignment.js +2 -2
  255. package/lib/rules/operator-linebreak.js +2 -2
  256. package/lib/rules/padded-blocks.js +2 -2
  257. package/lib/rules/padding-line-between-statements.js +8 -53
  258. package/lib/rules/prefer-arrow-callback.js +2 -2
  259. package/lib/rules/prefer-const.js +2 -2
  260. package/lib/rules/prefer-destructuring.js +2 -2
  261. package/lib/rules/prefer-exponentiation-operator.js +4 -3
  262. package/lib/rules/prefer-named-capture-group.js +10 -7
  263. package/lib/rules/prefer-numeric-literals.js +2 -2
  264. package/lib/rules/prefer-object-has-own.js +2 -2
  265. package/lib/rules/prefer-object-spread.js +2 -2
  266. package/lib/rules/prefer-promise-reject-errors.js +2 -2
  267. package/lib/rules/prefer-reflect.js +1 -1
  268. package/lib/rules/prefer-regex-literals.js +14 -17
  269. package/lib/rules/prefer-rest-params.js +2 -2
  270. package/lib/rules/prefer-spread.js +2 -2
  271. package/lib/rules/prefer-template.js +2 -2
  272. package/lib/rules/quote-props.js +2 -2
  273. package/lib/rules/quotes.js +16 -16
  274. package/lib/rules/radix.js +2 -2
  275. package/lib/rules/require-atomic-updates.js +2 -2
  276. package/lib/rules/require-await.js +2 -2
  277. package/lib/rules/require-jsdoc.js +2 -2
  278. package/lib/rules/require-unicode-regexp.js +5 -5
  279. package/lib/rules/require-yield.js +1 -1
  280. package/lib/rules/rest-spread-spacing.js +2 -2
  281. package/lib/rules/semi-spacing.js +2 -2
  282. package/lib/rules/semi-style.js +2 -2
  283. package/lib/rules/semi.js +30 -5
  284. package/lib/rules/sort-imports.js +2 -2
  285. package/lib/rules/sort-keys.js +2 -2
  286. package/lib/rules/sort-vars.js +2 -2
  287. package/lib/rules/space-before-blocks.js +2 -2
  288. package/lib/rules/space-before-function-paren.js +2 -2
  289. package/lib/rules/space-in-parens.js +2 -2
  290. package/lib/rules/space-infix-ops.js +2 -2
  291. package/lib/rules/space-unary-ops.js +2 -2
  292. package/lib/rules/spaced-comment.js +2 -2
  293. package/lib/rules/strict.js +1 -1
  294. package/lib/rules/switch-colon-spacing.js +2 -2
  295. package/lib/rules/symbol-description.js +2 -2
  296. package/lib/rules/template-curly-spacing.js +2 -2
  297. package/lib/rules/template-tag-spacing.js +2 -2
  298. package/lib/rules/unicode-bom.js +2 -2
  299. package/lib/rules/use-isnan.js +1 -1
  300. package/lib/rules/utils/ast-utils.js +55 -7
  301. package/lib/rules/utils/regular-expressions.js +2 -2
  302. package/lib/rules/valid-jsdoc.js +2 -2
  303. package/lib/rules/valid-typeof.js +9 -3
  304. package/lib/rules/vars-on-top.js +1 -1
  305. package/lib/rules/wrap-iife.js +2 -2
  306. package/lib/rules/wrap-regex.js +2 -2
  307. package/lib/rules/yield-star-spacing.js +2 -2
  308. package/lib/rules/yoda.js +4 -13
  309. package/lib/shared/string-utils.js +39 -1
  310. package/lib/shared/types.js +7 -3
  311. package/lib/unsupported-api.js +5 -2
  312. package/messages/eslintrc-incompat.js +98 -0
  313. package/messages/eslintrc-plugins.js +24 -0
  314. package/messages/invalid-rule-options.js +17 -0
  315. package/messages/invalid-rule-severity.js +13 -0
  316. package/messages/shared.js +18 -0
  317. package/package.json +15 -19
@@ -23,7 +23,7 @@ module.exports = {
23
23
  docs: {
24
24
  description: "Enforce valid JSDoc comments",
25
25
  recommended: false,
26
- url: "https://eslint.org/docs/rules/valid-jsdoc"
26
+ url: "https://eslint.org/docs/latest/rules/valid-jsdoc"
27
27
  },
28
28
 
29
29
  schema: [
@@ -96,7 +96,7 @@ module.exports = {
96
96
 
97
97
  const options = context.options[0] || {},
98
98
  prefer = options.prefer || {},
99
- sourceCode = context.getSourceCode(),
99
+ sourceCode = context.sourceCode,
100
100
 
101
101
  // these both default to true, so you have to explicitly make them false
102
102
  requireReturn = options.requireReturn !== false,
@@ -4,6 +4,12 @@
4
4
  */
5
5
  "use strict";
6
6
 
7
+ //------------------------------------------------------------------------------
8
+ // Requirements
9
+ //------------------------------------------------------------------------------
10
+
11
+ const astUtils = require("./utils/ast-utils");
12
+
7
13
  //------------------------------------------------------------------------------
8
14
  // Rule Definition
9
15
  //------------------------------------------------------------------------------
@@ -16,7 +22,7 @@ module.exports = {
16
22
  docs: {
17
23
  description: "Enforce comparing `typeof` expressions against valid strings",
18
24
  recommended: true,
19
- url: "https://eslint.org/docs/rules/valid-typeof"
25
+ url: "https://eslint.org/docs/latest/rules/valid-typeof"
20
26
  },
21
27
 
22
28
  hasSuggestions: true,
@@ -44,7 +50,7 @@ module.exports = {
44
50
 
45
51
  const VALID_TYPES = new Set(["symbol", "undefined", "object", "boolean", "number", "string", "function", "bigint"]),
46
52
  OPERATORS = new Set(["==", "===", "!=", "!=="]);
47
- const sourceCode = context.getSourceCode();
53
+ const sourceCode = context.sourceCode;
48
54
  const requireStringLiterals = context.options[0] && context.options[0].requireStringLiterals;
49
55
 
50
56
  let globalScope;
@@ -88,7 +94,7 @@ module.exports = {
88
94
  if (parent.type === "BinaryExpression" && OPERATORS.has(parent.operator)) {
89
95
  const sibling = parent.left === node ? parent.right : parent.left;
90
96
 
91
- if (sibling.type === "Literal" || sibling.type === "TemplateLiteral" && !sibling.expressions.length) {
97
+ if (sibling.type === "Literal" || astUtils.isStaticTemplateLiteral(sibling)) {
92
98
  const value = sibling.type === "Literal" ? sibling.value : sibling.quasis[0].value.cooked;
93
99
 
94
100
  if (!VALID_TYPES.has(value)) {
@@ -17,7 +17,7 @@ module.exports = {
17
17
  docs: {
18
18
  description: "Require `var` declarations be placed at the top of their containing scope",
19
19
  recommended: false,
20
- url: "https://eslint.org/docs/rules/vars-on-top"
20
+ url: "https://eslint.org/docs/latest/rules/vars-on-top"
21
21
  },
22
22
 
23
23
  schema: [],
@@ -45,7 +45,7 @@ module.exports = {
45
45
  docs: {
46
46
  description: "Require parentheses around immediate `function` invocations",
47
47
  recommended: false,
48
- url: "https://eslint.org/docs/rules/wrap-iife"
48
+ url: "https://eslint.org/docs/latest/rules/wrap-iife"
49
49
  },
50
50
 
51
51
  schema: [
@@ -77,7 +77,7 @@ module.exports = {
77
77
  const style = context.options[0] || "outside";
78
78
  const includeFunctionPrototypeMethods = context.options[1] && context.options[1].functionPrototypeMethods;
79
79
 
80
- const sourceCode = context.getSourceCode();
80
+ const sourceCode = context.sourceCode;
81
81
 
82
82
  /**
83
83
  * Check if the node is wrapped in any (). All parens count: grouping parens and parens for constructs such as if()
@@ -17,7 +17,7 @@ module.exports = {
17
17
  docs: {
18
18
  description: "Require parenthesis around regex literals",
19
19
  recommended: false,
20
- url: "https://eslint.org/docs/rules/wrap-regex"
20
+ url: "https://eslint.org/docs/latest/rules/wrap-regex"
21
21
  },
22
22
 
23
23
  schema: [],
@@ -29,7 +29,7 @@ module.exports = {
29
29
  },
30
30
 
31
31
  create(context) {
32
- const sourceCode = context.getSourceCode();
32
+ const sourceCode = context.sourceCode;
33
33
 
34
34
  return {
35
35
 
@@ -17,7 +17,7 @@ module.exports = {
17
17
  docs: {
18
18
  description: "Require or disallow spacing around the `*` in `yield*` expressions",
19
19
  recommended: false,
20
- url: "https://eslint.org/docs/rules/yield-star-spacing"
20
+ url: "https://eslint.org/docs/latest/rules/yield-star-spacing"
21
21
  },
22
22
 
23
23
  fixable: "whitespace",
@@ -48,7 +48,7 @@ module.exports = {
48
48
  },
49
49
 
50
50
  create(context) {
51
- const sourceCode = context.getSourceCode();
51
+ const sourceCode = context.sourceCode;
52
52
 
53
53
  const mode = (function(option) {
54
54
  if (!option || typeof option === "string") {
package/lib/rules/yoda.js CHANGED
@@ -58,22 +58,13 @@ function isNegativeNumericLiteral(node) {
58
58
  );
59
59
  }
60
60
 
61
- /**
62
- * Determines whether a node is a Template Literal which can be determined statically.
63
- * @param {ASTNode} node Node to test
64
- * @returns {boolean} True if the node is a Template Literal without expression.
65
- */
66
- function isStaticTemplateLiteral(node) {
67
- return node.type === "TemplateLiteral" && node.expressions.length === 0;
68
- }
69
-
70
61
  /**
71
62
  * Determines whether a non-Literal node should be treated as a single Literal node.
72
63
  * @param {ASTNode} node Node to test
73
64
  * @returns {boolean} True if the node should be treated as a single Literal node.
74
65
  */
75
66
  function looksLikeLiteral(node) {
76
- return isNegativeNumericLiteral(node) || isStaticTemplateLiteral(node);
67
+ return isNegativeNumericLiteral(node) || astUtils.isStaticTemplateLiteral(node);
77
68
  }
78
69
 
79
70
  /**
@@ -100,7 +91,7 @@ function getNormalizedLiteral(node) {
100
91
  };
101
92
  }
102
93
 
103
- if (isStaticTemplateLiteral(node)) {
94
+ if (astUtils.isStaticTemplateLiteral(node)) {
104
95
  return {
105
96
  type: "Literal",
106
97
  value: node.quasis[0].value.cooked,
@@ -123,7 +114,7 @@ module.exports = {
123
114
  docs: {
124
115
  description: 'Require or disallow "Yoda" conditions',
125
116
  recommended: false,
126
- url: "https://eslint.org/docs/rules/yoda"
117
+ url: "https://eslint.org/docs/latest/rules/yoda"
127
118
  },
128
119
 
129
120
  schema: [
@@ -162,7 +153,7 @@ module.exports = {
162
153
  const onlyEquality =
163
154
  context.options[1] && context.options[1].onlyEquality;
164
155
 
165
- const sourceCode = context.getSourceCode();
156
+ const sourceCode = context.sourceCode;
166
157
 
167
158
  /**
168
159
  * Determines whether node represents a range test.
@@ -5,6 +5,26 @@
5
5
 
6
6
  "use strict";
7
7
 
8
+ //------------------------------------------------------------------------------
9
+ // Requirements
10
+ //------------------------------------------------------------------------------
11
+
12
+ const Graphemer = require("graphemer").default;
13
+
14
+ //------------------------------------------------------------------------------
15
+ // Helpers
16
+ //------------------------------------------------------------------------------
17
+
18
+ // eslint-disable-next-line no-control-regex -- intentionally including control characters
19
+ const ASCII_REGEX = /^[\u0000-\u007f]*$/u;
20
+
21
+ /** @type {Graphemer | undefined} */
22
+ let splitter;
23
+
24
+ //------------------------------------------------------------------------------
25
+ // Public Interface
26
+ //------------------------------------------------------------------------------
27
+
8
28
  /**
9
29
  * Converts the first letter of a string to uppercase.
10
30
  * @param {string} string The string to operate on
@@ -17,6 +37,24 @@ function upperCaseFirst(string) {
17
37
  return string[0].toUpperCase() + string.slice(1);
18
38
  }
19
39
 
40
+ /**
41
+ * Counts graphemes in a given string.
42
+ * @param {string} value A string to count graphemes.
43
+ * @returns {number} The number of graphemes in `value`.
44
+ */
45
+ function getGraphemeCount(value) {
46
+ if (ASCII_REGEX.test(value)) {
47
+ return value.length;
48
+ }
49
+
50
+ if (!splitter) {
51
+ splitter = new Graphemer();
52
+ }
53
+
54
+ return splitter.countGraphemes(value);
55
+ }
56
+
20
57
  module.exports = {
21
- upperCaseFirst
58
+ upperCaseFirst,
59
+ getGraphemeCount
22
60
  };
@@ -21,7 +21,7 @@ module.exports = {};
21
21
  /**
22
22
  * @typedef {Object} ParserOptions
23
23
  * @property {EcmaFeatures} [ecmaFeatures] The optional features.
24
- * @property {3|5|6|7|8|9|10|11|12|13|14|2015|2016|2017|2018|2019|2020|2021|2022|2023} [ecmaVersion] The ECMAScript version (or revision number).
24
+ * @property {3|5|6|7|8|9|10|11|12|13|14|15|2015|2016|2017|2018|2019|2020|2021|2022|2023|2024} [ecmaVersion] The ECMAScript version (or revision number).
25
25
  * @property {"script"|"module"} [sourceType] The source code type.
26
26
  * @property {boolean} [allowReserved] Allowing the use of reserved words as identifiers in ES3.
27
27
  */
@@ -96,10 +96,12 @@ module.exports = {};
96
96
  * @property {number|undefined} column The 1-based column number.
97
97
  * @property {number} [endColumn] The 1-based column number of the end location.
98
98
  * @property {number} [endLine] The 1-based line number of the end location.
99
- * @property {boolean} fatal If `true` then this is a fatal error.
99
+ * @property {boolean} [fatal] If `true` then this is a fatal error.
100
100
  * @property {{range:[number,number], text:string}} [fix] Information for autofix.
101
101
  * @property {number|undefined} line The 1-based line number.
102
102
  * @property {string} message The error message.
103
+ * @property {string} [messageId] The ID of the message in the rule's meta.
104
+ * @property {(string|null)} nodeType Type of node
103
105
  * @property {string|null} ruleId The ID of the rule which makes this message.
104
106
  * @property {0|1|2} severity The severity of this message.
105
107
  * @property {Array<{desc?: string, messageId?: string, fix: {range: [number, number], text: string}}>} [suggestions] Information for suggestions.
@@ -110,10 +112,12 @@ module.exports = {};
110
112
  * @property {number|undefined} column The 1-based column number.
111
113
  * @property {number} [endColumn] The 1-based column number of the end location.
112
114
  * @property {number} [endLine] The 1-based line number of the end location.
113
- * @property {boolean} fatal If `true` then this is a fatal error.
115
+ * @property {boolean} [fatal] If `true` then this is a fatal error.
114
116
  * @property {{range:[number,number], text:string}} [fix] Information for autofix.
115
117
  * @property {number|undefined} line The 1-based line number.
116
118
  * @property {string} message The error message.
119
+ * @property {string} [messageId] The ID of the message in the rule's meta.
120
+ * @property {(string|null)} nodeType Type of node
117
121
  * @property {string|null} ruleId The ID of the rule which makes this message.
118
122
  * @property {0|1|2} severity The severity of this message.
119
123
  * @property {Array<{kind: string, justification: string}>} suppressions The suppression info.
@@ -12,8 +12,9 @@
12
12
  //-----------------------------------------------------------------------------
13
13
 
14
14
  const { FileEnumerator } = require("./cli-engine/file-enumerator");
15
- const { FlatESLint } = require("./eslint/flat-eslint");
15
+ const { FlatESLint, shouldUseFlatConfig } = require("./eslint/flat-eslint");
16
16
  const FlatRuleTester = require("./rule-tester/flat-rule-tester");
17
+ const { ESLint } = require("./eslint/eslint");
17
18
 
18
19
  //-----------------------------------------------------------------------------
19
20
  // Exports
@@ -22,6 +23,8 @@ const FlatRuleTester = require("./rule-tester/flat-rule-tester");
22
23
  module.exports = {
23
24
  builtinRules: require("./rules"),
24
25
  FlatESLint,
26
+ shouldUseFlatConfig,
25
27
  FlatRuleTester,
26
- FileEnumerator
28
+ FileEnumerator,
29
+ LegacyESLint: ESLint
27
30
  };
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+
3
+ /* eslint consistent-return: 0 -- no default case */
4
+
5
+ const messages = {
6
+
7
+ env: `
8
+ A config object is using the "env" key, which is not supported in flat config system.
9
+
10
+ Flat config uses "languageOptions.globals" to define global variables for your files.
11
+
12
+ Please see the following page for information on how to convert your config object into the correct format:
13
+ https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options
14
+ `,
15
+
16
+ extends: `
17
+ A config object is using the "extends" key, which is not supported in flat config system.
18
+
19
+ Instead of "extends", you can include config objects that you'd like to extend from directly in the flat config array.
20
+
21
+ Please see the following page for more information:
22
+ https://eslint.org/docs/latest/use/configure/migration-guide#predefined-configs
23
+ `,
24
+
25
+ globals: `
26
+ A config object is using the "globals" key, which is not supported in flat config system.
27
+
28
+ Flat config uses "languageOptions.globals" to define global variables for your files.
29
+
30
+ Please see the following page for information on how to convert your config object into the correct format:
31
+ https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options
32
+ `,
33
+
34
+ ignorePatterns: `
35
+ A config object is using the "ignorePatterns" key, which is not supported in flat config system.
36
+
37
+ Flat config uses "ignores" to specify files to ignore.
38
+
39
+ Please see the following page for information on how to convert your config object into the correct format:
40
+ https://eslint.org/docs/latest/use/configure/migration-guide#ignoring-files
41
+ `,
42
+
43
+ noInlineConfig: `
44
+ A config object is using the "noInlineConfig" key, which is not supported in flat config system.
45
+
46
+ Flat config uses "linterOptions.noInlineConfig" to specify files to ignore.
47
+
48
+ Please see the following page for information on how to convert your config object into the correct format:
49
+ https://eslint.org/docs/latest/use/configure/migration-guide#linter-options
50
+ `,
51
+
52
+ overrides: `
53
+ A config object is using the "overrides" key, which is not supported in flat config system.
54
+
55
+ Flat config is an array that acts like the eslintrc "overrides" array.
56
+
57
+ Please see the following page for information on how to convert your config object into the correct format:
58
+ https://eslint.org/docs/latest/use/configure/migration-guide#glob-based-configs
59
+ `,
60
+
61
+ parser: `
62
+ A config object is using the "parser" key, which is not supported in flat config system.
63
+
64
+ Flat config uses "languageOptions.parser" to override the default parser.
65
+
66
+ Please see the following page for information on how to convert your config object into the correct format:
67
+ https://eslint.org/docs/latest/use/configure/migration-guide#custom-parsers
68
+ `,
69
+
70
+ parserOptions: `
71
+ A config object is using the "parserOptions" key, which is not supported in flat config system.
72
+
73
+ Flat config uses "languageOptions.parserOptions" to specify parser options.
74
+
75
+ Please see the following page for information on how to convert your config object into the correct format:
76
+ https://eslint.org/docs/latest/use/configure/migration-guide#configuring-language-options
77
+ `,
78
+
79
+ reportUnusedDisableDirectives: `
80
+ A config object is using the "reportUnusedDisableDirectives" key, which is not supported in flat config system.
81
+
82
+ Flat config uses "linterOptions.reportUnusedDisableDirectives" to specify files to ignore.
83
+
84
+ Please see the following page for information on how to convert your config object into the correct format:
85
+ https://eslint.org/docs/latest/use/configure/migration-guide#linter-options
86
+ `,
87
+
88
+ root: `
89
+ A config object is using the "root" key, which is not supported in flat config system.
90
+
91
+ Flat configs always act as if they are the root config file, so this key can be safely removed.
92
+ `
93
+ };
94
+
95
+ module.exports = function({ key }) {
96
+
97
+ return messages[key].trim();
98
+ };
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+
3
+ module.exports = function({ plugins }) {
4
+
5
+ const isArrayOfStrings = typeof plugins[0] === "string";
6
+
7
+ return `
8
+ A config object has a "plugins" key defined as an array${isArrayOfStrings ? " of strings" : ""}.
9
+
10
+ Flat config requires "plugins" to be an object in this form:
11
+
12
+ {
13
+ plugins: {
14
+ ${isArrayOfStrings && plugins[0] ? plugins[0] : "namespace"}: pluginObject
15
+ }
16
+ }
17
+
18
+ Please see the following page for information on how to convert your config object into the correct format:
19
+ https://eslint.org/docs/latest/use/configure/migration-guide#importing-plugins-and-custom-parsers
20
+
21
+ If you're using a shareable config that you cannot rewrite in flat config format, then use the compatibility utility:
22
+ https://eslint.org/docs/latest/use/configure/migration-guide#using-eslintrc-configs-in-flat-config
23
+ `;
24
+ };
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ const { stringifyValueForError } = require("./shared");
4
+
5
+ module.exports = function({ ruleId, value }) {
6
+ return `
7
+ Configuration for rule "${ruleId}" is invalid. Each rule must have a severity ("off", 0, "warn", 1, "error", or 2) and may be followed by additional options for the rule.
8
+
9
+ You passed '${stringifyValueForError(value, 4)}', which doesn't contain a valid severity.
10
+
11
+ If you're attempting to configure rule options, perhaps you meant:
12
+
13
+ "${ruleId}": ["error", ${stringifyValueForError(value, 8)}]
14
+
15
+ See https://eslint.org/docs/latest/use/configure/rules#using-configuration-files for configuring rules.
16
+ `.trimStart();
17
+ };
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ const { stringifyValueForError } = require("./shared");
4
+
5
+ module.exports = function({ ruleId, value }) {
6
+ return `
7
+ Configuration for rule "${ruleId}" is invalid. Expected severity of "off", 0, "warn", 1, "error", or 2.
8
+
9
+ You passed '${stringifyValueForError(value, 4)}'.
10
+
11
+ See https://eslint.org/docs/latest/use/configure/rules#using-configuration-files for configuring rules.
12
+ `.trimStart();
13
+ };
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @fileoverview Shared utilities for error messages.
3
+ * @author Josh Goldberg
4
+ */
5
+
6
+ "use strict";
7
+
8
+ /**
9
+ * Converts a value to a string that may be printed in errors.
10
+ * @param {any} value The invalid value.
11
+ * @param {number} indentation How many spaces to indent
12
+ * @returns {string} The value, stringified.
13
+ */
14
+ function stringifyValueForError(value, indentation) {
15
+ return value ? JSON.stringify(value, null, 4).replace(/\n/gu, `\n${" ".repeat(indentation)}`) : `${value}`;
16
+ }
17
+
18
+ module.exports = { stringifyValueForError };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eslint",
3
- "version": "8.39.0",
3
+ "version": "8.47.0",
4
4
  "author": "Nicholas C. Zakas <nicholas+npm@nczconsulting.com>",
5
5
  "description": "An AST-based pattern checker for JavaScript.",
6
6
  "bin": {
@@ -61,21 +61,21 @@
61
61
  "bugs": "https://github.com/eslint/eslint/issues/",
62
62
  "dependencies": {
63
63
  "@eslint-community/eslint-utils": "^4.2.0",
64
- "@eslint-community/regexpp": "^4.4.0",
65
- "@eslint/eslintrc": "^2.0.2",
66
- "@eslint/js": "8.39.0",
67
- "@humanwhocodes/config-array": "^0.11.8",
64
+ "@eslint-community/regexpp": "^4.6.1",
65
+ "@eslint/eslintrc": "^2.1.2",
66
+ "@eslint/js": "^8.47.0",
67
+ "@humanwhocodes/config-array": "^0.11.10",
68
68
  "@humanwhocodes/module-importer": "^1.0.1",
69
69
  "@nodelib/fs.walk": "^1.2.8",
70
- "ajv": "^6.10.0",
70
+ "ajv": "^6.12.4",
71
71
  "chalk": "^4.0.0",
72
72
  "cross-spawn": "^7.0.2",
73
73
  "debug": "^4.3.2",
74
74
  "doctrine": "^3.0.0",
75
75
  "escape-string-regexp": "^4.0.0",
76
- "eslint-scope": "^7.2.0",
77
- "eslint-visitor-keys": "^3.4.0",
78
- "espree": "^9.5.1",
76
+ "eslint-scope": "^7.2.2",
77
+ "eslint-visitor-keys": "^3.4.3",
78
+ "espree": "^9.6.1",
79
79
  "esquery": "^1.4.2",
80
80
  "esutils": "^2.0.2",
81
81
  "fast-deep-equal": "^3.1.3",
@@ -83,22 +83,19 @@
83
83
  "find-up": "^5.0.0",
84
84
  "glob-parent": "^6.0.2",
85
85
  "globals": "^13.19.0",
86
- "grapheme-splitter": "^1.0.4",
86
+ "graphemer": "^1.4.0",
87
87
  "ignore": "^5.2.0",
88
- "import-fresh": "^3.0.0",
89
88
  "imurmurhash": "^0.1.4",
90
89
  "is-glob": "^4.0.0",
91
90
  "is-path-inside": "^3.0.3",
92
- "js-sdsl": "^4.1.4",
93
91
  "js-yaml": "^4.1.0",
94
92
  "json-stable-stringify-without-jsonify": "^1.0.1",
95
93
  "levn": "^0.4.1",
96
94
  "lodash.merge": "^4.6.2",
97
95
  "minimatch": "^3.1.2",
98
96
  "natural-compare": "^1.4.0",
99
- "optionator": "^0.9.1",
97
+ "optionator": "^0.9.3",
100
98
  "strip-ansi": "^6.0.1",
101
- "strip-json-comments": "^3.1.0",
102
99
  "text-table": "^0.2.0"
103
100
  },
104
101
  "devDependencies": {
@@ -114,10 +111,10 @@
114
111
  "eslint": "file:.",
115
112
  "eslint-config-eslint": "file:packages/eslint-config-eslint",
116
113
  "eslint-plugin-eslint-comments": "^3.2.0",
117
- "eslint-plugin-eslint-plugin": "^4.4.0",
114
+ "eslint-plugin-eslint-plugin": "^5.1.0",
118
115
  "eslint-plugin-internal-rules": "file:tools/internal-rules",
119
- "eslint-plugin-jsdoc": "^38.1.6",
120
- "eslint-plugin-n": "^15.2.4",
116
+ "eslint-plugin-jsdoc": "^46.2.5",
117
+ "eslint-plugin-n": "^16.0.0",
121
118
  "eslint-plugin-unicorn": "^42.0.0",
122
119
  "eslint-release": "^3.2.0",
123
120
  "eslump": "^3.0.0",
@@ -154,10 +151,9 @@
154
151
  "puppeteer": "^13.7.0",
155
152
  "recast": "^0.20.4",
156
153
  "regenerator-runtime": "^0.13.2",
157
- "semver": "^7.3.5",
154
+ "semver": "^7.5.3",
158
155
  "shelljs": "^0.8.2",
159
156
  "sinon": "^11.0.0",
160
- "temp": "^0.9.0",
161
157
  "webpack": "^5.23.0",
162
158
  "webpack-cli": "^4.5.0",
163
159
  "yorkie": "^2.0.0"