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,123 @@
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/no-restricted-properties.js
3
+ /**
4
+ * @fileoverview Rule to disallow certain object properties
5
+ * @author Will Klein & Eli White
6
+ */
7
+ var require_no_restricted_properties = /* @__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
+ docs: {
14
+ description: "Disallow certain properties on certain objects",
15
+ recommended: !1,
16
+ url: "https://eslint.org/docs/latest/rules/no-restricted-properties"
17
+ },
18
+ schema: {
19
+ type: "array",
20
+ items: {
21
+ type: "object",
22
+ properties: {
23
+ object: { type: "string" },
24
+ property: { type: "string" },
25
+ allowObjects: {
26
+ type: "array",
27
+ items: { type: "string" },
28
+ uniqueItems: !0
29
+ },
30
+ allowProperties: {
31
+ type: "array",
32
+ items: { type: "string" },
33
+ uniqueItems: !0
34
+ },
35
+ message: { type: "string" }
36
+ },
37
+ anyOf: [{ required: ["object"] }, { required: ["property"] }],
38
+ not: { anyOf: [{ required: ["allowObjects", "object"] }, { required: ["allowProperties", "property"] }] },
39
+ additionalProperties: !1
40
+ },
41
+ uniqueItems: !0
42
+ },
43
+ messages: {
44
+ restrictedObjectProperty: "'{{objectName}}.{{propertyName}}' is restricted from being used.{{allowedPropertiesMessage}}{{message}}",
45
+ restrictedProperty: "'{{propertyName}}' is restricted from being used.{{allowedObjectsMessage}}{{message}}"
46
+ }
47
+ },
48
+ create(context) {
49
+ let restrictedCalls = context.options;
50
+ if (restrictedCalls.length === 0) return {};
51
+ let restrictedProperties = /* @__PURE__ */ new Map(), globallyRestrictedObjects = /* @__PURE__ */ new Map(), globallyRestrictedProperties = /* @__PURE__ */ new Map();
52
+ restrictedCalls.forEach((option) => {
53
+ let objectName = option.object, propertyName = option.property;
54
+ objectName === void 0 ? globallyRestrictedProperties.set(propertyName, {
55
+ allowObjects: option.allowObjects,
56
+ message: option.message
57
+ }) : propertyName === void 0 ? globallyRestrictedObjects.set(objectName, {
58
+ allowProperties: option.allowProperties,
59
+ message: option.message
60
+ }) : (restrictedProperties.has(objectName) || restrictedProperties.set(objectName, /* @__PURE__ */ new Map()), restrictedProperties.get(objectName).set(propertyName, { message: option.message }));
61
+ });
62
+ /**
63
+ * Checks if a name is in the allowed list.
64
+ * @param {string} name The name to check
65
+ * @param {string[]} [allowedList] The list of allowed names
66
+ * @returns {boolean} True if the name is allowed, false otherwise
67
+ */
68
+ function isAllowed(name, allowedList) {
69
+ return allowedList ? allowedList.includes(name) : !1;
70
+ }
71
+ /**
72
+ * Checks to see whether a property access is restricted, and reports it if so.
73
+ * @param {ASTNode} node The node to report
74
+ * @param {string} objectName The name of the object
75
+ * @param {string} propertyName The name of the property
76
+ * @returns {undefined}
77
+ */
78
+ function checkPropertyAccess(node, objectName, propertyName) {
79
+ if (propertyName === null) return;
80
+ let matchedObject = restrictedProperties.get(objectName), matchedObjectProperty = matchedObject ? matchedObject.get(propertyName) : globallyRestrictedObjects.get(objectName), globalMatchedProperty = globallyRestrictedProperties.get(propertyName);
81
+ if (matchedObjectProperty && !isAllowed(propertyName, matchedObjectProperty.allowProperties)) {
82
+ let message = matchedObjectProperty.message ? ` ${matchedObjectProperty.message}` : "", allowedPropertiesMessage = matchedObjectProperty.allowProperties ? ` Only these properties are allowed: ${matchedObjectProperty.allowProperties.join(", ")}.` : "";
83
+ context.report({
84
+ node,
85
+ messageId: "restrictedObjectProperty",
86
+ data: {
87
+ objectName,
88
+ propertyName,
89
+ message,
90
+ allowedPropertiesMessage
91
+ }
92
+ });
93
+ } else if (globalMatchedProperty && !isAllowed(objectName, globalMatchedProperty.allowObjects)) {
94
+ let message = globalMatchedProperty.message ? ` ${globalMatchedProperty.message}` : "", allowedObjectsMessage = globalMatchedProperty.allowObjects ? ` Property '${propertyName}' is only allowed on these objects: ${globalMatchedProperty.allowObjects.join(", ")}.` : "";
95
+ context.report({
96
+ node,
97
+ messageId: "restrictedProperty",
98
+ data: {
99
+ propertyName,
100
+ message,
101
+ allowedObjectsMessage
102
+ }
103
+ });
104
+ }
105
+ }
106
+ return {
107
+ MemberExpression(node) {
108
+ checkPropertyAccess(node, node.object && node.object.name, astUtils.getStaticPropertyName(node));
109
+ },
110
+ ObjectPattern(node) {
111
+ let objectName = null;
112
+ node.parent.type === "VariableDeclarator" ? node.parent.init && node.parent.init.type === "Identifier" && (objectName = node.parent.init.name) : (node.parent.type === "AssignmentExpression" || node.parent.type === "AssignmentPattern") && node.parent.right.type === "Identifier" && (objectName = node.parent.right.name), node.properties.forEach((property) => {
113
+ checkPropertyAccess(node, objectName, astUtils.getStaticPropertyName(property));
114
+ });
115
+ }
116
+ };
117
+ }
118
+ };
119
+ }));
120
+ //#endregion
121
+ //#region src-js/generated/plugin-eslint/rules/no-restricted-properties.cjs
122
+ module.exports = require_no_restricted_properties().create;
123
+ //#endregion
@@ -0,0 +1,49 @@
1
+ //#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-restricted-syntax.js
2
+ /**
3
+ * @fileoverview Rule to flag use of certain node types
4
+ * @author Burak Yigit Kaya
5
+ */
6
+ var require_no_restricted_syntax = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
7
+ /** @type {import('../types').Rule.RuleModule} */
8
+ module.exports = {
9
+ meta: {
10
+ type: "suggestion",
11
+ docs: {
12
+ description: "Disallow specified syntax",
13
+ recommended: !1,
14
+ url: "https://eslint.org/docs/latest/rules/no-restricted-syntax"
15
+ },
16
+ schema: {
17
+ type: "array",
18
+ items: { oneOf: [{ type: "string" }, {
19
+ type: "object",
20
+ properties: {
21
+ selector: { type: "string" },
22
+ message: { type: "string" }
23
+ },
24
+ required: ["selector"],
25
+ additionalProperties: !1
26
+ }] },
27
+ uniqueItems: !0,
28
+ minItems: 0
29
+ },
30
+ messages: { restrictedSyntax: "{{message}}" }
31
+ },
32
+ create(context) {
33
+ return context.options.reduce((result, selectorOrObject) => {
34
+ let isStringFormat = typeof selectorOrObject == "string", hasCustomMessage = !isStringFormat && !!selectorOrObject.message, selector = isStringFormat ? selectorOrObject : selectorOrObject.selector, message = hasCustomMessage ? selectorOrObject.message : `Using '${selector}' is not allowed.`;
35
+ return Object.assign(result, { [selector](node) {
36
+ context.report({
37
+ node,
38
+ messageId: "restrictedSyntax",
39
+ data: { message }
40
+ });
41
+ } });
42
+ }, {});
43
+ }
44
+ };
45
+ }));
46
+ //#endregion
47
+ //#region src-js/generated/plugin-eslint/rules/no-restricted-syntax.cjs
48
+ module.exports = require_no_restricted_syntax().create;
49
+ //#endregion
@@ -0,0 +1,45 @@
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/no-return-assign.js
3
+ /**
4
+ * @fileoverview Rule to flag when return statement contains assignment
5
+ * @author Ilya Volodin
6
+ */
7
+ var require_no_return_assign = /* @__PURE__ */ require_chunk.t(((exports, module) => {
8
+ let astUtils = require_ast_utils$1.t(), SENTINEL_TYPE = /^(?:[a-zA-Z]+?Statement|ArrowFunctionExpression|FunctionExpression|ClassExpression)$/u;
9
+ /** @type {import('../types').Rule.RuleModule} */
10
+ module.exports = {
11
+ meta: {
12
+ type: "suggestion",
13
+ defaultOptions: ["except-parens"],
14
+ docs: {
15
+ description: "Disallow assignment operators in `return` statements",
16
+ recommended: !1,
17
+ url: "https://eslint.org/docs/latest/rules/no-return-assign"
18
+ },
19
+ schema: [{ enum: ["except-parens", "always"] }],
20
+ messages: {
21
+ returnAssignment: "Return statement should not contain assignment.",
22
+ arrowAssignment: "Arrow function should not return assignment."
23
+ }
24
+ },
25
+ create(context) {
26
+ let always = context.options[0] !== "except-parens", sourceCode = context.sourceCode;
27
+ return { AssignmentExpression(node) {
28
+ if (!always && astUtils.isParenthesised(sourceCode, node)) return;
29
+ let currentChild = node, parent = currentChild.parent;
30
+ for (; parent && !SENTINEL_TYPE.test(parent.type);) currentChild = parent, parent = parent.parent;
31
+ parent && parent.type === "ReturnStatement" ? context.report({
32
+ node: parent,
33
+ messageId: "returnAssignment"
34
+ }) : parent && parent.type === "ArrowFunctionExpression" && parent.body === currentChild && context.report({
35
+ node: parent,
36
+ messageId: "arrowAssignment"
37
+ });
38
+ } };
39
+ }
40
+ };
41
+ }));
42
+ //#endregion
43
+ //#region src-js/generated/plugin-eslint/rules/no-return-assign.cjs
44
+ module.exports = require_no_return_assign().create;
45
+ //#endregion
@@ -0,0 +1,88 @@
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/no-return-await.js
3
+ /**
4
+ * @fileoverview Disallows unnecessary `return await`
5
+ * @author Jordan Harband
6
+ * @deprecated in ESLint v8.46.0
7
+ */
8
+ var require_no_return_await = /* @__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
+ hasSuggestions: !0,
14
+ type: "suggestion",
15
+ docs: {
16
+ description: "Disallow unnecessary `return await`",
17
+ recommended: !1,
18
+ url: "https://eslint.org/docs/latest/rules/no-return-await"
19
+ },
20
+ fixable: null,
21
+ deprecated: {
22
+ message: "The original assumption of the rule no longer holds true because of engine optimization.",
23
+ deprecatedSince: "8.46.0",
24
+ availableUntil: null,
25
+ replacedBy: []
26
+ },
27
+ schema: [],
28
+ messages: {
29
+ removeAwait: "Remove redundant `await`.",
30
+ redundantUseOfAwait: "Redundant use of `await` on a return value."
31
+ }
32
+ },
33
+ create(context) {
34
+ /**
35
+ * Reports a found unnecessary `await` expression.
36
+ * @param {ASTNode} node The node representing the `await` expression to report
37
+ * @returns {void}
38
+ */
39
+ function reportUnnecessaryAwait(node) {
40
+ context.report({
41
+ node: context.sourceCode.getFirstToken(node),
42
+ loc: node.loc,
43
+ messageId: "redundantUseOfAwait",
44
+ suggest: [{
45
+ messageId: "removeAwait",
46
+ fix(fixer) {
47
+ let sourceCode = context.sourceCode, [awaitToken, tokenAfterAwait] = sourceCode.getFirstTokens(node, 2);
48
+ if (awaitToken.loc.start.line !== tokenAfterAwait.loc.start.line) return null;
49
+ let [startOfAwait, endOfAwait] = awaitToken.range, range = [startOfAwait, endOfAwait + (sourceCode.text[endOfAwait] === " " ? 1 : 0)];
50
+ return fixer.removeRange(range);
51
+ }
52
+ }]
53
+ });
54
+ }
55
+ /**
56
+ * Determines whether a thrown error from this node will be caught/handled within this function rather than immediately halting
57
+ * this function. For example, a statement in a `try` block will always have an error handler. A statement in
58
+ * a `catch` block will only have an error handler if there is also a `finally` block.
59
+ * @param {ASTNode} node A node representing a location where an could be thrown
60
+ * @returns {boolean} `true` if a thrown error will be caught/handled in this function
61
+ */
62
+ function hasErrorHandler(node) {
63
+ let ancestor = node;
64
+ for (; !astUtils.isFunction(ancestor) && ancestor.type !== "Program";) {
65
+ if (ancestor.parent.type === "TryStatement" && (ancestor === ancestor.parent.block || ancestor === ancestor.parent.handler && ancestor.parent.finalizer)) return !0;
66
+ ancestor = ancestor.parent;
67
+ }
68
+ return !1;
69
+ }
70
+ /**
71
+ * Checks if a node is placed in tail call position. Once `return` arguments (or arrow function expressions) can be a complex expression,
72
+ * an `await` expression could or could not be unnecessary by the definition of this rule. So we're looking for `await` expressions that are in tail position.
73
+ * @param {ASTNode} node A node representing the `await` expression to check
74
+ * @returns {boolean} The checking result
75
+ */
76
+ function isInTailCallPosition(node) {
77
+ return node.parent.type === "ArrowFunctionExpression" ? !0 : node.parent.type === "ReturnStatement" ? !hasErrorHandler(node.parent) : node.parent.type === "ConditionalExpression" && (node === node.parent.consequent || node === node.parent.alternate) || node.parent.type === "LogicalExpression" && node === node.parent.right || node.parent.type === "SequenceExpression" && node === node.parent.expressions.at(-1) ? isInTailCallPosition(node.parent) : !1;
78
+ }
79
+ return { AwaitExpression(node) {
80
+ isInTailCallPosition(node) && !hasErrorHandler(node) && reportUnnecessaryAwait(node);
81
+ } };
82
+ }
83
+ };
84
+ }));
85
+ //#endregion
86
+ //#region src-js/generated/plugin-eslint/rules/no-return-await.cjs
87
+ module.exports = require_no_return_await().create;
88
+ //#endregion
@@ -0,0 +1,49 @@
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/no-script-url.js
3
+ /**
4
+ * @fileoverview Rule to disallow `javascript:` URLs
5
+ * @author Ilya Volodin
6
+ */
7
+ var require_no_script_url = /* @__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
+ docs: {
14
+ description: "Disallow `javascript:` URLs",
15
+ recommended: !1,
16
+ url: "https://eslint.org/docs/latest/rules/no-script-url"
17
+ },
18
+ schema: [],
19
+ messages: { unexpectedScriptURL: "Script URL is a form of eval." }
20
+ },
21
+ create(context) {
22
+ /**
23
+ * Check whether a node's static value starts with `javascript:` or not.
24
+ * And report an error for unexpected script URL.
25
+ * @param {ASTNode} node node to check
26
+ * @returns {void}
27
+ */
28
+ function check(node) {
29
+ let value = astUtils.getStaticStringValue(node);
30
+ typeof value == "string" && value.toLowerCase().indexOf("javascript:") === 0 && context.report({
31
+ node,
32
+ messageId: "unexpectedScriptURL"
33
+ });
34
+ }
35
+ return {
36
+ Literal(node) {
37
+ node.value && typeof node.value == "string" && check(node);
38
+ },
39
+ TemplateLiteral(node) {
40
+ node.parent && node.parent.type === "TaggedTemplateExpression" || check(node);
41
+ }
42
+ };
43
+ }
44
+ };
45
+ }));
46
+ //#endregion
47
+ //#region src-js/generated/plugin-eslint/rules/no-script-url.cjs
48
+ module.exports = require_no_script_url().create;
49
+ //#endregion
@@ -0,0 +1,88 @@
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/no-self-assign.js
3
+ /**
4
+ * @fileoverview Rule to disallow assignments where both sides are exactly the same
5
+ * @author Toru Nagashima
6
+ */
7
+ var require_no_self_assign = /* @__PURE__ */ require_chunk.t(((exports, module) => {
8
+ let astUtils = require_ast_utils$1.t(), SPACES = /\s+/gu;
9
+ /**
10
+ * Traverses 2 Pattern nodes in parallel, then reports self-assignments.
11
+ * @param {ASTNode|null} left A left node to traverse. This is a Pattern or
12
+ * a Property.
13
+ * @param {ASTNode|null} right A right node to traverse. This is a Pattern or
14
+ * a Property.
15
+ * @param {boolean} props The flag to check member expressions as well.
16
+ * @param {Function} report A callback function to report.
17
+ * @returns {void}
18
+ */
19
+ function eachSelfAssignment(left, right, props, report) {
20
+ if (!(!left || !right)) if (left.type === "Identifier" && right.type === "Identifier" && left.name === right.name) report(right);
21
+ else if (left.type === "ArrayPattern" && right.type === "ArrayExpression") {
22
+ let end = Math.min(left.elements.length, right.elements.length);
23
+ for (let i = 0; i < end; ++i) {
24
+ let leftElement = left.elements[i], rightElement = right.elements[i];
25
+ if (leftElement && leftElement.type === "RestElement" && i < right.elements.length - 1 || (eachSelfAssignment(leftElement, rightElement, props, report), rightElement && rightElement.type === "SpreadElement")) break;
26
+ }
27
+ } else if (left.type === "RestElement" && right.type === "SpreadElement") eachSelfAssignment(left.argument, right.argument, props, report);
28
+ else if (left.type === "ObjectPattern" && right.type === "ObjectExpression" && right.properties.length >= 1) {
29
+ let startJ = 0;
30
+ for (let i = right.properties.length - 1; i >= 0; --i) {
31
+ let propType = right.properties[i].type;
32
+ if (propType === "SpreadElement" || propType === "ExperimentalSpreadProperty") {
33
+ startJ = i + 1;
34
+ break;
35
+ }
36
+ }
37
+ for (let i = 0; i < left.properties.length; ++i) for (let j = startJ; j < right.properties.length; ++j) eachSelfAssignment(left.properties[i], right.properties[j], props, report);
38
+ } else if (left.type === "Property" && right.type === "Property" && right.kind === "init" && !right.method) {
39
+ let leftName = astUtils.getStaticPropertyName(left);
40
+ leftName !== null && leftName === astUtils.getStaticPropertyName(right) && eachSelfAssignment(left.value, right.value, props, report);
41
+ } else props && astUtils.skipChainExpression(left).type === "MemberExpression" && astUtils.skipChainExpression(right).type === "MemberExpression" && astUtils.isSameReference(left, right) && report(right);
42
+ }
43
+ /** @type {import('../types').Rule.RuleModule} */
44
+ module.exports = {
45
+ meta: {
46
+ type: "problem",
47
+ defaultOptions: [{ props: !0 }],
48
+ docs: {
49
+ description: "Disallow assignments where both sides are exactly the same",
50
+ recommended: !0,
51
+ url: "https://eslint.org/docs/latest/rules/no-self-assign"
52
+ },
53
+ schema: [{
54
+ type: "object",
55
+ properties: { props: { type: "boolean" } },
56
+ additionalProperties: !1
57
+ }],
58
+ messages: { selfAssignment: "'{{name}}' is assigned to itself." }
59
+ },
60
+ create(context) {
61
+ let sourceCode = context.sourceCode, [{ props }] = context.options;
62
+ /**
63
+ * Reports a given node as self assignments.
64
+ * @param {ASTNode} node A node to report. This is an Identifier node.
65
+ * @returns {void}
66
+ */
67
+ function report(node) {
68
+ context.report({
69
+ node,
70
+ messageId: "selfAssignment",
71
+ data: { name: sourceCode.getText(node).replace(SPACES, "") }
72
+ });
73
+ }
74
+ return { AssignmentExpression(node) {
75
+ [
76
+ "=",
77
+ "&&=",
78
+ "||=",
79
+ "??="
80
+ ].includes(node.operator) && eachSelfAssignment(node.left, node.right, props, report);
81
+ } };
82
+ }
83
+ };
84
+ }));
85
+ //#endregion
86
+ //#region src-js/generated/plugin-eslint/rules/no-self-assign.cjs
87
+ module.exports = require_no_self_assign().create;
88
+ //#endregion
@@ -0,0 +1,53 @@
1
+ //#region ../../node_modules/.pnpm/eslint@9.39.3_jiti@2.6.1/node_modules/eslint/lib/rules/no-self-compare.js
2
+ /**
3
+ * @fileoverview Rule to flag comparison where left part is the same as the right
4
+ * part.
5
+ * @author Ilya Volodin
6
+ */
7
+ var require_no_self_compare = /* @__PURE__ */ require("../common/chunk.cjs").t(((exports, module) => {
8
+ /** @type {import('../types').Rule.RuleModule} */
9
+ module.exports = {
10
+ meta: {
11
+ type: "problem",
12
+ docs: {
13
+ description: "Disallow comparisons where both sides are exactly the same",
14
+ recommended: !1,
15
+ url: "https://eslint.org/docs/latest/rules/no-self-compare"
16
+ },
17
+ schema: [],
18
+ messages: { comparingToSelf: "Comparing to itself is potentially pointless." }
19
+ },
20
+ create(context) {
21
+ let sourceCode = context.sourceCode;
22
+ /**
23
+ * Determines whether two nodes are composed of the same tokens.
24
+ * @param {ASTNode} nodeA The first node
25
+ * @param {ASTNode} nodeB The second node
26
+ * @returns {boolean} true if the nodes have identical token representations
27
+ */
28
+ function hasSameTokens(nodeA, nodeB) {
29
+ let tokensA = sourceCode.getTokens(nodeA), tokensB = sourceCode.getTokens(nodeB);
30
+ return tokensA.length === tokensB.length && tokensA.every((token, index) => token.type === tokensB[index].type && token.value === tokensB[index].value);
31
+ }
32
+ return { BinaryExpression(node) {
33
+ new Set([
34
+ "===",
35
+ "==",
36
+ "!==",
37
+ "!=",
38
+ ">",
39
+ "<",
40
+ ">=",
41
+ "<="
42
+ ]).has(node.operator) && hasSameTokens(node.left, node.right) && context.report({
43
+ node,
44
+ messageId: "comparingToSelf"
45
+ });
46
+ } };
47
+ }
48
+ };
49
+ }));
50
+ //#endregion
51
+ //#region src-js/generated/plugin-eslint/rules/no-self-compare.cjs
52
+ module.exports = require_no_self_compare().create;
53
+ //#endregion
@@ -0,0 +1,81 @@
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/no-sequences.js
3
+ /**
4
+ * @fileoverview Rule to flag use of comma operator
5
+ * @author Brandon Mills
6
+ */
7
+ var require_no_sequences = /* @__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
+ docs: {
14
+ description: "Disallow comma operators",
15
+ recommended: !1,
16
+ url: "https://eslint.org/docs/latest/rules/no-sequences"
17
+ },
18
+ schema: [{
19
+ type: "object",
20
+ properties: { allowInParentheses: { type: "boolean" } },
21
+ additionalProperties: !1
22
+ }],
23
+ defaultOptions: [{ allowInParentheses: !0 }],
24
+ messages: { unexpectedCommaExpression: "Unexpected use of comma operator." }
25
+ },
26
+ create(context) {
27
+ let [{ allowInParentheses }] = context.options, sourceCode = context.sourceCode, parenthesized = {
28
+ DoWhileStatement: "test",
29
+ IfStatement: "test",
30
+ SwitchStatement: "discriminant",
31
+ WhileStatement: "test",
32
+ WithStatement: "object",
33
+ ArrowFunctionExpression: "body"
34
+ };
35
+ /**
36
+ * Determines whether a node is required by the grammar to be wrapped in
37
+ * parens, e.g. the test of an if statement.
38
+ * @param {ASTNode} node The AST node
39
+ * @returns {boolean} True if parens around node belong to parent node.
40
+ */
41
+ function requiresExtraParens(node) {
42
+ return node.parent && parenthesized[node.parent.type] && node === node.parent[parenthesized[node.parent.type]];
43
+ }
44
+ /**
45
+ * Check if a node is wrapped in parens.
46
+ * @param {ASTNode} node The AST node
47
+ * @returns {boolean} True if the node has a paren on each side.
48
+ */
49
+ function isParenthesised(node) {
50
+ return astUtils.isParenthesised(sourceCode, node);
51
+ }
52
+ /**
53
+ * Check if a node is wrapped in two levels of parens.
54
+ * @param {ASTNode} node The AST node
55
+ * @returns {boolean} True if two parens surround the node on each side.
56
+ */
57
+ function isParenthesisedTwice(node) {
58
+ let previousToken = sourceCode.getTokenBefore(node, 1), nextToken = sourceCode.getTokenAfter(node, 1);
59
+ return isParenthesised(node) && previousToken && nextToken && astUtils.isOpeningParenToken(previousToken) && previousToken.range[1] <= node.range[0] && astUtils.isClosingParenToken(nextToken) && nextToken.range[0] >= node.range[1];
60
+ }
61
+ return { SequenceExpression(node) {
62
+ if (node.parent.type === "ForStatement" && (node === node.parent.init || node === node.parent.update)) return;
63
+ if (allowInParentheses) {
64
+ if (requiresExtraParens(node)) {
65
+ if (isParenthesisedTwice(node)) return;
66
+ } else if (isParenthesised(node)) return;
67
+ }
68
+ let firstCommaToken = sourceCode.getTokenAfter(node.expressions[0], astUtils.isCommaToken);
69
+ context.report({
70
+ node,
71
+ loc: firstCommaToken.loc,
72
+ messageId: "unexpectedCommaExpression"
73
+ });
74
+ } };
75
+ }
76
+ };
77
+ }));
78
+ //#endregion
79
+ //#region src-js/generated/plugin-eslint/rules/no-sequences.cjs
80
+ module.exports = require_no_sequences().create;
81
+ //#endregion