oxlint-plugin-eslint 1.52.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 (305) hide show
  1. package/LICENSE +22 -0
  2. package/README.md +36 -0
  3. package/common/ast-utils.cjs +5843 -0
  4. package/common/chunk.cjs +9 -0
  5. package/common/eslint-utils.cjs +1633 -0
  6. package/common/fix-tracker.cjs +89 -0
  7. package/common/ignore.cjs +123 -0
  8. package/common/keywords.cjs +15 -0
  9. package/common/regexpp.cjs +1720 -0
  10. package/common/regular-expressions.cjs +40 -0
  11. package/common/string-utils.cjs +39 -0
  12. package/index.js +7477 -0
  13. package/package.json +34 -0
  14. package/rules/accessor-pairs.cjs +233 -0
  15. package/rules/array-bracket-newline.cjs +172 -0
  16. package/rules/array-bracket-spacing.cjs +184 -0
  17. package/rules/array-callback-return.cjs +262 -0
  18. package/rules/array-element-newline.cjs +178 -0
  19. package/rules/arrow-body-style.cjs +135 -0
  20. package/rules/arrow-parens.cjs +130 -0
  21. package/rules/arrow-spacing.cjs +129 -0
  22. package/rules/block-scoped-var.cjs +101 -0
  23. package/rules/block-spacing.cjs +125 -0
  24. package/rules/brace-style.cjs +141 -0
  25. package/rules/callback-return.cjs +117 -0
  26. package/rules/camelcase.cjs +194 -0
  27. package/rules/capitalized-comments.cjs +168 -0
  28. package/rules/class-methods-use-this.cjs +155 -0
  29. package/rules/comma-dangle.cjs +274 -0
  30. package/rules/comma-spacing.cjs +111 -0
  31. package/rules/comma-style.cjs +180 -0
  32. package/rules/complexity.cjs +100 -0
  33. package/rules/computed-property-spacing.cjs +155 -0
  34. package/rules/consistent-return.cjs +113 -0
  35. package/rules/consistent-this.cjs +109 -0
  36. package/rules/constructor-super.cjs +207 -0
  37. package/rules/curly.cjs +173 -0
  38. package/rules/default-case-last.cjs +36 -0
  39. package/rules/default-case.cjs +50 -0
  40. package/rules/default-param-last.cjs +61 -0
  41. package/rules/dot-location.cjs +87 -0
  42. package/rules/dot-notation.cjs +77 -0
  43. package/rules/eol-last.cjs +91 -0
  44. package/rules/eqeqeq.cjs +127 -0
  45. package/rules/for-direction.cjs +94 -0
  46. package/rules/func-call-spacing.cjs +127 -0
  47. package/rules/func-name-matching.cjs +138 -0
  48. package/rules/func-names.cjs +121 -0
  49. package/rules/func-style.cjs +103 -0
  50. package/rules/function-call-argument-newline.cjs +109 -0
  51. package/rules/function-paren-newline.cjs +173 -0
  52. package/rules/generator-star-spacing.cjs +174 -0
  53. package/rules/getter-return.cjs +129 -0
  54. package/rules/global-require.cjs +84 -0
  55. package/rules/grouped-accessor-pairs.cjs +146 -0
  56. package/rules/guard-for-in.cjs +39 -0
  57. package/rules/handle-callback-err.cjs +86 -0
  58. package/rules/id-blacklist.cjs +135 -0
  59. package/rules/id-denylist.cjs +126 -0
  60. package/rules/id-length.cjs +119 -0
  61. package/rules/id-match.cjs +139 -0
  62. package/rules/implicit-arrow-linebreak.cjs +76 -0
  63. package/rules/indent-legacy.cjs +520 -0
  64. package/rules/indent.cjs +842 -0
  65. package/rules/init-declarations.cjs +88 -0
  66. package/rules/jsx-quotes.cjs +84 -0
  67. package/rules/key-spacing.cjs +399 -0
  68. package/rules/keyword-spacing.cjs +464 -0
  69. package/rules/line-comment-position.cjs +75 -0
  70. package/rules/linebreak-style.cjs +89 -0
  71. package/rules/lines-around-comment.cjs +290 -0
  72. package/rules/lines-around-directive.cjs +129 -0
  73. package/rules/lines-between-class-members.cjs +212 -0
  74. package/rules/logical-assignment-operators.cjs +305 -0
  75. package/rules/max-classes-per-file.cjs +61 -0
  76. package/rules/max-depth.cjs +117 -0
  77. package/rules/max-len.cjs +256 -0
  78. package/rules/max-lines-per-function.cjs +116 -0
  79. package/rules/max-lines.cjs +109 -0
  80. package/rules/max-nested-callbacks.cjs +78 -0
  81. package/rules/max-params.cjs +78 -0
  82. package/rules/max-statements-per-line.cjs +147 -0
  83. package/rules/max-statements.cjs +119 -0
  84. package/rules/multiline-comment-style.cjs +319 -0
  85. package/rules/multiline-ternary.cjs +106 -0
  86. package/rules/new-cap.cjs +139 -0
  87. package/rules/new-parens.cjs +70 -0
  88. package/rules/newline-after-var.cjs +159 -0
  89. package/rules/newline-before-return.cjs +128 -0
  90. package/rules/newline-per-chained-call.cjs +100 -0
  91. package/rules/no-alert.cjs +84 -0
  92. package/rules/no-array-constructor.cjs +91 -0
  93. package/rules/no-async-promise-executor.cjs +33 -0
  94. package/rules/no-await-in-loop.cjs +75 -0
  95. package/rules/no-bitwise.cjs +106 -0
  96. package/rules/no-buffer-constructor.cjs +51 -0
  97. package/rules/no-caller.cjs +34 -0
  98. package/rules/no-case-declarations.cjs +56 -0
  99. package/rules/no-catch-shadow.cjs +57 -0
  100. package/rules/no-class-assign.cjs +55 -0
  101. package/rules/no-compare-neg-zero.cjs +52 -0
  102. package/rules/no-cond-assign.cjs +104 -0
  103. package/rules/no-confusing-arrow.cjs +87 -0
  104. package/rules/no-console.cjs +138 -0
  105. package/rules/no-const-assign.cjs +50 -0
  106. package/rules/no-constant-binary-expression.cjs +284 -0
  107. package/rules/no-constant-condition.cjs +119 -0
  108. package/rules/no-constructor-return.cjs +43 -0
  109. package/rules/no-continue.cjs +33 -0
  110. package/rules/no-control-regex.cjs +74 -0
  111. package/rules/no-debugger.cjs +33 -0
  112. package/rules/no-delete-var.cjs +32 -0
  113. package/rules/no-div-regex.cjs +39 -0
  114. package/rules/no-dupe-args.cjs +61 -0
  115. package/rules/no-dupe-class-members.cjs +77 -0
  116. package/rules/no-dupe-else-if.cjs +74 -0
  117. package/rules/no-dupe-keys.cjs +88 -0
  118. package/rules/no-duplicate-case.cjs +49 -0
  119. package/rules/no-duplicate-imports.cjs +166 -0
  120. package/rules/no-else-return.cjs +182 -0
  121. package/rules/no-empty-character-class.cjs +47 -0
  122. package/rules/no-empty-function.cjs +141 -0
  123. package/rules/no-empty-pattern.cjs +50 -0
  124. package/rules/no-empty-static-block.cjs +50 -0
  125. package/rules/no-empty.cjs +78 -0
  126. package/rules/no-eq-null.cjs +34 -0
  127. package/rules/no-eval.cjs +165 -0
  128. package/rules/no-ex-assign.cjs +45 -0
  129. package/rules/no-extend-native.cjs +103 -0
  130. package/rules/no-extra-bind.cjs +127 -0
  131. package/rules/no-extra-boolean-cast.cjs +159 -0
  132. package/rules/no-extra-label.cjs +116 -0
  133. package/rules/no-extra-parens.cjs +665 -0
  134. package/rules/no-extra-semi.cjs +103 -0
  135. package/rules/no-fallthrough.cjs +136 -0
  136. package/rules/no-floating-decimal.cjs +66 -0
  137. package/rules/no-func-assign.cjs +63 -0
  138. package/rules/no-global-assign.cjs +62 -0
  139. package/rules/no-implicit-coercion.cjs +219 -0
  140. package/rules/no-implicit-globals.cjs +77 -0
  141. package/rules/no-implied-eval.cjs +87 -0
  142. package/rules/no-import-assign.cjs +123 -0
  143. package/rules/no-inline-comments.cjs +57 -0
  144. package/rules/no-inner-declarations.cjs +82 -0
  145. package/rules/no-invalid-regexp.cjs +130 -0
  146. package/rules/no-invalid-this.cjs +90 -0
  147. package/rules/no-irregular-whitespace.cjs +157 -0
  148. package/rules/no-iterator.cjs +34 -0
  149. package/rules/no-label-var.cjs +46 -0
  150. package/rules/no-labels.cjs +106 -0
  151. package/rules/no-lone-blocks.cjs +75 -0
  152. package/rules/no-lonely-if.cjs +42 -0
  153. package/rules/no-loop-func.cjs +143 -0
  154. package/rules/no-loss-of-precision.cjs +160 -0
  155. package/rules/no-magic-numbers.cjs +222 -0
  156. package/rules/no-misleading-character-class.cjs +500 -0
  157. package/rules/no-mixed-operators.cjs +197 -0
  158. package/rules/no-mixed-requires.cjs +117 -0
  159. package/rules/no-mixed-spaces-and-tabs.cjs +87 -0
  160. package/rules/no-multi-assign.cjs +38 -0
  161. package/rules/no-multi-spaces.cjs +95 -0
  162. package/rules/no-multi-str.cjs +44 -0
  163. package/rules/no-multiple-empty-lines.cjs +112 -0
  164. package/rules/no-native-reassign.cjs +72 -0
  165. package/rules/no-negated-condition.cjs +77 -0
  166. package/rules/no-negated-in-lhs.cjs +43 -0
  167. package/rules/no-nested-ternary.cjs +33 -0
  168. package/rules/no-new-func.cjs +50 -0
  169. package/rules/no-new-native-nonconstructor.cjs +42 -0
  170. package/rules/no-new-object.cjs +47 -0
  171. package/rules/no-new-require.cjs +50 -0
  172. package/rules/no-new-symbol.cjs +48 -0
  173. package/rules/no-new-wrappers.cjs +44 -0
  174. package/rules/no-new.cjs +33 -0
  175. package/rules/no-nonoctal-decimal-escape.cjs +80 -0
  176. package/rules/no-obj-calls.cjs +64 -0
  177. package/rules/no-object-constructor.cjs +69 -0
  178. package/rules/no-octal-escape.cjs +35 -0
  179. package/rules/no-octal.cjs +32 -0
  180. package/rules/no-param-reassign.cjs +135 -0
  181. package/rules/no-path-concat.cjs +52 -0
  182. package/rules/no-plusplus.cjs +64 -0
  183. package/rules/no-process-env.cjs +51 -0
  184. package/rules/no-process-exit.cjs +50 -0
  185. package/rules/no-promise-executor-return.cjs +131 -0
  186. package/rules/no-proto.cjs +34 -0
  187. package/rules/no-prototype-builtins.cjs +85 -0
  188. package/rules/no-redeclare.cjs +103 -0
  189. package/rules/no-regex-spaces.cjs +115 -0
  190. package/rules/no-restricted-exports.cjs +117 -0
  191. package/rules/no-restricted-globals.cjs +147 -0
  192. package/rules/no-restricted-imports.cjs +421 -0
  193. package/rules/no-restricted-modules.cjs +144 -0
  194. package/rules/no-restricted-properties.cjs +123 -0
  195. package/rules/no-restricted-syntax.cjs +49 -0
  196. package/rules/no-return-assign.cjs +45 -0
  197. package/rules/no-return-await.cjs +88 -0
  198. package/rules/no-script-url.cjs +49 -0
  199. package/rules/no-self-assign.cjs +88 -0
  200. package/rules/no-self-compare.cjs +53 -0
  201. package/rules/no-sequences.cjs +81 -0
  202. package/rules/no-setter-return.cjs +110 -0
  203. package/rules/no-shadow-restricted-names.cjs +60 -0
  204. package/rules/no-shadow.cjs +302 -0
  205. package/rules/no-spaced-func.cjs +69 -0
  206. package/rules/no-sparse-arrays.cjs +40 -0
  207. package/rules/no-sync.cjs +58 -0
  208. package/rules/no-tabs.cjs +73 -0
  209. package/rules/no-template-curly-in-string.cjs +33 -0
  210. package/rules/no-ternary.cjs +33 -0
  211. package/rules/no-this-before-super.cjs +177 -0
  212. package/rules/no-throw-literal.cjs +40 -0
  213. package/rules/no-trailing-spaces.cjs +123 -0
  214. package/rules/no-unassigned-vars.cjs +54 -0
  215. package/rules/no-undef-init.cjs +46 -0
  216. package/rules/no-undef.cjs +51 -0
  217. package/rules/no-undefined.cjs +58 -0
  218. package/rules/no-underscore-dangle.cjs +211 -0
  219. package/rules/no-unexpected-multiline.cjs +76 -0
  220. package/rules/no-unmodified-loop-condition.cjs +849 -0
  221. package/rules/no-unneeded-ternary.cjs +112 -0
  222. package/rules/no-unreachable-loop.cjs +128 -0
  223. package/rules/no-unreachable.cjs +195 -0
  224. package/rules/no-unsafe-finally.cjs +67 -0
  225. package/rules/no-unsafe-negation.cjs +86 -0
  226. package/rules/no-unsafe-optional-chaining.cjs +164 -0
  227. package/rules/no-unused-expressions.cjs +163 -0
  228. package/rules/no-unused-labels.cjs +97 -0
  229. package/rules/no-unused-private-class-members.cjs +69 -0
  230. package/rules/no-unused-vars.cjs +639 -0
  231. package/rules/no-use-before-define.cjs +245 -0
  232. package/rules/no-useless-assignment.cjs +250 -0
  233. package/rules/no-useless-backreference.cjs +137 -0
  234. package/rules/no-useless-call.cjs +57 -0
  235. package/rules/no-useless-catch.cjs +38 -0
  236. package/rules/no-useless-computed-key.cjs +106 -0
  237. package/rules/no-useless-concat.cjs +78 -0
  238. package/rules/no-useless-constructor.cjs +152 -0
  239. package/rules/no-useless-escape.cjs +164 -0
  240. package/rules/no-useless-rename.cjs +94 -0
  241. package/rules/no-useless-return.cjs +229 -0
  242. package/rules/no-var.cjs +235 -0
  243. package/rules/no-void.cjs +39 -0
  244. package/rules/no-warning-comments.cjs +112 -0
  245. package/rules/no-whitespace-before-property.cjs +72 -0
  246. package/rules/no-with.cjs +32 -0
  247. package/rules/nonblock-statement-body-position.cjs +107 -0
  248. package/rules/object-curly-newline.cjs +194 -0
  249. package/rules/object-curly-spacing.cjs +225 -0
  250. package/rules/object-property-newline.cjs +81 -0
  251. package/rules/object-shorthand.cjs +284 -0
  252. package/rules/one-var-declaration-per-line.cjs +75 -0
  253. package/rules/one-var.cjs +378 -0
  254. package/rules/operator-assignment.cjs +146 -0
  255. package/rules/operator-linebreak.cjs +150 -0
  256. package/rules/padded-blocks.cjs +192 -0
  257. package/rules/padding-line-between-statements.cjs +377 -0
  258. package/rules/prefer-arrow-callback.cjs +185 -0
  259. package/rules/prefer-const.cjs +240 -0
  260. package/rules/prefer-destructuring.cjs +188 -0
  261. package/rules/prefer-exponentiation-operator.cjs +100 -0
  262. package/rules/prefer-named-capture-group.cjs +111 -0
  263. package/rules/prefer-numeric-literals.cjs +75 -0
  264. package/rules/prefer-object-has-own.cjs +54 -0
  265. package/rules/prefer-object-spread.cjs +170 -0
  266. package/rules/prefer-promise-reject-errors.cjs +62 -0
  267. package/rules/prefer-reflect.cjs +100 -0
  268. package/rules/prefer-regex-literals.cjs +256 -0
  269. package/rules/prefer-rest-params.cjs +80 -0
  270. package/rules/prefer-spread.cjs +57 -0
  271. package/rules/prefer-template.cjs +147 -0
  272. package/rules/preserve-caught-error.cjs +196 -0
  273. package/rules/quote-props.cjs +224 -0
  274. package/rules/quotes.cjs +187 -0
  275. package/rules/radix.cjs +124 -0
  276. package/rules/require-atomic-updates.cjs +197 -0
  277. package/rules/require-await.cjs +90 -0
  278. package/rules/require-unicode-regexp.cjs +101 -0
  279. package/rules/require-yield.cjs +56 -0
  280. package/rules/rest-spread-spacing.cjs +99 -0
  281. package/rules/semi-spacing.cjs +215 -0
  282. package/rules/semi-style.cjs +116 -0
  283. package/rules/semi.cjs +239 -0
  284. package/rules/sort-imports.cjs +140 -0
  285. package/rules/sort-keys.cjs +165 -0
  286. package/rules/sort-vars.cjs +50 -0
  287. package/rules/space-before-blocks.cjs +132 -0
  288. package/rules/space-before-function-paren.cjs +126 -0
  289. package/rules/space-in-parens.cjs +175 -0
  290. package/rules/space-infix-ops.cjs +133 -0
  291. package/rules/space-unary-ops.cjs +237 -0
  292. package/rules/spaced-comment.cjs +233 -0
  293. package/rules/strict.cjs +206 -0
  294. package/rules/switch-colon-spacing.cjs +114 -0
  295. package/rules/symbol-description.cjs +49 -0
  296. package/rules/template-curly-spacing.cjs +112 -0
  297. package/rules/template-tag-spacing.cjs +82 -0
  298. package/rules/unicode-bom.cjs +52 -0
  299. package/rules/use-isnan.cjs +144 -0
  300. package/rules/valid-typeof.cjs +104 -0
  301. package/rules/vars-on-top.cjs +94 -0
  302. package/rules/wrap-iife.cjs +131 -0
  303. package/rules/wrap-regex.cjs +57 -0
  304. package/rules/yield-star-spacing.cjs +115 -0
  305. package/rules/yoda.cjs +185 -0
