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,88 @@
1
+ //#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/init-declarations.js
2
+ /**
3
+ * @fileoverview A rule to control the style of variable initializations.
4
+ * @author Colin Ihrig
5
+ */
6
+ var require_init_declarations = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
7
+ let CONSTANT_BINDINGS = new Set([
8
+ "const",
9
+ "using",
10
+ "await using"
11
+ ]);
12
+ /**
13
+ * Checks whether or not a given node is a for loop.
14
+ * @param {ASTNode} block A node to check.
15
+ * @returns {boolean} `true` when the node is a for loop.
16
+ */
17
+ function isForLoop(block) {
18
+ return block.type === "ForInStatement" || block.type === "ForOfStatement" || block.type === "ForStatement";
19
+ }
20
+ /**
21
+ * Checks whether or not a given declarator node has its initializer.
22
+ * @param {ASTNode} node A declarator node to check.
23
+ * @returns {boolean} `true` when the node has its initializer.
24
+ */
25
+ function isInitialized(node) {
26
+ let declaration = node.parent, block = declaration.parent;
27
+ return isForLoop(block) ? block.type === "ForStatement" ? block.init === declaration : block.left === declaration : !!node.init;
28
+ }
29
+ /** @type {import('../types').Rule.RuleModule} */
30
+ module.exports = {
31
+ meta: {
32
+ type: "suggestion",
33
+ dialects: ["typescript", "javascript"],
34
+ language: "javascript",
35
+ docs: {
36
+ description: "Require or disallow initialization in variable declarations",
37
+ recommended: !1,
38
+ frozen: !0,
39
+ url: "https://eslint.org/docs/latest/rules/init-declarations"
40
+ },
41
+ schema: { anyOf: [{
42
+ type: "array",
43
+ items: [{ enum: ["always"] }],
44
+ minItems: 0,
45
+ maxItems: 1
46
+ }, {
47
+ type: "array",
48
+ items: [{ enum: ["never"] }, {
49
+ type: "object",
50
+ properties: { ignoreForLoopInit: { type: "boolean" } },
51
+ additionalProperties: !1
52
+ }],
53
+ minItems: 0,
54
+ maxItems: 2
55
+ }] },
56
+ messages: {
57
+ initialized: "Variable '{{idName}}' should be initialized on declaration.",
58
+ notInitialized: "Variable '{{idName}}' should not be initialized on declaration."
59
+ }
60
+ },
61
+ create(context) {
62
+ let MODE_ALWAYS = "always", mode = context.options[0] || MODE_ALWAYS, params = context.options[1] || {}, insideDeclaredNamespace = !1;
63
+ return {
64
+ TSModuleDeclaration(node) {
65
+ node.declare && (insideDeclaredNamespace = !0);
66
+ },
67
+ "TSModuleDeclaration:exit"(node) {
68
+ node.declare && (insideDeclaredNamespace = !1);
69
+ },
70
+ "VariableDeclaration:exit"(node) {
71
+ let kind = node.kind, declarations = node.declarations;
72
+ if (!(node.declare || insideDeclaredNamespace)) for (let i = 0; i < declarations.length; ++i) {
73
+ let declaration = declarations[i], id = declaration.id, initialized = isInitialized(declaration), isIgnoredForLoop = params.ignoreForLoopInit && isForLoop(node.parent), messageId = "";
74
+ mode === MODE_ALWAYS && !initialized ? messageId = "initialized" : mode === "never" && !CONSTANT_BINDINGS.has(kind) && initialized && !isIgnoredForLoop && (messageId = "notInitialized"), id.type === "Identifier" && messageId && context.report({
75
+ node: declaration,
76
+ messageId,
77
+ data: { idName: id.name }
78
+ });
79
+ }
80
+ }
81
+ };
82
+ }
83
+ };
84
+ }));
85
+ //#endregion
86
+ //#region src-js/generated/plugin-eslint/rules/init-declarations.cjs
87
+ module.exports = require_init_declarations().create;
88
+ //#endregion
@@ -0,0 +1,84 @@
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/jsx-quotes.js
3
+ /**
4
+ * @fileoverview A rule to ensure consistent quotes used in jsx syntax.
5
+ * @author Mathias Schreck <https://github.com/lo1tuma>
6
+ * @deprecated in ESLint v8.53.0
7
+ */
8
+ var require_jsx_quotes = /* @__PURE__ */ require_chunk.t(((exports, module) => {
9
+ let astUtils = require_ast_utils$1.t(), QUOTE_SETTINGS = {
10
+ "prefer-double": {
11
+ quote: "\"",
12
+ description: "singlequote",
13
+ convert(str) {
14
+ return str.replace(/'/gu, "\"");
15
+ }
16
+ },
17
+ "prefer-single": {
18
+ quote: "'",
19
+ description: "doublequote",
20
+ convert(str) {
21
+ return str.replace(/"/gu, "'");
22
+ }
23
+ }
24
+ };
25
+ /** @type {import('../types').Rule.RuleModule} */
26
+ module.exports = {
27
+ meta: {
28
+ deprecated: {
29
+ message: "Formatting rules are being moved out of ESLint core.",
30
+ url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
31
+ deprecatedSince: "8.53.0",
32
+ availableUntil: "11.0.0",
33
+ replacedBy: [{
34
+ message: "ESLint Stylistic now maintains deprecated stylistic core rules.",
35
+ url: "https://eslint.style/guide/migration",
36
+ plugin: {
37
+ name: "@stylistic/eslint-plugin",
38
+ url: "https://eslint.style"
39
+ },
40
+ rule: {
41
+ name: "jsx-quotes",
42
+ url: "https://eslint.style/rules/jsx-quotes"
43
+ }
44
+ }]
45
+ },
46
+ type: "layout",
47
+ docs: {
48
+ description: "Enforce the consistent use of either double or single quotes in JSX attributes",
49
+ recommended: !1,
50
+ url: "https://eslint.org/docs/latest/rules/jsx-quotes"
51
+ },
52
+ fixable: "whitespace",
53
+ schema: [{ enum: ["prefer-single", "prefer-double"] }],
54
+ messages: { unexpected: "Unexpected usage of {{description}}." }
55
+ },
56
+ create(context) {
57
+ let setting = QUOTE_SETTINGS[context.options[0] || "prefer-double"];
58
+ /**
59
+ * Checks if the given string literal node uses the expected quotes
60
+ * @param {ASTNode} node A string literal node.
61
+ * @returns {boolean} Whether or not the string literal used the expected quotes.
62
+ * @public
63
+ */
64
+ function usesExpectedQuotes(node) {
65
+ return node.value.includes(setting.quote) || astUtils.isSurroundedBy(node.raw, setting.quote);
66
+ }
67
+ return { JSXAttribute(node) {
68
+ let attributeValue = node.value;
69
+ attributeValue && astUtils.isStringLiteral(attributeValue) && !usesExpectedQuotes(attributeValue) && context.report({
70
+ node: attributeValue,
71
+ messageId: "unexpected",
72
+ data: { description: setting.description },
73
+ fix(fixer) {
74
+ return fixer.replaceText(attributeValue, setting.convert(attributeValue.raw));
75
+ }
76
+ });
77
+ } };
78
+ }
79
+ };
80
+ }));
81
+ //#endregion
82
+ //#region src-js/generated/plugin-eslint/rules/jsx-quotes.cjs
83
+ module.exports = require_jsx_quotes().create;
84
+ //#endregion
@@ -0,0 +1,399 @@
1
+ const require_chunk = require("../common/chunk.cjs"), require_ast_utils$1 = require("../common/ast-utils.cjs"), require_string_utils$1 = require("../common/string-utils.cjs");
2
+ //#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/key-spacing.js
3
+ /**
4
+ * @fileoverview Rule to specify spacing of object literal keys and values
5
+ * @author Brandon Mills
6
+ * @deprecated in ESLint v8.53.0
7
+ */
8
+ var require_key_spacing = /* @__PURE__ */ require_chunk.t(((exports, module) => {
9
+ let astUtils = require_ast_utils$1.t(), { getGraphemeCount } = require_string_utils$1.t();
10
+ /**
11
+ * Checks whether a string contains a line terminator as defined in
12
+ * http://www.ecma-international.org/ecma-262/5.1/#sec-7.3
13
+ * @param {string} str String to test.
14
+ * @returns {boolean} True if str contains a line terminator.
15
+ */
16
+ function containsLineTerminator(str) {
17
+ return astUtils.LINEBREAK_MATCHER.test(str);
18
+ }
19
+ /**
20
+ * Gets the last element of an array.
21
+ * @param {Array} arr An array.
22
+ * @returns {any} Last element of arr.
23
+ */
24
+ function last(arr) {
25
+ return arr.at(-1);
26
+ }
27
+ /**
28
+ * Checks whether a node is contained on a single line.
29
+ * @param {ASTNode} node AST Node being evaluated.
30
+ * @returns {boolean} True if the node is a single line.
31
+ */
32
+ function isSingleLine(node) {
33
+ return node.loc.end.line === node.loc.start.line;
34
+ }
35
+ /**
36
+ * Checks whether the properties on a single line.
37
+ * @param {ASTNode[]} properties List of Property AST nodes.
38
+ * @returns {boolean} True if all properties is on a single line.
39
+ */
40
+ function isSingleLineProperties(properties) {
41
+ let [firstProp] = properties, lastProp = last(properties);
42
+ return firstProp.loc.start.line === lastProp.loc.end.line;
43
+ }
44
+ /**
45
+ * Initializes a single option property from the configuration with defaults for undefined values
46
+ * @param {Object} toOptions Object to be initialized
47
+ * @param {Object} fromOptions Object to be initialized from
48
+ * @returns {Object} The object with correctly initialized options and values
49
+ */
50
+ function initOptionProperty(toOptions, fromOptions) {
51
+ return toOptions.mode = fromOptions.mode || "strict", fromOptions.beforeColon === void 0 ? toOptions.beforeColon = 0 : toOptions.beforeColon = +fromOptions.beforeColon, fromOptions.afterColon === void 0 ? toOptions.afterColon = 1 : toOptions.afterColon = +fromOptions.afterColon, fromOptions.align !== void 0 && (typeof fromOptions.align == "object" ? toOptions.align = fromOptions.align : toOptions.align = {
52
+ on: fromOptions.align,
53
+ mode: toOptions.mode,
54
+ beforeColon: toOptions.beforeColon,
55
+ afterColon: toOptions.afterColon
56
+ }), toOptions;
57
+ }
58
+ /**
59
+ * Initializes all the option values (singleLine, multiLine and align) from the configuration with defaults for undefined values
60
+ * @param {Object} toOptions Object to be initialized
61
+ * @param {Object} fromOptions Object to be initialized from
62
+ * @returns {Object} The object with correctly initialized options and values
63
+ */
64
+ function initOptions(toOptions, fromOptions) {
65
+ return typeof fromOptions.align == "object" ? (toOptions.align = initOptionProperty({}, fromOptions.align), toOptions.align.on = fromOptions.align.on || "colon", toOptions.align.mode = fromOptions.align.mode || "strict", toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions), toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions)) : (toOptions.multiLine = initOptionProperty({}, fromOptions.multiLine || fromOptions), toOptions.singleLine = initOptionProperty({}, fromOptions.singleLine || fromOptions), toOptions.multiLine.align && (toOptions.align = {
66
+ on: toOptions.multiLine.align.on,
67
+ mode: toOptions.multiLine.align.mode || toOptions.multiLine.mode,
68
+ beforeColon: toOptions.multiLine.align.beforeColon,
69
+ afterColon: toOptions.multiLine.align.afterColon
70
+ })), toOptions;
71
+ }
72
+ /** @type {import('../types').Rule.RuleModule} */
73
+ module.exports = {
74
+ meta: {
75
+ deprecated: {
76
+ message: "Formatting rules are being moved out of ESLint core.",
77
+ url: "https://eslint.org/blog/2023/10/deprecating-formatting-rules/",
78
+ deprecatedSince: "8.53.0",
79
+ availableUntil: "11.0.0",
80
+ replacedBy: [{
81
+ message: "ESLint Stylistic now maintains deprecated stylistic core rules.",
82
+ url: "https://eslint.style/guide/migration",
83
+ plugin: {
84
+ name: "@stylistic/eslint-plugin",
85
+ url: "https://eslint.style"
86
+ },
87
+ rule: {
88
+ name: "key-spacing",
89
+ url: "https://eslint.style/rules/key-spacing"
90
+ }
91
+ }]
92
+ },
93
+ type: "layout",
94
+ docs: {
95
+ description: "Enforce consistent spacing between keys and values in object literal properties",
96
+ recommended: !1,
97
+ url: "https://eslint.org/docs/latest/rules/key-spacing"
98
+ },
99
+ fixable: "whitespace",
100
+ schema: [{ anyOf: [
101
+ {
102
+ type: "object",
103
+ properties: {
104
+ align: { anyOf: [{ enum: ["colon", "value"] }, {
105
+ type: "object",
106
+ properties: {
107
+ mode: { enum: ["strict", "minimum"] },
108
+ on: { enum: ["colon", "value"] },
109
+ beforeColon: { type: "boolean" },
110
+ afterColon: { type: "boolean" }
111
+ },
112
+ additionalProperties: !1
113
+ }] },
114
+ mode: { enum: ["strict", "minimum"] },
115
+ beforeColon: { type: "boolean" },
116
+ afterColon: { type: "boolean" }
117
+ },
118
+ additionalProperties: !1
119
+ },
120
+ {
121
+ type: "object",
122
+ properties: {
123
+ singleLine: {
124
+ type: "object",
125
+ properties: {
126
+ mode: { enum: ["strict", "minimum"] },
127
+ beforeColon: { type: "boolean" },
128
+ afterColon: { type: "boolean" }
129
+ },
130
+ additionalProperties: !1
131
+ },
132
+ multiLine: {
133
+ type: "object",
134
+ properties: {
135
+ align: { anyOf: [{ enum: ["colon", "value"] }, {
136
+ type: "object",
137
+ properties: {
138
+ mode: { enum: ["strict", "minimum"] },
139
+ on: { enum: ["colon", "value"] },
140
+ beforeColon: { type: "boolean" },
141
+ afterColon: { type: "boolean" }
142
+ },
143
+ additionalProperties: !1
144
+ }] },
145
+ mode: { enum: ["strict", "minimum"] },
146
+ beforeColon: { type: "boolean" },
147
+ afterColon: { type: "boolean" }
148
+ },
149
+ additionalProperties: !1
150
+ }
151
+ },
152
+ additionalProperties: !1
153
+ },
154
+ {
155
+ type: "object",
156
+ properties: {
157
+ singleLine: {
158
+ type: "object",
159
+ properties: {
160
+ mode: { enum: ["strict", "minimum"] },
161
+ beforeColon: { type: "boolean" },
162
+ afterColon: { type: "boolean" }
163
+ },
164
+ additionalProperties: !1
165
+ },
166
+ multiLine: {
167
+ type: "object",
168
+ properties: {
169
+ mode: { enum: ["strict", "minimum"] },
170
+ beforeColon: { type: "boolean" },
171
+ afterColon: { type: "boolean" }
172
+ },
173
+ additionalProperties: !1
174
+ },
175
+ align: {
176
+ type: "object",
177
+ properties: {
178
+ mode: { enum: ["strict", "minimum"] },
179
+ on: { enum: ["colon", "value"] },
180
+ beforeColon: { type: "boolean" },
181
+ afterColon: { type: "boolean" }
182
+ },
183
+ additionalProperties: !1
184
+ }
185
+ },
186
+ additionalProperties: !1
187
+ }
188
+ ] }],
189
+ messages: {
190
+ extraKey: "Extra space after {{computed}}key '{{key}}'.",
191
+ extraValue: "Extra space before value for {{computed}}key '{{key}}'.",
192
+ missingKey: "Missing space after {{computed}}key '{{key}}'.",
193
+ missingValue: "Missing space before value for {{computed}}key '{{key}}'."
194
+ }
195
+ },
196
+ create(context) {
197
+ /**
198
+ * OPTIONS
199
+ * "key-spacing": [2, {
200
+ * beforeColon: false,
201
+ * afterColon: true,
202
+ * align: "colon" // Optional, or "value"
203
+ * }
204
+ */
205
+ let ruleOptions = initOptions({}, context.options[0] || {}), multiLineOptions = ruleOptions.multiLine, singleLineOptions = ruleOptions.singleLine, alignmentOptions = ruleOptions.align || null, sourceCode = context.sourceCode;
206
+ /**
207
+ * Determines if the given property is key-value property.
208
+ * @param {ASTNode} property Property node to check.
209
+ * @returns {boolean} Whether the property is a key-value property.
210
+ */
211
+ function isKeyValueProperty(property) {
212
+ return !(property.method || property.shorthand || property.kind !== "init" || property.type !== "Property");
213
+ }
214
+ /**
215
+ * Starting from the given node (a property.key node here) looks forward
216
+ * until it finds the colon punctuator and returns it.
217
+ * @param {ASTNode} node The node to start looking from.
218
+ * @returns {ASTNode} The colon punctuator.
219
+ */
220
+ function getNextColon(node) {
221
+ return sourceCode.getTokenAfter(node, astUtils.isColonToken);
222
+ }
223
+ /**
224
+ * Starting from the given node (a property.key node here) looks forward
225
+ * until it finds the last token before a colon punctuator and returns it.
226
+ * @param {ASTNode} node The node to start looking from.
227
+ * @returns {ASTNode} The last token before a colon punctuator.
228
+ */
229
+ function getLastTokenBeforeColon(node) {
230
+ let colonToken = getNextColon(node);
231
+ return sourceCode.getTokenBefore(colonToken);
232
+ }
233
+ /**
234
+ * Starting from the given node (a property.key node here) looks forward
235
+ * until it finds the first token after a colon punctuator and returns it.
236
+ * @param {ASTNode} node The node to start looking from.
237
+ * @returns {ASTNode} The first token after a colon punctuator.
238
+ */
239
+ function getFirstTokenAfterColon(node) {
240
+ let colonToken = getNextColon(node);
241
+ return sourceCode.getTokenAfter(colonToken);
242
+ }
243
+ /**
244
+ * Checks whether a property is a member of the property group it follows.
245
+ * @param {ASTNode} lastMember The last Property known to be in the group.
246
+ * @param {ASTNode} candidate The next Property that might be in the group.
247
+ * @returns {boolean} True if the candidate property is part of the group.
248
+ */
249
+ function continuesPropertyGroup(lastMember, candidate) {
250
+ let groupEndLine = lastMember.loc.start.line, candidateValueStartLine = (isKeyValueProperty(candidate) ? getFirstTokenAfterColon(candidate.key) : candidate).loc.start.line;
251
+ if (candidateValueStartLine - groupEndLine <= 1) return !0;
252
+ let leadingComments = sourceCode.getCommentsBefore(candidate);
253
+ if (leadingComments.length && leadingComments[0].loc.start.line - groupEndLine <= 1 && candidateValueStartLine - last(leadingComments).loc.end.line <= 1) {
254
+ for (let i = 1; i < leadingComments.length; i++) if (leadingComments[i].loc.start.line - leadingComments[i - 1].loc.end.line > 1) return !1;
255
+ return !0;
256
+ }
257
+ return !1;
258
+ }
259
+ /**
260
+ * Gets an object literal property's key as the identifier name or string value.
261
+ * @param {ASTNode} property Property node whose key to retrieve.
262
+ * @returns {string} The property's key.
263
+ */
264
+ function getKey(property) {
265
+ let key = property.key;
266
+ return property.computed ? sourceCode.getText().slice(key.range[0], key.range[1]) : astUtils.getStaticPropertyName(property);
267
+ }
268
+ /**
269
+ * Reports an appropriately-formatted error if spacing is incorrect on one
270
+ * side of the colon.
271
+ * @param {ASTNode} property Key-value pair in an object literal.
272
+ * @param {string} side Side being verified - either "key" or "value".
273
+ * @param {string} whitespace Actual whitespace string.
274
+ * @param {number} expected Expected whitespace length.
275
+ * @param {string} mode Value of the mode as "strict" or "minimum"
276
+ * @returns {void}
277
+ */
278
+ function report(property, side, whitespace, expected, mode) {
279
+ let diff = whitespace.length - expected;
280
+ if ((diff && mode === "strict" || diff < 0 && mode === "minimum" || diff > 0 && !expected && mode === "minimum") && !(expected && containsLineTerminator(whitespace))) {
281
+ let nextColon = getNextColon(property.key), tokenBeforeColon = sourceCode.getTokenBefore(nextColon, { includeComments: !0 }), tokenAfterColon = sourceCode.getTokenAfter(nextColon, { includeComments: !0 }), isKeySide = side === "key", isExtra = diff > 0, diffAbs = Math.abs(diff), spaces = Array(diffAbs + 1).join(" "), locStart = isKeySide ? tokenBeforeColon.loc.end : nextColon.loc.start, locEnd = isKeySide ? nextColon.loc.start : tokenAfterColon.loc.start, missingLoc = isKeySide ? tokenBeforeColon.loc : tokenAfterColon.loc, loc = isExtra ? {
282
+ start: locStart,
283
+ end: locEnd
284
+ } : missingLoc, fix;
285
+ if (isExtra) {
286
+ let range;
287
+ range = isKeySide ? [tokenBeforeColon.range[1], tokenBeforeColon.range[1] + diffAbs] : [tokenAfterColon.range[0] - diffAbs, tokenAfterColon.range[0]], fix = function(fixer) {
288
+ return fixer.removeRange(range);
289
+ };
290
+ } else fix = isKeySide ? function(fixer) {
291
+ return fixer.insertTextAfter(tokenBeforeColon, spaces);
292
+ } : function(fixer) {
293
+ return fixer.insertTextBefore(tokenAfterColon, spaces);
294
+ };
295
+ let messageId;
296
+ messageId = isExtra ? side === "key" ? "extraKey" : "extraValue" : side === "key" ? "missingKey" : "missingValue", context.report({
297
+ node: property[side],
298
+ loc,
299
+ messageId,
300
+ data: {
301
+ computed: property.computed ? "computed " : "",
302
+ key: getKey(property)
303
+ },
304
+ fix
305
+ });
306
+ }
307
+ }
308
+ /**
309
+ * Gets the number of characters in a key, including quotes around string
310
+ * keys and braces around computed property keys.
311
+ * @param {ASTNode} property Property of on object literal.
312
+ * @returns {number} Width of the key.
313
+ */
314
+ function getKeyWidth(property) {
315
+ let startToken = sourceCode.getFirstToken(property), endToken = getLastTokenBeforeColon(property.key);
316
+ return getGraphemeCount(sourceCode.getText().slice(startToken.range[0], endToken.range[1]));
317
+ }
318
+ /**
319
+ * Gets the whitespace around the colon in an object literal property.
320
+ * @param {ASTNode} property Property node from an object literal.
321
+ * @returns {Object} Whitespace before and after the property's colon.
322
+ */
323
+ function getPropertyWhitespace(property) {
324
+ let whitespace = /(\s*):(\s*)/u.exec(sourceCode.getText().slice(property.key.range[1], property.value.range[0]));
325
+ return whitespace ? {
326
+ beforeColon: whitespace[1],
327
+ afterColon: whitespace[2]
328
+ } : null;
329
+ }
330
+ /**
331
+ * Creates groups of properties.
332
+ * @param {ASTNode} node ObjectExpression node being evaluated.
333
+ * @returns {Array<ASTNode[]>} Groups of property AST node lists.
334
+ */
335
+ function createGroups(node) {
336
+ return node.properties.length === 1 ? [node.properties] : node.properties.reduce((groups, property) => {
337
+ let currentGroup = last(groups), prev = last(currentGroup);
338
+ return !prev || continuesPropertyGroup(prev, property) ? currentGroup.push(property) : groups.push([property]), groups;
339
+ }, [[]]);
340
+ }
341
+ /**
342
+ * Verifies correct vertical alignment of a group of properties.
343
+ * @param {ASTNode[]} properties List of Property AST nodes.
344
+ * @returns {void}
345
+ */
346
+ function verifyGroupAlignment(properties) {
347
+ let length = properties.length, widths = properties.map(getKeyWidth), align = alignmentOptions.on, targetWidth = Math.max(...widths), beforeColon, afterColon, mode;
348
+ alignmentOptions && length > 1 ? (beforeColon = alignmentOptions.beforeColon, afterColon = alignmentOptions.afterColon, mode = alignmentOptions.mode) : (beforeColon = multiLineOptions.beforeColon, afterColon = multiLineOptions.afterColon, mode = alignmentOptions.mode), targetWidth += align === "colon" ? beforeColon : afterColon;
349
+ for (let i = 0; i < length; i++) {
350
+ let property = properties[i], whitespace = getPropertyWhitespace(property);
351
+ if (whitespace) {
352
+ let width = widths[i];
353
+ align === "value" ? (report(property, "key", whitespace.beforeColon, beforeColon, mode), report(property, "value", whitespace.afterColon, targetWidth - width, mode)) : (report(property, "key", whitespace.beforeColon, targetWidth - width, mode), report(property, "value", whitespace.afterColon, afterColon, mode));
354
+ }
355
+ }
356
+ }
357
+ /**
358
+ * Verifies spacing of property conforms to specified options.
359
+ * @param {ASTNode} node Property node being evaluated.
360
+ * @param {Object} lineOptions Configured singleLine or multiLine options
361
+ * @returns {void}
362
+ */
363
+ function verifySpacing(node, lineOptions) {
364
+ let actual = getPropertyWhitespace(node);
365
+ actual && (report(node, "key", actual.beforeColon, lineOptions.beforeColon, lineOptions.mode), report(node, "value", actual.afterColon, lineOptions.afterColon, lineOptions.mode));
366
+ }
367
+ /**
368
+ * Verifies spacing of each property in a list.
369
+ * @param {ASTNode[]} properties List of Property AST nodes.
370
+ * @param {Object} lineOptions Configured singleLine or multiLine options
371
+ * @returns {void}
372
+ */
373
+ function verifyListSpacing(properties, lineOptions) {
374
+ let length = properties.length;
375
+ for (let i = 0; i < length; i++) verifySpacing(properties[i], lineOptions);
376
+ }
377
+ /**
378
+ * Verifies vertical alignment, taking into account groups of properties.
379
+ * @param {ASTNode} node ObjectExpression node being evaluated.
380
+ * @returns {void}
381
+ */
382
+ function verifyAlignment(node) {
383
+ createGroups(node).forEach((group) => {
384
+ let properties = group.filter(isKeyValueProperty);
385
+ properties.length > 0 && isSingleLineProperties(properties) ? verifyListSpacing(properties, multiLineOptions) : verifyGroupAlignment(properties);
386
+ });
387
+ }
388
+ return alignmentOptions ? { ObjectExpression(node) {
389
+ isSingleLine(node) ? verifyListSpacing(node.properties.filter(isKeyValueProperty), singleLineOptions) : verifyAlignment(node);
390
+ } } : { Property(node) {
391
+ verifySpacing(node, isSingleLine(node.parent) ? singleLineOptions : multiLineOptions);
392
+ } };
393
+ }
394
+ };
395
+ }));
396
+ //#endregion
397
+ //#region src-js/generated/plugin-eslint/rules/key-spacing.cjs
398
+ module.exports = require_key_spacing().create;
399
+ //#endregion