@kutur-kit/oxc 0.0.0-stage → 0.1.0-alpha.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 (213) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +42 -2
  3. package/dist/anti-slop.d.ts +4 -0
  4. package/dist/anti-slop.d.ts.map +1 -0
  5. package/dist/anti-slop.js +42 -0
  6. package/dist/anti-slop.js.map +1 -0
  7. package/dist/base.d.ts +4 -0
  8. package/dist/base.d.ts.map +1 -0
  9. package/dist/base.js +45 -0
  10. package/dist/base.js.map +1 -0
  11. package/dist/effect.d.ts +4 -0
  12. package/dist/effect.d.ts.map +1 -0
  13. package/dist/effect.js +8 -0
  14. package/dist/effect.js.map +1 -0
  15. package/dist/format.d.ts +4 -0
  16. package/dist/format.d.ts.map +1 -0
  17. package/dist/format.js +26 -0
  18. package/dist/format.js.map +1 -0
  19. package/dist/plugin.d.ts +3 -0
  20. package/dist/plugin.d.ts.map +1 -0
  21. package/dist/plugin.js +7 -0
  22. package/dist/plugin.js.map +1 -0
  23. package/dist/rules/no-yield-in-if.d.ts +2 -0
  24. package/dist/rules/no-yield-in-if.d.ts.map +1 -0
  25. package/dist/rules/no-yield-in-if.js +30 -0
  26. package/dist/rules/no-yield-in-if.js.map +1 -0
  27. package/dist/vendor/anti-slop/effect/index.d.ts +4 -0
  28. package/dist/vendor/anti-slop/effect/index.d.ts.map +1 -0
  29. package/dist/vendor/anti-slop/effect/index.js +19 -0
  30. package/dist/vendor/anti-slop/effect/index.js.map +1 -0
  31. package/dist/vendor/anti-slop/effect/rules/no-manual-effect-error-tag.d.ts +2 -0
  32. package/dist/vendor/anti-slop/effect/rules/no-manual-effect-error-tag.d.ts.map +1 -0
  33. package/dist/vendor/anti-slop/effect/rules/no-manual-effect-error-tag.js +40 -0
  34. package/dist/vendor/anti-slop/effect/rules/no-manual-effect-error-tag.js.map +1 -0
  35. package/dist/vendor/anti-slop/effect/rules/no-manual-tag-comparison.d.ts +2 -0
  36. package/dist/vendor/anti-slop/effect/rules/no-manual-tag-comparison.d.ts.map +1 -0
  37. package/dist/vendor/anti-slop/effect/rules/no-manual-tag-comparison.js +33 -0
  38. package/dist/vendor/anti-slop/effect/rules/no-manual-tag-comparison.js.map +1 -0
  39. package/dist/vendor/anti-slop/effect/rules/no-manual-tagged-construction.d.ts +2 -0
  40. package/dist/vendor/anti-slop/effect/rules/no-manual-tagged-construction.d.ts.map +1 -0
  41. package/dist/vendor/anti-slop/effect/rules/no-manual-tagged-construction.js +28 -0
  42. package/dist/vendor/anti-slop/effect/rules/no-manual-tagged-construction.js.map +1 -0
  43. package/dist/vendor/anti-slop/effect/rules/no-service-constructor-imports.d.ts +3 -0
  44. package/dist/vendor/anti-slop/effect/rules/no-service-constructor-imports.d.ts.map +1 -0
  45. package/dist/vendor/anti-slop/effect/rules/no-service-constructor-imports.js +45 -0
  46. package/dist/vendor/anti-slop/effect/rules/no-service-constructor-imports.js.map +1 -0
  47. package/dist/vendor/anti-slop/effect/rules/prefer-effect-match.d.ts +2 -0
  48. package/dist/vendor/anti-slop/effect/rules/prefer-effect-match.d.ts.map +1 -0
  49. package/dist/vendor/anti-slop/effect/rules/prefer-effect-match.js +49 -0
  50. package/dist/vendor/anti-slop/effect/rules/prefer-effect-match.js.map +1 -0
  51. package/dist/vendor/anti-slop/effect/shared/tagged-values.d.ts +9 -0
  52. package/dist/vendor/anti-slop/effect/shared/tagged-values.d.ts.map +1 -0
  53. package/dist/vendor/anti-slop/effect/shared/tagged-values.js +69 -0
  54. package/dist/vendor/anti-slop/effect/shared/tagged-values.js.map +1 -0
  55. package/dist/vendor/anti-slop/index.d.ts +4 -0
  56. package/dist/vendor/anti-slop/index.d.ts.map +1 -0
  57. package/dist/vendor/anti-slop/index.js +45 -0
  58. package/dist/vendor/anti-slop/index.js.map +1 -0
  59. package/dist/vendor/anti-slop/rules/no-array-filter-map.d.ts +3 -0
  60. package/dist/vendor/anti-slop/rules/no-array-filter-map.d.ts.map +1 -0
  61. package/dist/vendor/anti-slop/rules/no-array-filter-map.js +31 -0
  62. package/dist/vendor/anti-slop/rules/no-array-filter-map.js.map +1 -0
  63. package/dist/vendor/anti-slop/rules/no-chained-type-assertions.d.ts +3 -0
  64. package/dist/vendor/anti-slop/rules/no-chained-type-assertions.d.ts.map +1 -0
  65. package/dist/vendor/anti-slop/rules/no-chained-type-assertions.js +61 -0
  66. package/dist/vendor/anti-slop/rules/no-chained-type-assertions.js.map +1 -0
  67. package/dist/vendor/anti-slop/rules/no-conditional-empty-object-spread.d.ts +3 -0
  68. package/dist/vendor/anti-slop/rules/no-conditional-empty-object-spread.d.ts.map +1 -0
  69. package/dist/vendor/anti-slop/rules/no-conditional-empty-object-spread.js +41 -0
  70. package/dist/vendor/anti-slop/rules/no-conditional-empty-object-spread.js.map +1 -0
  71. package/dist/vendor/anti-slop/rules/no-known-value-widening.d.ts +3 -0
  72. package/dist/vendor/anti-slop/rules/no-known-value-widening.d.ts.map +1 -0
  73. package/dist/vendor/anti-slop/rules/no-known-value-widening.js +301 -0
  74. package/dist/vendor/anti-slop/rules/no-known-value-widening.js.map +1 -0
  75. package/dist/vendor/anti-slop/rules/no-module-mocking.d.ts +3 -0
  76. package/dist/vendor/anti-slop/rules/no-module-mocking.d.ts.map +1 -0
  77. package/dist/vendor/anti-slop/rules/no-module-mocking.js +70 -0
  78. package/dist/vendor/anti-slop/rules/no-module-mocking.js.map +1 -0
  79. package/dist/vendor/anti-slop/rules/no-object-parameters.d.ts +3 -0
  80. package/dist/vendor/anti-slop/rules/no-object-parameters.d.ts.map +1 -0
  81. package/dist/vendor/anti-slop/rules/no-object-parameters.js +57 -0
  82. package/dist/vendor/anti-slop/rules/no-object-parameters.js.map +1 -0
  83. package/dist/vendor/anti-slop/rules/no-reduce-accumulator-copy.d.ts +3 -0
  84. package/dist/vendor/anti-slop/rules/no-reduce-accumulator-copy.d.ts.map +1 -0
  85. package/dist/vendor/anti-slop/rules/no-reduce-accumulator-copy.js +100 -0
  86. package/dist/vendor/anti-slop/rules/no-reduce-accumulator-copy.js.map +1 -0
  87. package/dist/vendor/anti-slop/rules/no-reflect-apply.d.ts +3 -0
  88. package/dist/vendor/anti-slop/rules/no-reflect-apply.d.ts.map +1 -0
  89. package/dist/vendor/anti-slop/rules/no-reflect-apply.js +26 -0
  90. package/dist/vendor/anti-slop/rules/no-reflect-apply.js.map +1 -0
  91. package/dist/vendor/anti-slop/rules/no-reflect-get.d.ts +3 -0
  92. package/dist/vendor/anti-slop/rules/no-reflect-get.d.ts.map +1 -0
  93. package/dist/vendor/anti-slop/rules/no-reflect-get.js +26 -0
  94. package/dist/vendor/anti-slop/rules/no-reflect-get.js.map +1 -0
  95. package/dist/vendor/anti-slop/rules/no-runtime-typeof.d.ts +3 -0
  96. package/dist/vendor/anti-slop/rules/no-runtime-typeof.d.ts.map +1 -0
  97. package/dist/vendor/anti-slop/rules/no-runtime-typeof.js +65 -0
  98. package/dist/vendor/anti-slop/rules/no-runtime-typeof.js.map +1 -0
  99. package/dist/vendor/anti-slop/rules/no-shape-in-symbol-names.d.ts +3 -0
  100. package/dist/vendor/anti-slop/rules/no-shape-in-symbol-names.d.ts.map +1 -0
  101. package/dist/vendor/anti-slop/rules/no-shape-in-symbol-names.js +41 -0
  102. package/dist/vendor/anti-slop/rules/no-shape-in-symbol-names.js.map +1 -0
  103. package/dist/vendor/anti-slop/rules/no-unknown-parameters.d.ts +3 -0
  104. package/dist/vendor/anti-slop/rules/no-unknown-parameters.d.ts.map +1 -0
  105. package/dist/vendor/anti-slop/rules/no-unknown-parameters.js +52 -0
  106. package/dist/vendor/anti-slop/rules/no-unknown-parameters.js.map +1 -0
  107. package/dist/vendor/anti-slop/rules/no-unknown-returns.d.ts +3 -0
  108. package/dist/vendor/anti-slop/rules/no-unknown-returns.d.ts.map +1 -0
  109. package/dist/vendor/anti-slop/rules/no-unknown-returns.js +59 -0
  110. package/dist/vendor/anti-slop/rules/no-unknown-returns.js.map +1 -0
  111. package/dist/vendor/anti-slop/rules/no-unknown-type-aliases.d.ts +3 -0
  112. package/dist/vendor/anti-slop/rules/no-unknown-type-aliases.d.ts.map +1 -0
  113. package/dist/vendor/anti-slop/rules/no-unknown-type-aliases.js +41 -0
  114. package/dist/vendor/anti-slop/rules/no-unknown-type-aliases.js.map +1 -0
  115. package/dist/vendor/anti-slop/rules/no-unsafe-dictionary-type.d.ts +3 -0
  116. package/dist/vendor/anti-slop/rules/no-unsafe-dictionary-type.d.ts.map +1 -0
  117. package/dist/vendor/anti-slop/rules/no-unsafe-dictionary-type.js +135 -0
  118. package/dist/vendor/anti-slop/rules/no-unsafe-dictionary-type.js.map +1 -0
  119. package/dist/vendor/anti-slop/rules/no-widen-then-assert.d.ts +3 -0
  120. package/dist/vendor/anti-slop/rules/no-widen-then-assert.d.ts.map +1 -0
  121. package/dist/vendor/anti-slop/rules/no-widen-then-assert.js +271 -0
  122. package/dist/vendor/anti-slop/rules/no-widen-then-assert.js.map +1 -0
  123. package/dist/vendor/anti-slop/rules/require-readable-spacing.d.ts +4 -0
  124. package/dist/vendor/anti-slop/rules/require-readable-spacing.d.ts.map +1 -0
  125. package/dist/vendor/anti-slop/rules/require-readable-spacing.js +42 -0
  126. package/dist/vendor/anti-slop/rules/require-readable-spacing.js.map +1 -0
  127. package/dist/vendor/anti-slop/rules/require-safety-comment-for-type-assertion.d.ts +3 -0
  128. package/dist/vendor/anti-slop/rules/require-safety-comment-for-type-assertion.d.ts.map +1 -0
  129. package/dist/vendor/anti-slop/rules/require-safety-comment-for-type-assertion.js +101 -0
  130. package/dist/vendor/anti-slop/rules/require-safety-comment-for-type-assertion.js.map +1 -0
  131. package/dist/vendor/anti-slop/shared/array-method.d.ts +13 -0
  132. package/dist/vendor/anti-slop/shared/array-method.d.ts.map +1 -0
  133. package/dist/vendor/anti-slop/shared/array-method.js +85 -0
  134. package/dist/vendor/anti-slop/shared/array-method.js.map +1 -0
  135. package/dist/vendor/anti-slop/shared/dictionary-types.d.ts +21 -0
  136. package/dist/vendor/anti-slop/shared/dictionary-types.d.ts.map +1 -0
  137. package/dist/vendor/anti-slop/shared/dictionary-types.js +378 -0
  138. package/dist/vendor/anti-slop/shared/dictionary-types.js.map +1 -0
  139. package/dist/vendor/anti-slop/shared/function-parameters.d.ts +9 -0
  140. package/dist/vendor/anti-slop/shared/function-parameters.d.ts.map +1 -0
  141. package/dist/vendor/anti-slop/shared/function-parameters.js +41 -0
  142. package/dist/vendor/anti-slop/shared/function-parameters.js.map +1 -0
  143. package/dist/vendor/anti-slop/shared/lexical-type-parameters.d.ts +6 -0
  144. package/dist/vendor/anti-slop/shared/lexical-type-parameters.d.ts.map +1 -0
  145. package/dist/vendor/anti-slop/shared/lexical-type-parameters.js +48 -0
  146. package/dist/vendor/anti-slop/shared/lexical-type-parameters.js.map +1 -0
  147. package/dist/vendor/anti-slop/shared/reflect-method.d.ts +4 -0
  148. package/dist/vendor/anti-slop/shared/reflect-method.d.ts.map +1 -0
  149. package/dist/vendor/anti-slop/shared/reflect-method.js +21 -0
  150. package/dist/vendor/anti-slop/shared/reflect-method.js.map +1 -0
  151. package/dist/vendor/anti-slop/shared/scope.d.ts +4 -0
  152. package/dist/vendor/anti-slop/shared/scope.d.ts.map +1 -0
  153. package/dist/vendor/anti-slop/shared/scope.js +12 -0
  154. package/dist/vendor/anti-slop/shared/scope.js.map +1 -0
  155. package/dist/vendor/anti-slop/shared/type-alias-resolution.d.ts +24 -0
  156. package/dist/vendor/anti-slop/shared/type-alias-resolution.d.ts.map +1 -0
  157. package/dist/vendor/anti-slop/shared/type-alias-resolution.js +163 -0
  158. package/dist/vendor/anti-slop/shared/type-alias-resolution.js.map +1 -0
  159. package/dist/vendor/anti-slop/vendor/eslint-stylistic/padding-line-ast.d.ts +28 -0
  160. package/dist/vendor/anti-slop/vendor/eslint-stylistic/padding-line-ast.d.ts.map +1 -0
  161. package/dist/vendor/anti-slop/vendor/eslint-stylistic/padding-line-ast.js +29 -0
  162. package/dist/vendor/anti-slop/vendor/eslint-stylistic/padding-line-ast.js.map +1 -0
  163. package/dist/vendor/anti-slop/vendor/eslint-stylistic/padding-line-between-statements.d.ts +5 -0
  164. package/dist/vendor/anti-slop/vendor/eslint-stylistic/padding-line-between-statements.d.ts.map +1 -0
  165. package/dist/vendor/anti-slop/vendor/eslint-stylistic/padding-line-between-statements.js +699 -0
  166. package/dist/vendor/anti-slop/vendor/eslint-stylistic/padding-line-between-statements.js.map +1 -0
  167. package/package.json +71 -3
  168. package/src/anti-slop.ts +48 -0
  169. package/src/base.ts +49 -0
  170. package/src/effect.ts +12 -0
  171. package/src/format.ts +28 -0
  172. package/src/plugin.ts +8 -0
  173. package/src/rules/no-yield-in-if.ts +40 -0
  174. package/src/vendor/anti-slop/LICENSE +21 -0
  175. package/src/vendor/anti-slop/UPSTREAM.md +10 -0
  176. package/src/vendor/anti-slop/effect/index.ts +21 -0
  177. package/src/vendor/anti-slop/effect/rules/no-manual-effect-error-tag.ts +52 -0
  178. package/src/vendor/anti-slop/effect/rules/no-manual-tag-comparison.ts +45 -0
  179. package/src/vendor/anti-slop/effect/rules/no-manual-tagged-construction.ts +37 -0
  180. package/src/vendor/anti-slop/effect/rules/no-service-constructor-imports.ts +52 -0
  181. package/src/vendor/anti-slop/effect/rules/prefer-effect-match.ts +54 -0
  182. package/src/vendor/anti-slop/effect/shared/tagged-values.ts +97 -0
  183. package/src/vendor/anti-slop/index.ts +47 -0
  184. package/src/vendor/anti-slop/rules/no-array-filter-map.ts +28 -0
  185. package/src/vendor/anti-slop/rules/no-chained-type-assertions.ts +77 -0
  186. package/src/vendor/anti-slop/rules/no-conditional-empty-object-spread.ts +49 -0
  187. package/src/vendor/anti-slop/rules/no-known-value-widening.ts +415 -0
  188. package/src/vendor/anti-slop/rules/no-module-mocking.ts +80 -0
  189. package/src/vendor/anti-slop/rules/no-object-parameters.ts +83 -0
  190. package/src/vendor/anti-slop/rules/no-reduce-accumulator-copy.ts +109 -0
  191. package/src/vendor/anti-slop/rules/no-reflect-apply.ts +28 -0
  192. package/src/vendor/anti-slop/rules/no-reflect-get.ts +28 -0
  193. package/src/vendor/anti-slop/rules/no-runtime-typeof.ts +77 -0
  194. package/src/vendor/anti-slop/rules/no-shape-in-symbol-names.ts +46 -0
  195. package/src/vendor/anti-slop/rules/no-unknown-parameters.ts +69 -0
  196. package/src/vendor/anti-slop/rules/no-unknown-returns.ts +82 -0
  197. package/src/vendor/anti-slop/rules/no-unknown-type-aliases.ts +54 -0
  198. package/src/vendor/anti-slop/rules/no-unsafe-dictionary-type.ts +154 -0
  199. package/src/vendor/anti-slop/rules/no-widen-then-assert.ts +366 -0
  200. package/src/vendor/anti-slop/rules/require-readable-spacing.ts +47 -0
  201. package/src/vendor/anti-slop/rules/require-safety-comment-for-type-assertion.ts +131 -0
  202. package/src/vendor/anti-slop/shared/array-method.ts +94 -0
  203. package/src/vendor/anti-slop/shared/dictionary-types.ts +515 -0
  204. package/src/vendor/anti-slop/shared/function-parameters.ts +49 -0
  205. package/src/vendor/anti-slop/shared/lexical-type-parameters.ts +61 -0
  206. package/src/vendor/anti-slop/shared/reflect-method.ts +24 -0
  207. package/src/vendor/anti-slop/shared/scope.ts +15 -0
  208. package/src/vendor/anti-slop/shared/type-alias-resolution.ts +250 -0
  209. package/src/vendor/anti-slop/vendor/eslint-stylistic/LICENSE +22 -0
  210. package/src/vendor/anti-slop/vendor/eslint-stylistic/UPSTREAM.md +28 -0
  211. package/src/vendor/anti-slop/vendor/eslint-stylistic/padding-line-ast.ts +51 -0
  212. package/src/vendor/anti-slop/vendor/eslint-stylistic/padding-line-between-statements.ts +906 -0
  213. package/src/vendor/anti-slop/vendor/eslint-stylistic/padding-line-options.d.ts +87 -0