@@ -0,0 +1,262 @@
1
+ const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs");
2
+ //#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/array-callback-return.js
3
+ /**
4
+ * @fileoverview Rule to enforce return statements in callbacks of array's methods
5
+ * @author Toru Nagashima
6
+ */
7
+ var require_array_callback_return = /* @__PURE__ */ require_chunk.t(((exports, module) => {
8
+ let astUtils = require_ast_utils$1.t(), TARGET_NODE_TYPE = /^(?:Arrow)?FunctionExpression$/u, TARGET_METHODS = /^(?:every|filter|find(?:Last)?(?:Index)?|flatMap|forEach|map|reduce(?:Right)?|some|sort|toSorted)$/u;
9
+ /**
10
+ * Checks a given node is a member access which has the specified name's
11
+ * property.
12
+ * @param {ASTNode} node A node to check.
13
+ * @returns {boolean} `true` if the node is a member access which has
14
+ * the specified name's property. The node may be a `(Chain|Member)Expression` node.
15
+ */
16
+ function isTargetMethod(node) {
17
+ return astUtils.isSpecificMemberAccess(node, null, TARGET_METHODS);
18
+ }
19
+ /**
20
+ * Checks all segments in a set and returns true if any are reachable.
21
+ * @param {Set<CodePathSegment>} segments The segments to check.
22
+ * @returns {boolean} True if any segment is reachable; false otherwise.
23
+ */
24
+ function isAnySegmentReachable(segments) {
25
+ for (let segment of segments) if (segment.reachable) return !0;
26
+ return !1;
27
+ }
28
+ /**
29
+ * Returns a human-legible description of an array method
30
+ * @param {string} arrayMethodName A method name to fully qualify
31
+ * @returns {string} the method name prefixed with `Array.` if it is a class method,
32
+ * or else `Array.prototype.` if it is an instance method.
33
+ */
34
+ function fullMethodName(arrayMethodName) {
35
+ return [
36
+ "from",
37
+ "of",
38
+ "isArray"
39
+ ].includes(arrayMethodName) ? `Array.${arrayMethodName}` : `Array.prototype.${arrayMethodName}`;
40
+ }
41
+ /**
42
+ * Checks whether or not a given node is a function expression which is the
43
+ * callback of an array method, returning the method name.
44
+ * @param {ASTNode} node A node to check. This is one of
45
+ * FunctionExpression or ArrowFunctionExpression.
46
+ * @returns {string} The method name if the node is a callback method,
47
+ * null otherwise.
48
+ */
49
+ function getArrayMethodName(node) {
50
+ let currentNode = node;
51
+ for (; currentNode;) {
52
+ let parent = currentNode.parent;
53
+ switch (parent.type) {
54
+ case "LogicalExpression":
55
+ case "ConditionalExpression":
56
+ case "ChainExpression":
57
+ currentNode = parent;
58
+ break;
59
+ case "ReturnStatement": {
60
+ let func = astUtils.getUpperFunction(parent);
61
+ if (func === null || !astUtils.isCallee(func)) return null;
62
+ currentNode = func.parent;
63
+ break;
64
+ }
65
+ case "CallExpression": return astUtils.isArrayFromMethod(parent.callee) && parent.arguments.length >= 2 && parent.arguments[1] === currentNode ? "from" : isTargetMethod(parent.callee) && parent.arguments.length >= 1 && parent.arguments[0] === currentNode ? astUtils.getStaticPropertyName(parent.callee) : null;
66
+ default: return null;
67
+ }
68
+ }
69
+ /* c8 ignore next */
70
+ return null;
71
+ }
72
+ /**
73
+ * Checks if the given node is a void expression.
74
+ * @param {ASTNode} node The node to check.
75
+ * @returns {boolean} - `true` if the node is a void expression
76
+ */
77
+ function isExpressionVoid(node) {
78
+ return node.type === "UnaryExpression" && node.operator === "void";
79
+ }
80
+ /**
81
+ * Fixes the linting error by prepending "void " to the given node
82
+ * @param {Object} sourceCode context given by context.sourceCode
83
+ * @param {ASTNode} node The node to fix.
84
+ * @param {Object} fixer The fixer object provided by ESLint.
85
+ * @returns {Array<Object>} - An array of fix objects to apply to the node.
86
+ */
87
+ function voidPrependFixer(sourceCode, node, fixer) {
88
+ let requiresParens = astUtils.getPrecedence(node) < astUtils.getPrecedence({
89
+ type: "UnaryExpression",
90
+ operator: "void"
91
+ }) && !astUtils.isParenthesised(sourceCode, node), returnOrArrowToken = sourceCode.getTokenBefore(node, node.parent.type === "ArrowFunctionExpression" ? astUtils.isArrowToken : (token) => token.type === "Keyword" && token.value === "return"), firstToken = sourceCode.getTokenAfter(returnOrArrowToken), prependSpace = returnOrArrowToken.value === "return" && returnOrArrowToken.range[1] === firstToken.range[0];
92
+ return [fixer.insertTextBefore(firstToken, `${prependSpace ? " " : ""}void ${requiresParens ? "(" : ""}`), fixer.insertTextAfter(node, requiresParens ? ")" : "")];
93
+ }
94
+ /**
95
+ * Fixes the linting error by `wrapping {}` around the given node's body.
96
+ * @param {Object} sourceCode context given by context.sourceCode
97
+ * @param {ASTNode} node The node to fix.
98
+ * @param {Object} fixer The fixer object provided by ESLint.
99
+ * @returns {Array<Object>} - An array of fix objects to apply to the node.
100
+ */
101
+ function curlyWrapFixer(sourceCode, node, fixer) {
102
+ let arrowToken = sourceCode.getTokenBefore(node.body, astUtils.isArrowToken), firstToken = sourceCode.getTokenAfter(arrowToken), lastToken = sourceCode.getLastToken(node);
103
+ return [fixer.insertTextBefore(firstToken, "{"), fixer.insertTextAfter(lastToken, "}")];
104
+ }
105
+ /** @type {import('../types').Rule.RuleModule} */
106
+ module.exports = {
107
+ meta: {
108
+ type: "problem",
109
+ defaultOptions: [{
110
+ allowImplicit: !1,
111
+ checkForEach: !1,
112
+ allowVoid: !1
113
+ }],
114
+ docs: {
115
+ description: "Enforce `return` statements in callbacks of array methods",
116
+ recommended: !1,
117
+ url: "https://eslint.org/docs/latest/rules/array-callback-return"
118
+ },
119
+ hasSuggestions: !0,
120
+ schema: [{
121
+ type: "object",
122
+ properties: {
123
+ allowImplicit: { type: "boolean" },
124
+ checkForEach: { type: "boolean" },
125
+ allowVoid: { type: "boolean" }
126
+ },
127
+ additionalProperties: !1
128
+ }],
129
+ messages: {
130
+ expectedAtEnd: "{{arrayMethodName}}() expects a value to be returned at the end of {{name}}.",
131
+ expectedInside: "{{arrayMethodName}}() expects a return value from {{name}}.",
132
+ expectedReturnValue: "{{arrayMethodName}}() expects a return value from {{name}}.",
133
+ expectedNoReturnValue: "{{arrayMethodName}}() expects no useless return value from {{name}}.",
134
+ wrapBraces: "Wrap the expression in `{}`.",
135
+ prependVoid: "Prepend `void` to the expression."
136
+ }
137
+ },
138
+ create(context) {
139
+ let [options] = context.options, sourceCode = context.sourceCode, funcInfo = {
140
+ arrayMethodName: null,
141
+ upper: null,
142
+ codePath: null,
143
+ hasReturn: !1,
144
+ shouldCheck: !1,
145
+ node: null
146
+ };
147
+ /**
148
+ * Checks whether or not the last code path segment is reachable.
149
+ * Then reports this function if the segment is reachable.
150
+ *
151
+ * If the last code path segment is reachable, there are paths which are not
152
+ * returned or thrown.
153
+ * @param {ASTNode} node A node to check.
154
+ * @returns {void}
155
+ */
156
+ function checkLastSegment(node) {
157
+ if (!funcInfo.shouldCheck) return;
158
+ let messageAndSuggestions = {
159
+ messageId: "",
160
+ suggest: []
161
+ };
162
+ if (funcInfo.arrayMethodName === "forEach") {
163
+ if (options.checkForEach && node.type === "ArrowFunctionExpression" && node.expression) if (options.allowVoid) {
164
+ if (isExpressionVoid(node.body)) return;
165
+ messageAndSuggestions.messageId = "expectedNoReturnValue", messageAndSuggestions.suggest = [{
166
+ messageId: "wrapBraces",
167
+ fix(fixer) {
168
+ return curlyWrapFixer(sourceCode, node, fixer);
169
+ }
170
+ }, {
171
+ messageId: "prependVoid",
172
+ fix(fixer) {
173
+ return voidPrependFixer(sourceCode, node.body, fixer);
174
+ }
175
+ }];
176
+ } else messageAndSuggestions.messageId = "expectedNoReturnValue", messageAndSuggestions.suggest = [{
177
+ messageId: "wrapBraces",
178
+ fix(fixer) {
179
+ return curlyWrapFixer(sourceCode, node, fixer);
180
+ }
181
+ }];
182
+ } else node.body.type === "BlockStatement" && isAnySegmentReachable(funcInfo.currentSegments) && (messageAndSuggestions.messageId = funcInfo.hasReturn ? "expectedAtEnd" : "expectedInside");
183
+ if (messageAndSuggestions.messageId) {
184
+ let name = astUtils.getFunctionNameWithKind(node);
185
+ context.report({
186
+ node,
187
+ loc: astUtils.getFunctionHeadLoc(node, sourceCode),
188
+ messageId: messageAndSuggestions.messageId,
189
+ data: {
190
+ name,
191
+ arrayMethodName: fullMethodName(funcInfo.arrayMethodName)
192
+ },
193
+ suggest: messageAndSuggestions.suggest.length === 0 ? null : messageAndSuggestions.suggest
194
+ });
195
+ }
196
+ }
197
+ return {
198
+ onCodePathStart(codePath, node) {
199
+ let methodName = null;
200
+ TARGET_NODE_TYPE.test(node.type) && (methodName = getArrayMethodName(node)), funcInfo = {
201
+ arrayMethodName: methodName,
202
+ upper: funcInfo,
203
+ codePath,
204
+ hasReturn: !1,
205
+ shouldCheck: methodName && !node.async && !node.generator,
206
+ node,
207
+ currentSegments: /* @__PURE__ */ new Set()
208
+ };
209
+ },
210
+ onCodePathEnd() {
211
+ funcInfo = funcInfo.upper;
212
+ },
213
+ onUnreachableCodePathSegmentStart(segment) {
214
+ funcInfo.currentSegments.add(segment);
215
+ },
216
+ onUnreachableCodePathSegmentEnd(segment) {
217
+ funcInfo.currentSegments.delete(segment);
218
+ },
219
+ onCodePathSegmentStart(segment) {
220
+ funcInfo.currentSegments.add(segment);
221
+ },
222
+ onCodePathSegmentEnd(segment) {
223
+ funcInfo.currentSegments.delete(segment);
224
+ },
225
+ ReturnStatement(node) {
226
+ if (!funcInfo.shouldCheck) return;
227
+ funcInfo.hasReturn = !0;
228
+ let messageAndSuggestions = {
229
+ messageId: "",
230
+ suggest: []
231
+ };
232
+ if (funcInfo.arrayMethodName === "forEach") {
233
+ if (options.checkForEach && node.argument) if (options.allowVoid) {
234
+ if (isExpressionVoid(node.argument)) return;
235
+ messageAndSuggestions.messageId = "expectedNoReturnValue", messageAndSuggestions.suggest = [{
236
+ messageId: "prependVoid",
237
+ fix(fixer) {
238
+ return voidPrependFixer(sourceCode, node.argument, fixer);
239
+ }
240
+ }];
241
+ } else messageAndSuggestions.messageId = "expectedNoReturnValue";
242
+ } else !options.allowImplicit && !node.argument && (messageAndSuggestions.messageId = "expectedReturnValue");
243
+ messageAndSuggestions.messageId && context.report({
244
+ node,
245
+ messageId: messageAndSuggestions.messageId,
246
+ data: {
247
+ name: astUtils.getFunctionNameWithKind(funcInfo.node),
248
+ arrayMethodName: fullMethodName(funcInfo.arrayMethodName)
249
+ },
250
+ suggest: messageAndSuggestions.suggest.length === 0 ? null : messageAndSuggestions.suggest
251
+ });
252
+ },
253
+ "FunctionExpression:exit": checkLastSegment,
254
+ "ArrowFunctionExpression:exit": checkLastSegment
255
+ };
256
+ }
257
+ };
258
+ }));
259
+ //#endregion
260
+ //#region src-js/generated/plugin-eslint/rules/array-callback-return.cjs
261
+ module.exports = require_array_callback_return().create;
262
+ //#endregion
@@ -0,0 +1,178 @@
1
+ const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs");
2
+ //#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/array-element-newline.js
3
+ /**
4
+ * @fileoverview Rule to enforce line breaks after each array element
5
+ * @author Jan Peer Stöcklmair <https://github.com/JPeer264>
6
+ * @deprecated in ESLint v8.53.0
7
+ */
8
+ var require_array_element_newline = /* @__PURE__ */ require_chunk.t(((exports, module) => {
9
+ let astUtils = require_ast_utils$1.t();
10
+ /** @type {import('../types').Rule.RuleModule} */
11
+ module.exports = {
12
+ meta: {
13
+ deprecated: {
14
+ message: "Formatting rules are being moved out of ESLint core.",
15
+ url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
16
+ deprecatedSince: "8.53.0",
17
+ availableUntil: "11.0.0",
18
+ replacedBy: [{
19
+ message: "ESLint Stylistic now maintains deprecated stylistic core rules.",
20
+ url: "https://eslint.style/guide/migration",
21
+ plugin: {
22
+ name: "@stylistic/eslint-plugin",
23
+ url: "https://eslint.style"
24
+ },
25
+ rule: {
26
+ name: "array-element-newline",
27
+ url: "https://eslint.style/rules/array-element-newline"
28
+ }
29
+ }]
30
+ },
31
+ type: "layout",
32
+ docs: {
33
+ description: "Enforce line breaks after each array element",
34
+ recommended: !1,
35
+ url: "https://eslint.org/docs/latest/rules/array-element-newline"
36
+ },
37
+ fixable: "whitespace",
38
+ schema: {
39
+ definitions: { basicConfig: { oneOf: [{ enum: [
40
+ "always",
41
+ "never",
42
+ "consistent"
43
+ ] }, {
44
+ type: "object",
45
+ properties: {
46
+ multiline: { type: "boolean" },
47
+ minItems: {
48
+ type: ["integer", "null"],
49
+ minimum: 0
50
+ }
51
+ },
52
+ additionalProperties: !1
53
+ }] } },
54
+ type: "array",
55
+ items: [{ oneOf: [{ $ref: "#/definitions/basicConfig" }, {
56
+ type: "object",
57
+ properties: {
58
+ ArrayExpression: { $ref: "#/definitions/basicConfig" },
59
+ ArrayPattern: { $ref: "#/definitions/basicConfig" }
60
+ },
61
+ additionalProperties: !1,
62
+ minProperties: 1
63
+ }] }]
64
+ },
65
+ messages: {
66
+ unexpectedLineBreak: "There should be no linebreak here.",
67
+ missingLineBreak: "There should be a linebreak after this element."
68
+ }
69
+ },
70
+ create(context) {
71
+ let sourceCode = context.sourceCode;
72
+ /**
73
+ * Normalizes a given option value.
74
+ * @param {string|Object|undefined} providedOption An option value to parse.
75
+ * @returns {{multiline: boolean, minItems: number}} Normalized option object.
76
+ */
77
+ function normalizeOptionValue(providedOption) {
78
+ let consistent = !1, multiline = !1, minItems, option = providedOption || "always";
79
+ return !option || option === "always" || option.minItems === 0 ? minItems = 0 : option === "never" ? minItems = Infinity : option === "consistent" ? (consistent = !0, minItems = Infinity) : (multiline = !!option.multiline, minItems = option.minItems || Infinity), {
80
+ consistent,
81
+ multiline,
82
+ minItems
83
+ };
84
+ }
85
+ /**
86
+ * Normalizes a given option value.
87
+ * @param {string|Object|undefined} options An option value to parse.
88
+ * @returns {{ArrayExpression: {multiline: boolean, minItems: number}, ArrayPattern: {multiline: boolean, minItems: number}}} Normalized option object.
89
+ */
90
+ function normalizeOptions(options) {
91
+ if (options && (options.ArrayExpression || options.ArrayPattern)) {
92
+ let expressionOptions, patternOptions;
93
+ return options.ArrayExpression && (expressionOptions = normalizeOptionValue(options.ArrayExpression)), options.ArrayPattern && (patternOptions = normalizeOptionValue(options.ArrayPattern)), {
94
+ ArrayExpression: expressionOptions,
95
+ ArrayPattern: patternOptions
96
+ };
97
+ }
98
+ let value = normalizeOptionValue(options);
99
+ return {
100
+ ArrayExpression: value,
101
+ ArrayPattern: value
102
+ };
103
+ }
104
+ /**
105
+ * Reports that there shouldn't be a line break after the first token
106
+ * @param {Token} token The token to use for the report.
107
+ * @returns {void}
108
+ */
109
+ function reportNoLineBreak(token) {
110
+ let tokenBefore = sourceCode.getTokenBefore(token, { includeComments: !0 });
111
+ context.report({
112
+ loc: {
113
+ start: tokenBefore.loc.end,
114
+ end: token.loc.start
115
+ },
116
+ messageId: "unexpectedLineBreak",
117
+ fix(fixer) {
118
+ if (astUtils.isCommentToken(tokenBefore)) return null;
119
+ if (!astUtils.isTokenOnSameLine(tokenBefore, token)) return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], " ");
120
+ let twoTokensBefore = sourceCode.getTokenBefore(tokenBefore, { includeComments: !0 });
121
+ return astUtils.isCommentToken(twoTokensBefore) ? null : fixer.replaceTextRange([twoTokensBefore.range[1], tokenBefore.range[0]], "");
122
+ }
123
+ });
124
+ }
125
+ /**
126
+ * Reports that there should be a line break after the first token
127
+ * @param {Token} token The token to use for the report.
128
+ * @returns {void}
129
+ */
130
+ function reportRequiredLineBreak(token) {
131
+ let tokenBefore = sourceCode.getTokenBefore(token, { includeComments: !0 });
132
+ context.report({
133
+ loc: {
134
+ start: tokenBefore.loc.end,
135
+ end: token.loc.start
136
+ },
137
+ messageId: "missingLineBreak",
138
+ fix(fixer) {
139
+ return fixer.replaceTextRange([tokenBefore.range[1], token.range[0]], "\n");
140
+ }
141
+ });
142
+ }
143
+ /**
144
+ * Reports a given node if it violated this rule.
145
+ * @param {ASTNode} node A node to check. This is an ObjectExpression node or an ObjectPattern node.
146
+ * @returns {void}
147
+ */
148
+ function check(node) {
149
+ let elements = node.elements, options = normalizeOptions(context.options[0])[node.type];
150
+ if (!options) return;
151
+ let elementBreak = !1;
152
+ options.multiline && (elementBreak = elements.filter((element) => element !== null).some((element) => element.loc.start.line !== element.loc.end.line));
153
+ let linebreaksCount = 0;
154
+ for (let i = 0; i < node.elements.length; i++) {
155
+ let element = node.elements[i], previousElement = elements[i - 1];
156
+ if (i === 0 || element === null || previousElement === null) continue;
157
+ let commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken), lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken), firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
158
+ astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement) || linebreaksCount++;
159
+ }
160
+ let needsLinebreaks = elements.length >= options.minItems || options.multiline && elementBreak || options.consistent && linebreaksCount > 0 && linebreaksCount < node.elements.length;
161
+ elements.forEach((element, i) => {
162
+ let previousElement = elements[i - 1];
163
+ if (i === 0 || element === null || previousElement === null) return;
164
+ let commaToken = sourceCode.getFirstTokenBetween(previousElement, element, astUtils.isCommaToken), lastTokenOfPreviousElement = sourceCode.getTokenBefore(commaToken), firstTokenOfCurrentElement = sourceCode.getTokenAfter(commaToken);
165
+ needsLinebreaks ? astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement) && reportRequiredLineBreak(firstTokenOfCurrentElement) : astUtils.isTokenOnSameLine(lastTokenOfPreviousElement, firstTokenOfCurrentElement) || reportNoLineBreak(firstTokenOfCurrentElement);
166
+ });
167
+ }
168
+ return {
169
+ ArrayPattern: check,
170
+ ArrayExpression: check
171
+ };
172
+ }
173
+ };
174
+ }));
175
+ //#endregion
176
+ //#region src-js/generated/plugin-eslint/rules/array-element-newline.cjs
177
+ module.exports = require_array_element_newline().create;
178
+ //#endregion
@@ -0,0 +1,135 @@
1
+ const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs");
2
+ //#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/arrow-body-style.js
3
+ /**
4
+ * @fileoverview Rule to require braces in arrow function body.
5
+ * @author Alberto Rodríguez
6
+ */
7
+ var require_arrow_body_style = /* @__PURE__ */ require_chunk.t(((exports, module) => {
8
+ let astUtils = require_ast_utils$1.t();
9
+ /** @type {import('../types').Rule.RuleModule} */
10
+ module.exports = {
11
+ meta: {
12
+ type: "suggestion",
13
+ defaultOptions: ["as-needed"],
14
+ docs: {
15
+ description: "Require braces around arrow function bodies",
16
+ recommended: !1,
17
+ frozen: !0,
18
+ url: "https://eslint.org/docs/latest/rules/arrow-body-style"
19
+ },
20
+ schema: { anyOf: [{
21
+ type: "array",
22
+ items: [{ enum: ["always", "never"] }],
23
+ minItems: 0,
24
+ maxItems: 1
25
+ }, {
26
+ type: "array",
27
+ items: [{ enum: ["as-needed"] }, {
28
+ type: "object",
29
+ properties: { requireReturnForObjectLiteral: { type: "boolean" } },
30
+ additionalProperties: !1
31
+ }],
32
+ minItems: 0,
33
+ maxItems: 2
34
+ }] },
35
+ fixable: "code",
36
+ messages: {
37
+ unexpectedOtherBlock: "Unexpected block statement surrounding arrow body.",
38
+ unexpectedEmptyBlock: "Unexpected block statement surrounding arrow body; put a value of `undefined` immediately after the `=>`.",
39
+ unexpectedObjectBlock: "Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`.",
40
+ unexpectedSingleBlock: "Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`.",
41
+ expectedBlock: "Expected block statement surrounding arrow body."
42
+ }
43
+ },
44
+ create(context) {
45
+ let options = context.options, always = options[0] === "always", asNeeded = options[0] === "as-needed", never = options[0] === "never", requireReturnForObjectLiteral = options[1] && options[1].requireReturnForObjectLiteral, sourceCode = context.sourceCode, funcInfo = null;
46
+ /**
47
+ * Checks whether the given node has ASI problem or not.
48
+ * @param {Token} token The token to check.
49
+ * @returns {boolean} `true` if it changes semantics if `;` or `}` followed by the token are removed.
50
+ */
51
+ function hasASIProblem(token) {
52
+ return token && token.type === "Punctuator" && /^[([/`+-]/u.test(token.value);
53
+ }
54
+ /**
55
+ * Gets the closing parenthesis by the given node.
56
+ * @param {ASTNode} node first node after an opening parenthesis.
57
+ * @returns {Token} The found closing parenthesis token.
58
+ */
59
+ function findClosingParen(node) {
60
+ let nodeToCheck = node;
61
+ for (; !astUtils.isParenthesised(sourceCode, nodeToCheck);) nodeToCheck = nodeToCheck.parent;
62
+ return sourceCode.getTokenAfter(nodeToCheck);
63
+ }
64
+ /**
65
+ * Check whether the node is inside of a for loop's init
66
+ * @param {ASTNode} node node is inside for loop
67
+ * @returns {boolean} `true` if the node is inside of a for loop, else `false`
68
+ */
69
+ function isInsideForLoopInitializer(node) {
70
+ return node && node.parent ? node.parent.type === "ForStatement" && node.parent.init === node ? !0 : isInsideForLoopInitializer(node.parent) : !1;
71
+ }
72
+ /**
73
+ * Determines whether a arrow function body needs braces
74
+ * @param {ASTNode} node The arrow function node.
75
+ * @returns {void}
76
+ */
77
+ function validate(node) {
78
+ let arrowBody = node.body;
79
+ if (arrowBody.type === "BlockStatement") {
80
+ let blockBody = arrowBody.body;
81
+ if (blockBody.length !== 1 && !never || asNeeded && requireReturnForObjectLiteral && blockBody[0].type === "ReturnStatement" && blockBody[0].argument && blockBody[0].argument.type === "ObjectExpression") return;
82
+ if (never || asNeeded && blockBody[0].type === "ReturnStatement") {
83
+ let messageId;
84
+ messageId = blockBody.length === 0 ? "unexpectedEmptyBlock" : blockBody.length > 1 || blockBody[0].type !== "ReturnStatement" ? "unexpectedOtherBlock" : blockBody[0].argument === null ? "unexpectedSingleBlock" : astUtils.isOpeningBraceToken(sourceCode.getFirstToken(blockBody[0], { skip: 1 })) ? "unexpectedObjectBlock" : "unexpectedSingleBlock", context.report({
85
+ node,
86
+ loc: arrowBody.loc,
87
+ messageId,
88
+ fix(fixer) {
89
+ let fixes = [];
90
+ if (blockBody.length !== 1 || blockBody[0].type !== "ReturnStatement" || !blockBody[0].argument || hasASIProblem(sourceCode.getTokenAfter(arrowBody))) return fixes;
91
+ let openingBrace = sourceCode.getFirstToken(arrowBody), closingBrace = sourceCode.getLastToken(arrowBody), firstValueToken = sourceCode.getFirstToken(blockBody[0], 1), lastValueToken = sourceCode.getLastToken(blockBody[0]);
92
+ return sourceCode.commentsExistBetween(openingBrace, firstValueToken) || sourceCode.commentsExistBetween(lastValueToken, closingBrace) ? fixes.push(fixer.remove(openingBrace), fixer.remove(closingBrace), fixer.remove(sourceCode.getTokenAfter(openingBrace))) : fixes.push(fixer.removeRange([openingBrace.range[0], firstValueToken.range[0]]), fixer.removeRange([lastValueToken.range[1], closingBrace.range[1]])), (astUtils.isOpeningBraceToken(firstValueToken) || blockBody[0].argument.type === "SequenceExpression" || funcInfo.hasInOperator && isInsideForLoopInitializer(node)) && (astUtils.isParenthesised(sourceCode, blockBody[0].argument) || fixes.push(fixer.insertTextBefore(firstValueToken, "("), fixer.insertTextAfter(lastValueToken, ")"))), astUtils.isSemicolonToken(lastValueToken) && fixes.push(fixer.remove(lastValueToken)), fixes;
93
+ }
94
+ });
95
+ }
96
+ } else (always || asNeeded && requireReturnForObjectLiteral && arrowBody.type === "ObjectExpression") && context.report({
97
+ node,
98
+ loc: arrowBody.loc,
99
+ messageId: "expectedBlock",
100
+ fix(fixer) {
101
+ let fixes = [], arrowToken = sourceCode.getTokenBefore(arrowBody, astUtils.isArrowToken), [firstTokenAfterArrow, secondTokenAfterArrow] = sourceCode.getTokensAfter(arrowToken, { count: 2 }), lastToken = sourceCode.getLastToken(node), parenthesisedObjectLiteral = null;
102
+ if (astUtils.isOpeningParenToken(firstTokenAfterArrow) && astUtils.isOpeningBraceToken(secondTokenAfterArrow)) {
103
+ let braceNode = sourceCode.getNodeByRangeIndex(secondTokenAfterArrow.range[0]);
104
+ braceNode.type === "ObjectExpression" && (parenthesisedObjectLiteral = braceNode);
105
+ }
106
+ if (parenthesisedObjectLiteral) {
107
+ let openingParenToken = firstTokenAfterArrow, openingBraceToken = secondTokenAfterArrow;
108
+ astUtils.isTokenOnSameLine(openingParenToken, openingBraceToken) ? fixes.push(fixer.replaceText(openingParenToken, "{return ")) : fixes.push(fixer.replaceText(openingParenToken, "{"), fixer.insertTextBefore(openingBraceToken, "return ")), fixes.push(fixer.remove(findClosingParen(parenthesisedObjectLiteral))), fixes.push(fixer.insertTextAfter(lastToken, "}"));
109
+ } else fixes.push(fixer.insertTextBefore(firstTokenAfterArrow, "{return ")), fixes.push(fixer.insertTextAfter(lastToken, "}"));
110
+ return fixes;
111
+ }
112
+ });
113
+ }
114
+ return {
115
+ "BinaryExpression[operator='in']"() {
116
+ let info = funcInfo;
117
+ for (; info;) info.hasInOperator = !0, info = info.upper;
118
+ },
119
+ ArrowFunctionExpression() {
120
+ funcInfo = {
121
+ upper: funcInfo,
122
+ hasInOperator: !1
123
+ };
124
+ },
125
+ "ArrowFunctionExpression:exit"(node) {
126
+ validate(node), funcInfo = funcInfo.upper;
127
+ }
128
+ };
129
+ }
130
+ };
131
+ }));
132
+ //#endregion
133
+ //#region src-js/generated/plugin-eslint/rules/arrow-body-style.cjs
134
+ module.exports = require_arrow_body_style().create;
135
+ //#endregion