@@ -0,0 +1,59 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { createTypeAliasEnvironment, resolvedTypeMatches, } from "../shared/type-alias-resolution.js";
3
+ /** Ban function contracts that return unknown instead of a parsed domain type. */
4
+ export const noUnknownReturnsRule = defineRule({
5
+ meta: {
6
+ type: "problem",
7
+ docs: {
8
+ description: "Disallow functions whose explicit return contract is unknown or Promise<unknown>.",
9
+ },
10
+ messages: {
11
+ unknownReturn: "This function exposes `unknown` to its caller. Parse the value at its boundary and return a named domain type.",
12
+ },
13
+ },
14
+ createOnce(context) {
15
+ let environment = null;
16
+ const resolvesToUnknown = (type) => environment !== null &&
17
+ resolvedTypeMatches(type, environment, (resolved, matches) => {
18
+ if (resolved.type === "TSUnknownKeyword")
19
+ return true;
20
+ if (resolved.type === "TSParenthesizedType") {
21
+ return matches(resolved.typeAnnotation);
22
+ }
23
+ if (resolved.type === "TSUnionType")
24
+ return resolved.types.some(matches);
25
+ if (resolved.type !== "TSTypeReference" ||
26
+ resolved.typeName.type !== "Identifier" ||
27
+ (resolved.typeName.name !== "Promise" &&
28
+ resolved.typeName.name !== "PromiseLike")) {
29
+ return false;
30
+ }
31
+ const value = resolved.typeArguments?.params[0];
32
+ return value !== undefined && matches(value);
33
+ });
34
+ const checkReturnType = (node) => {
35
+ const annotation = node.returnType;
36
+ if (annotation === null || annotation === undefined)
37
+ return;
38
+ if (!resolvesToUnknown(annotation.typeAnnotation))
39
+ return;
40
+ context.report({ node: annotation.typeAnnotation, messageId: "unknownReturn" });
41
+ };
42
+ return {
43
+ Program(node) {
44
+ environment = createTypeAliasEnvironment(node, context.sourceCode.visitorKeys);
45
+ },
46
+ ArrowFunctionExpression: checkReturnType,
47
+ FunctionDeclaration: checkReturnType,
48
+ FunctionExpression: checkReturnType,
49
+ TSCallSignatureDeclaration: checkReturnType,
50
+ TSConstructSignatureDeclaration: checkReturnType,
51
+ TSConstructorType: checkReturnType,
52
+ TSDeclareFunction: checkReturnType,
53
+ TSEmptyBodyFunctionExpression: checkReturnType,
54
+ TSFunctionType: checkReturnType,
55
+ TSMethodSignature: checkReturnType,
56
+ };
57
+ },
58
+ });
59
+ //# sourceMappingURL=no-unknown-returns.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unknown-returns.js","s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aAAa,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;gBAChD,OAAO,KAAK,KAAK,SAAS,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;YAC/C,CAAC,CAAC,CAAC;QAEL,MAAM,eAAe,GAAG,CAAC,IAA4B,EAAE,EAAE;YACvD,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;YACnC,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,SAAS;gBAAE,OAAO;YAC5D,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,cAAc,CAAC;gBAAE,OAAO;YAC1D,OAAO,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,CAAC,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC;QAClF,CAAC,CAAC;QAEF,OAAO;YACL,OAAO,CAAC,IAAI;gBACV,WAAW,GAAG,0BAA0B,CACtC,IAAI,EACJ,OAAO,CAAC,UAAU,CAAC,WAAW,CAC/B,CAAC;YACJ,CAAC;YACD,uBAAuB,EAAE,eAAe;YACxC,mBAAmB,EAAE,eAAe;YACpC,kBAAkB,EAAE,eAAe;YACnC,0BAA0B,EAAE,eAAe;YAC3C,+BAA+B,EAAE,eAAe;YAChD,iBAAiB,EAAE,eAAe;YAClC,iBAAiB,EAAE,eAAe;YAClC,6BAA6B,EAAE,eAAe;YAC9C,cAAc,EAAE,eAAe;YAC/B,iBAAiB,EAAE,eAAe;SACnC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Ban named aliases that merely conceal TypeScript's unknown top type. */
2
+ export declare const noUnknownTypeAliasesRule: import("@oxlint/plugins").Rule;
3
+ //# sourceMappingURL=no-unknown-type-aliases.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unknown-type-aliases.d.ts","sourceRoot":"","sources":["../../../../src/vendor/anti-slop/rules/no-unknown-type-aliases.ts"],"names":[],"mappings":"AAUA,2EAA2E;AAC3E,eAAO,MAAM,wBAAwB,gCA0CnC,CAAC"}
@@ -0,0 +1,41 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { createTypeAliasEnvironment, resolvedTypeMatches, } from "../shared/type-alias-resolution.js";
3
+ /** Ban named aliases that merely conceal TypeScript's unknown top type. */
4
+ export const noUnknownTypeAliasesRule = defineRule({
5
+ meta: {
6
+ type: "problem",
7
+ docs: {
8
+ description: "Disallow type aliases whose resolved type is unknown; unknown must remain visible at an allowed boundary.",
9
+ },
10
+ messages: {
11
+ unknownAlias: "Type alias `{{alias}}` hides `unknown`. Keep `unknown` explicit at the parsing boundary or on an allowed `cause` field; otherwise use the parsed owner type.",
12
+ },
13
+ },
14
+ createOnce(context) {
15
+ let environment = null;
16
+ const resolvesToUnknown = (type) => environment !== null &&
17
+ resolvedTypeMatches(type, environment, (resolved, matches) => {
18
+ if (resolved.type === "TSUnknownKeyword")
19
+ return true;
20
+ if (resolved.type === "TSParenthesizedType") {
21
+ return matches(resolved.typeAnnotation);
22
+ }
23
+ return resolved.type === "TSUnionType" && resolved.types.some(matches);
24
+ });
25
+ return {
26
+ Program(node) {
27
+ environment = createTypeAliasEnvironment(node, context.sourceCode.visitorKeys);
28
+ },
29
+ TSTypeAliasDeclaration(node) {
30
+ if (!resolvesToUnknown(node.typeAnnotation))
31
+ return;
32
+ context.report({
33
+ node: node.id,
34
+ messageId: "unknownAlias",
35
+ data: { alias: node.id.name },
36
+ });
37
+ },
38
+ };
39
+ },
40
+ });
41
+ //# sourceMappingURL=no-unknown-type-aliases.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unknown-type-aliases.js","sourceRoot":"","sources":["../../../../src/vendor/anti-slop/rules/no-unknown-type-aliases.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAI7C,OAAO,EACN,0BAA0B,EAC1B,mBAAmB,GAEnB,MAAM,oCAAoC,CAAC;AAE5C,2EAA2E;AAC3E,MA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/** Disallow object-dictionary contracts whose direct value type is an unsafe escape hatch. */
2
+ export declare const noUnsafeDictionaryTypeRule: import("@oxlint/plugins").Rule;
3
+ //# sourceMappingURL=no-unsafe-dictionary-type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unsafe-dictionary-type.d.ts","sourceRoot":"","sources":["../../../../src/vendor/anti-slop/rules/no-unsafe-dictionary-type.ts"],"names":[],"mappings":"AAuGA,8FAA8F;AAC9F,eAAO,MAAM,0BAA0B,gCAiDrC,CAAC"}
@@ -0,0 +1,135 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { classifyUnsafeDictionary, classifyUnsafeDictionaryValue, createTypeEnvironment, } from "../shared/dictionary-types.js";
3
+ import { visibleTypeAlias } from "../shared/type-alias-resolution.js";
4
+ const typeNodeKinds = new Set([
5
+ "JSDocNonNullableType",
6
+ "JSDocNullableType",
7
+ "JSDocUnknownType",
8
+ "TSAnyKeyword",
9
+ "TSArrayType",
10
+ "TSBigIntKeyword",
11
+ "TSBooleanKeyword",
12
+ "TSConditionalType",
13
+ "TSConstructorType",
14
+ "TSFunctionType",
15
+ "TSImportType",
16
+ "TSIndexedAccessType",
17
+ "TSInferType",
18
+ "TSIntersectionType",
19
+ "TSIntrinsicKeyword",
20
+ "TSLiteralType",
21
+ "TSMappedType",
22
+ "TSNamedTupleMember",
23
+ "TSNeverKeyword",
24
+ "TSNullKeyword",
25
+ "TSNumberKeyword",
26
+ "TSObjectKeyword",
27
+ "TSParenthesizedType",
28
+ "TSStringKeyword",
29
+ "TSSymbolKeyword",
30
+ "TSTemplateLiteralType",
31
+ "TSThisType",
32
+ "TSTupleType",
33
+ "TSTypeLiteral",
34
+ "TSTypeOperator",
35
+ "TSTypePredicate",
36
+ "TSTypeQuery",
37
+ "TSTypeReference",
38
+ "TSUndefinedKeyword",
39
+ "TSUnionType",
40
+ "TSUnknownKeyword",
41
+ "TSVoidKeyword",
42
+ ]);
43
+ function isTypeNode(node) {
44
+ return typeNodeKinds.has(node.type);
45
+ }
46
+ function typeReferenceName(type) {
47
+ return type.typeName.type === "Identifier" ? type.typeName.name : null;
48
+ }
49
+ function isInsideTypeAliasDeclaration(node) {
50
+ let current = node.parent;
51
+ while (current !== null && current.type !== "Program") {
52
+ if (current.type === "TSTypeAliasDeclaration")
53
+ return true;
54
+ current = current.parent;
55
+ }
56
+ return false;
57
+ }
58
+ function isPlainAliasConsumerUse(node, environment) {
59
+ if (node.type !== "TSTypeReference" || node.typeArguments?.params.length)
60
+ return false;
61
+ const name = typeReferenceName(node);
62
+ return (name !== null &&
63
+ visibleTypeAlias(name, node, environment.typeAliases) !== null &&
64
+ !isInsideTypeAliasDeclaration(node));
65
+ }
66
+ function isInsideTypeParameterConstraint(node) {
67
+ let child = node;
68
+ let parent = child.parent;
69
+ while (parent !== null && parent.type !== "Program") {
70
+ if (parent.type === "TSTypeParameter" && parent.constraint === child)
71
+ return true;
72
+ child = parent;
73
+ parent = child.parent;
74
+ }
75
+ return false;
76
+ }
77
+ function shouldReportType(node, environment) {
78
+ if (isInsideTypeParameterConstraint(node))
79
+ return false;
80
+ if (isPlainAliasConsumerUse(node, environment))
81
+ return false;
82
+ if (classifyUnsafeDictionary(node, environment) === null)
83
+ return false;
84
+ let current = node.parent;
85
+ while (current !== null && current.type !== "Program") {
86
+ if (isTypeNode(current) && classifyUnsafeDictionary(current, environment) !== null)
87
+ return false;
88
+ current = current.parent;
89
+ }
90
+ return true;
91
+ }
92
+ /** Disallow object-dictionary contracts whose direct value type is an unsafe escape hatch. */
93
+ export const noUnsafeDictionaryTypeRule = defineRule({
94
+ meta: {
95
+ type: "problem",
96
+ docs: {
97
+ description: "Disallow object-dictionary contracts whose direct value type is unknown, any, object, {}, or a union/alias containing one of those escape hatches.",
98
+ },
99
+ messages: {
100
+ unsafeDictionary: "This dictionary's {{value}} value type gives callers no concrete value contract. Use an owner/schema-derived value type; parse external payloads before insertion.",
101
+ },
102
+ },
103
+ createOnce(context) {
104
+ let environment = null;
105
+ const report = (node, value) => {
106
+ context.report({ node, messageId: "unsafeDictionary", data: { value } });
107
+ };
108
+ const reportIfUnsafe = (node) => {
109
+ if (environment === null || !shouldReportType(node, environment))
110
+ return;
111
+ const unsafe = classifyUnsafeDictionary(node, environment);
112
+ if (unsafe === null)
113
+ return;
114
+ report(node, unsafe.unsafeValue);
115
+ };
116
+ return {
117
+ Program(node) {
118
+ environment = createTypeEnvironment(node, context.sourceCode.visitorKeys);
119
+ },
120
+ TSTypeReference: reportIfUnsafe,
121
+ TSTypeLiteral: reportIfUnsafe,
122
+ TSMappedType: reportIfUnsafe,
123
+ TSIndexSignature(node) {
124
+ if (environment === null ||
125
+ node.typeAnnotation === null ||
126
+ node.parent.type === "TSTypeLiteral")
127
+ return;
128
+ const unsafe = classifyUnsafeDictionaryValue(node.typeAnnotation.typeAnnotation, environment);
129
+ if (unsafe !== null)
130
+ report(node, unsafe.unsafeValue);
131
+ },
132
+ };
133
+ },
134
+ });
135
+ //# sourceMappingURL=no-unsafe-dictionary-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-unsafe-dictionary-type.js","sourceRoot":"","sources":["../../../../src/vendor/anti-slop/rules/no-unsafe-dictionary-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,OAAO,EACN,wBAAwB,EACxB,6BAA6B,EAC7B,qBAAqB,GAErB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAItE,MAAM,aAAa,GAAwB,IAAI,GAAG,CAAC;IAClD,sBAAsB;IACtB,mBAAmB;IACnB,kBAAkB;IAClB,cAAc;IACd,aAAa;IACb,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;IACnB,mBAAmB;IACnB,gBAAgB;IAChB,cAAc;IACd,qBAAqB;IACrB,aAAa;IACb,oBAAoB;IACpB,oBAAoB;IACpB,eAAe;IACf,cAAc;IACd,oBAAoB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;CACD,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Detect immutable local bindings that erase a known type and are later asserted back to a narrower type. */
2
+ export declare const noWidenThenAssertRule: import("@oxlint/plugins").Rule;
3
+ //# sourceMappingURL=no-widen-then-assert.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-widen-then-assert.d.ts","sourceRoot":"","sources":["../../../../src/vendor/anti-slop/rules/no-widen-then-assert.ts"],"names":[],"mappings":"AAyTA,8GAA8G;AAC9G,eAAO,MAAM,qBAAqB,gCAmDhC,CAAC"}
@@ -0,0 +1,271 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ const functionBoundaryTypes = new Set([
3
+ "ArrowFunctionExpression",
4
+ "FunctionDeclaration",
5
+ "FunctionExpression",
6
+ "TSDeclareFunction",
7
+ "TSEmptyBodyFunctionExpression",
8
+ ]);
9
+ function unwrapExpressionParentheses(expression) {
10
+ let current = expression;
11
+ while (current.type === "ParenthesizedExpression")
12
+ current = current.expression;
13
+ return current;
14
+ }
15
+ function unwrapTypeParentheses(type) {
16
+ let current = type;
17
+ while (current.type === "TSParenthesizedType")
18
+ current = current.typeAnnotation;
19
+ return current;
20
+ }
21
+ function typeReferenceName(type) {
22
+ return type.typeName.type === "Identifier" ? type.typeName.name : null;
23
+ }
24
+ function isUnknownOrAnyType(type) {
25
+ const unwrapped = unwrapTypeParentheses(type);
26
+ return unwrapped.type === "TSUnknownKeyword" || unwrapped.type === "TSAnyKeyword";
27
+ }
28
+ function isBroadRecordKeyType(type) {
29
+ const unwrapped = unwrapTypeParentheses(type);
30
+ if (unwrapped.type === "TSStringKeyword" ||
31
+ unwrapped.type === "TSNumberKeyword" ||
32
+ unwrapped.type === "TSSymbolKeyword") {
33
+ return true;
34
+ }
35
+ if (unwrapped.type === "TSUnionType")
36
+ return unwrapped.types.every(isBroadRecordKeyType);
37
+ return unwrapped.type === "TSTypeReference" && typeReferenceName(unwrapped) === "PropertyKey";
38
+ }
39
+ function isBroadRecordType(type) {
40
+ const unwrapped = unwrapTypeParentheses(type);
41
+ if (unwrapped.type === "TSTypeReference") {
42
+ if (typeReferenceName(unwrapped) === "Readonly") {
43
+ const [inner] = unwrapped.typeArguments?.params ?? [];
44
+ return inner !== undefined && isBroadRecordType(inner);
45
+ }
46
+ if (typeReferenceName(unwrapped) !== "Record")
47
+ return false;
48
+ const parameters = unwrapped.typeArguments?.params ?? [];
49
+ return (parameters.length === 2 &&
50
+ parameters[0] !== undefined &&
51
+ parameters[1] !== undefined &&
52
+ isBroadRecordKeyType(parameters[0]) &&
53
+ isUnknownOrAnyType(parameters[1]));
54
+ }
55
+ if (unwrapped.type !== "TSTypeLiteral" || unwrapped.members.length !== 1)
56
+ return false;
57
+ const [member] = unwrapped.members;
58
+ const [parameter] = member?.type === "TSIndexSignature" ? member.parameters : [];
59
+ return (member?.type === "TSIndexSignature" &&
60
+ member.parameters.length === 1 &&
61
+ parameter !== undefined &&
62
+ isBroadRecordKeyType(parameter.typeAnnotation.typeAnnotation) &&
63
+ isUnknownOrAnyType(member.typeAnnotation.typeAnnotation));
64
+ }
65
+ function broadTypeKind(type) {
66
+ const unwrapped = unwrapTypeParentheses(type);
67
+ if (unwrapped.type === "TSUnknownKeyword" || unwrapped.type === "TSAnyKeyword")
68
+ return "top";
69
+ if (unwrapped.type === "TSObjectKeyword")
70
+ return "object";
71
+ return isBroadRecordType(unwrapped) ? "record" : null;
72
+ }
73
+ function assertedExpression(node) {
74
+ return unwrapExpressionParentheses(node.expression);
75
+ }
76
+ function assertionFromExpression(expression) {
77
+ const unwrapped = unwrapExpressionParentheses(expression);
78
+ return unwrapped.type === "TSAsExpression" || unwrapped.type === "TSTypeAssertion"
79
+ ? unwrapped
80
+ : null;
81
+ }
82
+ function normalizedTypeText(sourceText, type) {
83
+ return sourceText.slice(type.start, type.end).replaceAll(/\s+/gu, "");
84
+ }
85
+ function typesHaveSameSyntax(sourceText, left, right) {
86
+ return (left !== null &&
87
+ normalizedTypeText(sourceText, unwrapTypeParentheses(left)) ===
88
+ normalizedTypeText(sourceText, unwrapTypeParentheses(right)));
89
+ }
90
+ function isDefinitelyObjectType(type) {
91
+ const unwrapped = unwrapTypeParentheses(type);
92
+ switch (unwrapped.type) {
93
+ case "TSArrayType":
94
+ case "TSConstructorType":
95
+ case "TSFunctionType":
96
+ case "TSMappedType":
97
+ case "TSObjectKeyword":
98
+ case "TSTupleType":
99
+ return true;
100
+ case "TSTypeLiteral":
101
+ return unwrapped.members.length > 0;
102
+ case "TSIntersectionType":
103
+ return unwrapped.types.every(isDefinitelyObjectType);
104
+ case "TSTypeOperator":
105
+ return unwrapped.operator === "readonly" && isDefinitelyObjectType(unwrapped.typeAnnotation);
106
+ default:
107
+ return false;
108
+ }
109
+ }
110
+ function isDefinitelyNarrowerRecordType(type) {
111
+ const unwrapped = unwrapTypeParentheses(type);
112
+ if (unwrapped.type === "TSTypeLiteral") {
113
+ return unwrapped.members.some((member) => member.type !== "TSIndexSignature");
114
+ }
115
+ if (unwrapped.type !== "TSTypeReference")
116
+ return false;
117
+ if (typeReferenceName(unwrapped) === "Readonly") {
118
+ const [inner] = unwrapped.typeArguments?.params ?? [];
119
+ return inner !== undefined && isDefinitelyNarrowerRecordType(inner);
120
+ }
121
+ if (typeReferenceName(unwrapped) !== "Record")
122
+ return false;
123
+ const parameters = unwrapped.typeArguments?.params ?? [];
124
+ return (parameters.length === 2 && parameters[1] !== undefined && !isUnknownOrAnyType(parameters[1]));
125
+ }
126
+ function functionBoundary(node) {
127
+ let current = node.parent;
128
+ while (current !== null && current.type !== "Program") {
129
+ if (functionBoundaryTypes.has(current.type))
130
+ return current;
131
+ current = current.parent;
132
+ }
133
+ return null;
134
+ }
135
+ function resolvedVariableForIdentifier(scopes, identifier) {
136
+ for (const scope of scopes) {
137
+ const reference = scope.references.find((candidate) => candidate.identifier.start === identifier.start &&
138
+ candidate.identifier.end === identifier.end);
139
+ if (reference !== undefined)
140
+ return reference.resolved;
141
+ }
142
+ return null;
143
+ }
144
+ function variableDeclarator(variable) {
145
+ for (const definition of variable.defs) {
146
+ if (definition.type === "Variable" && definition.node.type === "VariableDeclarator") {
147
+ return definition.node;
148
+ }
149
+ }
150
+ return null;
151
+ }
152
+ function knownValueEvidence(expression, scopes, boundary, visitedVariables) {
153
+ const unwrapped = unwrapExpressionParentheses(expression);
154
+ if (unwrapped.type === "TSAsExpression" || unwrapped.type === "TSTypeAssertion") {
155
+ if (broadTypeKind(unwrapped.typeAnnotation) !== null)
156
+ return null;
157
+ return { type: unwrapped.typeAnnotation };
158
+ }
159
+ if (unwrapped.type === "Literal" || unwrapped.type === "TemplateLiteral") {
160
+ return { type: null };
161
+ }
162
+ if (unwrapped.type === "ArrayExpression" ||
163
+ unwrapped.type === "ArrowFunctionExpression" ||
164
+ unwrapped.type === "ClassExpression" ||
165
+ unwrapped.type === "FunctionExpression" ||
166
+ unwrapped.type === "NewExpression" ||
167
+ unwrapped.type === "ObjectExpression") {
168
+ return { type: null };
169
+ }
170
+ if (unwrapped.type !== "Identifier")
171
+ return null;
172
+ const variable = resolvedVariableForIdentifier(scopes, unwrapped);
173
+ if (variable === null || visitedVariables.has(variable))
174
+ return null;
175
+ const annotatedIdentifier = variable.identifiers.find((identifier) => identifier.typeAnnotation !== null && identifier.typeAnnotation !== undefined);
176
+ const annotation = annotatedIdentifier?.typeAnnotation?.typeAnnotation;
177
+ if (annotation !== undefined && annotatedIdentifier !== undefined) {
178
+ if (functionBoundary(annotatedIdentifier) !== boundary || broadTypeKind(annotation) !== null) {
179
+ return null;
180
+ }
181
+ return { type: annotation };
182
+ }
183
+ const declarator = variableDeclarator(variable);
184
+ if (declarator === null ||
185
+ declarator.parent.type !== "VariableDeclaration" ||
186
+ declarator.parent.kind !== "const" ||
187
+ declarator.init === null ||
188
+ variable.references.some((reference) => reference.isWrite() && !reference.init) ||
189
+ functionBoundary(declarator) !== boundary) {
190
+ return null;
191
+ }
192
+ return knownValueEvidence(declarator.init, scopes, boundary, new Set([...visitedVariables, variable]));
193
+ }
194
+ function widenedBinding(variable, scopes) {
195
+ const declarator = variableDeclarator(variable);
196
+ if (declarator === null ||
197
+ declarator.parent.type !== "VariableDeclaration" ||
198
+ declarator.parent.kind !== "const" ||
199
+ declarator.id.type !== "Identifier" ||
200
+ declarator.init === null ||
201
+ variable.references.some((reference) => reference.isWrite() && !reference.init)) {
202
+ return null;
203
+ }
204
+ const boundary = functionBoundary(declarator);
205
+ const declaredType = declarator.id.typeAnnotation?.typeAnnotation;
206
+ const initializerAssertion = assertionFromExpression(declarator.init);
207
+ const initializerBroadKind = initializerAssertion === null ? null : broadTypeKind(initializerAssertion.typeAnnotation);
208
+ const declaredBroadKind = declaredType === undefined ? null : broadTypeKind(declaredType);
209
+ const broadKind = declaredBroadKind ?? initializerBroadKind;
210
+ if (broadKind === null)
211
+ return null;
212
+ const originalExpression = initializerAssertion !== null && initializerBroadKind !== null
213
+ ? assertedExpression(initializerAssertion)
214
+ : declarator.init;
215
+ const evidence = knownValueEvidence(originalExpression, scopes, boundary, new Set([variable]));
216
+ return evidence === null ? null : { broadKind, evidence, declaredAt: declarator.end, boundary };
217
+ }
218
+ function assertionIsNarrower(sourceText, broadKind, evidence, assertedType) {
219
+ if (broadTypeKind(assertedType) !== null)
220
+ return false;
221
+ if (broadKind === "top")
222
+ return true;
223
+ if (typesHaveSameSyntax(sourceText, evidence.type, assertedType))
224
+ return true;
225
+ if (broadKind === "object")
226
+ return isDefinitelyObjectType(assertedType);
227
+ return isDefinitelyNarrowerRecordType(assertedType);
228
+ }
229
+ /** Detect immutable local bindings that erase a known type and are later asserted back to a narrower type. */
230
+ export const noWidenThenAssertRule = defineRule({
231
+ meta: {
232
+ type: "problem",
233
+ docs: {
234
+ description: "Disallow local const flows that explicitly widen a known value before asserting the widened binding to a narrower type.",
235
+ },
236
+ messages: {
237
+ widenThenAssert: 'Binding "{{name}}" discards type evidence and later recreates it with an assertion. Keep the precise type from initialization through use; parse boundary input once.',
238
+ },
239
+ },
240
+ createOnce(context) {
241
+ let scopes = [];
242
+ const checkAssertion = (node) => {
243
+ const expression = assertedExpression(node);
244
+ if (expression.type !== "Identifier")
245
+ return;
246
+ const variable = resolvedVariableForIdentifier(scopes, expression);
247
+ if (variable === null)
248
+ return;
249
+ const widened = widenedBinding(variable, scopes);
250
+ if (widened === null ||
251
+ node.start <= widened.declaredAt ||
252
+ functionBoundary(node) !== widened.boundary ||
253
+ !assertionIsNarrower(context.sourceCode.text, widened.broadKind, widened.evidence, node.typeAnnotation)) {
254
+ return;
255
+ }
256
+ context.report({
257
+ node,
258
+ messageId: "widenThenAssert",
259
+ data: { name: expression.name },
260
+ });
261
+ };
262
+ return {
263
+ Program() {
264
+ scopes = context.sourceCode.scopeManager.scopes;
265
+ },
266
+ TSAsExpression: checkAssertion,
267
+ TSTypeAssertion: checkAssertion,
268
+ };
269
+ },
270
+ });
271
+ //# sourceMappingURL=no-widen-then-assert.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"no-widen-then-assert.js","sourceRoot":"","sources":["../../../../src/vendor/anti-slop/rules/no-widen-then-assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAS7C,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IACpC,yBAAyB;IACzB,qBAAqB;IACrB,oBAAoB;IACpB,mBAAmB;IACnB,+BAA+B;CAChC,CAAC,CAAC;AAEH,SAAS,2BAA2B,CAAC,UAA6B;IAChE,IAAI,OAAO,GAAG,UAAU,CAAC;IACzB,OAAO,OAAO,CAAC,IAAI,KAAK,yBAAyB;QAAE,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC;IAChF,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,qBAAqB,CAAC,IAAmB;IAChD,IAAI,OAAO,GAAG,IAAI,CAAC;IACnB,OAAO,OAAO,CAAC,IAAI,KAAK,qBAAqB;QAAE,OAAO,GAAG,OAAO,CAAC,cAAc,CAAC;IAChF,OAAO,OAAO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AAS,EAAE,iBAAiB;gBAC5B,IAAI,EAAE,EAAE,IAAI,EAAE,UAAU,CAAC,IAAI,EAAE;aAChC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,OAAO;YACL,OAAO;gBACL,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,CAAC;YAClD,CAAC;YACD,cAAc,EAAE,cAAc;YAC9B,eAAe,EAAE,cAAc;SAChC,CAAC;IACJ,CAAC;CACF,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { CreateRule } from "@oxlint/plugins";
2
+ /** Restore structural blank lines with whitespace-only fixes; keep local short bindings and overloads grouped. */
3
+ export declare const requireReadableSpacingRule: CreateRule;
4
+ //# sourceMappingURL=require-readable-spacing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-readable-spacing.d.ts","sourceRoot":"","sources":["../../../../src/vendor/anti-slop/rules/require-readable-spacing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAoClD,kHAAkH;AAClH,eAAO,MAAM,0BAA0B,EAAE,UASxC,CAAC"}
@@ -0,0 +1,42 @@
1
+ import createPaddingLineRule from "../vendor/eslint-stylistic/padding-line-between-statements.js";
2
+ const paddingRule = createPaddingLineRule([
3
+ { blankLine: "always", prev: "import", next: "*" },
4
+ { blankLine: "always", prev: "*", next: { selector: "Program > :not(ImportDeclaration)" } },
5
+ { blankLine: "always", prev: { selector: "Program > :not(ImportDeclaration)" }, next: "*" },
6
+ { blankLine: "always", prev: "*", next: ["function", "class", "interface", "type"] },
7
+ { blankLine: "always", prev: ["function", "class", "interface", "type"], next: "*" },
8
+ {
9
+ blankLine: "always",
10
+ prev: "*",
11
+ next: ["multiline-const", "multiline-let", "multiline-var", "multiline-using"],
12
+ },
13
+ {
14
+ blankLine: "always",
15
+ prev: ["multiline-const", "multiline-let", "multiline-var", "multiline-using"],
16
+ next: "*",
17
+ },
18
+ { blankLine: "always", prev: "*", next: ["return", "if", "switch", "try", "for", "while", "do"] },
19
+ { blankLine: "always", prev: "block-like", next: "*" },
20
+ { blankLine: "any", prev: "import", next: "import" },
21
+ {
22
+ blankLine: "any",
23
+ prev: {
24
+ selector: ':matches(TSDeclareFunction, ExportNamedDeclaration[declaration.type="TSDeclareFunction"])',
25
+ },
26
+ next: {
27
+ selector: ':matches(TSDeclareFunction, FunctionDeclaration, ExportNamedDeclaration[declaration.type="TSDeclareFunction"], ExportNamedDeclaration[declaration.type="FunctionDeclaration"])',
28
+ },
29
+ },
30
+ ]);
31
+ /** Restore structural blank lines with whitespace-only fixes; keep local short bindings and overloads grouped. */
32
+ export const requireReadableSpacingRule = {
33
+ ...paddingRule,
34
+ meta: {
35
+ ...paddingRule.meta,
36
+ docs: {
37
+ description: "Require readable spacing between declarations and logical statement groups.",
38
+ },
39
+ schema: [],
40
+ },
41
+ };
42
+ //# sourceMappingURL=require-readable-spacing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-readable-spacing.js","sourceRoot":"","sources":["../../../../src/vendor/anti-slop/rules/require-readable-spacing.ts"],"names":[],"mappings":"AAEA,OAAO,qBAAqB,MAAM,+DAA+D,CAAC;AAElG,MAAM,WAAW,GAAG,qBAAqB,CAAC;IACxC,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE;IAClD,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,mCAAmC,EAAE,EAAE;IAC3F,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,QAAQ,EAAE,mCAAmC,EAAE,EAAE,IAAI,EAAE,GAAG,EAAE;IAC3F,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE;IACpF,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,IAAI,EAAE,GAAG,EAAE;IACpF;QACE,SAAS,EAAE,QAAQ;QACnB,IAAI,EAAE,GAAG;QACT,IAAI,EAAE,CAAC,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,CAAC;KAC/E;IACD;QACE,SAAS,EAAE,QAAQ;QACnB,IAAI,EAAE,CAAC,iBAAiB,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,CAAC;QAC9E,IAAI,EAAE,GAAG;KACV;IACD,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE;IACjG,EAAE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE;IACtD,EAAE,SAAS,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE;IACpD;QACE,SAAS,EAAE,KAAK;QAChB,IAAI,EAAE;YACJ,QAAQ,EACN,2FAA2F;SAC9F;QACD,IAAI,EAAE;YACJ,QAAQ,EACN,gLAAgL;SACnL;KACF;CACF,CAAC,CAAC;AAEH,kHAAkH;AAClH,MAAM,CAAC,MAAM,0BAA0B,GAAe;IACpD,GAAG,WAAW;IACd,IAAI,EAAE;QACJ,GAAG,WAAW,CAAC,IAAI;QACnB,IAAI,EAAE;YACJ,WAAW,EAAE,6EAA6E;SAC3F;QACD,MAAM,EAAE,EAAE;KACX;CACF,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** Require every non-const type assertion to state the invariant TypeScript cannot express. */
2
+ export declare const requireSafetyCommentForTypeAssertionRule: import("@oxlint/plugins").Rule;
3
+ //# sourceMappingURL=require-safety-comment-for-type-assertion.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"require-safety-comment-for-type-assertion.d.ts","sourceRoot":"","sources":["../../../../src/vendor/anti-slop/rules/require-safety-comment-for-type-assertion.ts"],"names":[],"mappings":"AAgFA,+FAA+F;AAC/F,eAAO,MAAM,wCAAwC,gCAiDnD,CAAC"}