@autotelic/plumb 0.3.1 → 0.4.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 (268) hide show
  1. package/dist/effect/index.d.ts +3 -0
  2. package/dist/effect/index.js +56 -0
  3. package/dist/effect/rules/guarded-op-must-return-effect.d.ts +6 -0
  4. package/dist/effect/rules/guarded-op-must-return-effect.js +235 -0
  5. package/dist/effect/rules/guarded-op-must-return-option.d.ts +2 -0
  6. package/dist/effect/rules/guarded-op-must-return-option.js +88 -0
  7. package/dist/effect/rules/no-cascading-layer-provide.d.ts +6 -0
  8. package/dist/effect/rules/no-cascading-layer-provide.js +73 -0
  9. package/dist/effect/rules/no-decode-unknown-option.d.ts +7 -0
  10. package/dist/effect/rules/no-decode-unknown-option.js +34 -0
  11. package/dist/effect/rules/no-direct-browser-storage.d.ts +2 -0
  12. package/dist/effect/rules/no-direct-browser-storage.js +88 -0
  13. package/dist/effect/rules/no-direct-fetch.d.ts +2 -0
  14. package/dist/effect/rules/no-direct-fetch.js +37 -0
  15. package/dist/effect/rules/no-manual-field-guards.d.ts +6 -0
  16. package/dist/effect/rules/no-manual-field-guards.js +129 -0
  17. package/dist/effect/rules/no-nested-layer-provide.d.ts +2 -0
  18. package/dist/effect/rules/no-nested-layer-provide.js +50 -0
  19. package/dist/effect/rules/no-schema-class-modeling.d.ts +2 -0
  20. package/dist/effect/rules/no-schema-class-modeling.js +52 -0
  21. package/dist/effect/rules/no-service-constructor-imports.d.ts +2 -0
  22. package/dist/effect/rules/no-service-constructor-imports.js +42 -0
  23. package/dist/effect/rules/no-silent-error-swallow.d.ts +2 -0
  24. package/dist/effect/rules/no-silent-error-swallow.js +95 -0
  25. package/dist/effect/rules/no-static-effect-service-forwarders.d.ts +6 -0
  26. package/dist/effect/rules/no-static-effect-service-forwarders.js +222 -0
  27. package/dist/effect/rules/no-try-catch.d.ts +2 -0
  28. package/dist/effect/rules/no-try-catch.js +30 -0
  29. package/dist/effect/rules/no-unguarded-json-parse.d.ts +5 -0
  30. package/dist/effect/rules/no-unguarded-json-parse.js +200 -0
  31. package/dist/effect/rules/option-core-needs-effect-public.d.ts +5 -0
  32. package/dist/effect/rules/option-core-needs-effect-public.js +76 -0
  33. package/dist/effect/rules/prefer-die-for-precondition-defects.d.ts +5 -0
  34. package/dist/effect/rules/prefer-die-for-precondition-defects.js +112 -0
  35. package/dist/effect/rules/prefer-effect-gen-for-guard-ladders.d.ts +5 -0
  36. package/dist/effect/rules/prefer-effect-gen-for-guard-ladders.js +72 -0
  37. package/dist/effect/rules/prefer-effect-match.d.ts +2 -0
  38. package/dist/effect/rules/prefer-effect-match.js +74 -0
  39. package/dist/effect/rules/prefer-effect-predicate-over-boolean-function.d.ts +2 -0
  40. package/dist/effect/rules/prefer-effect-predicate-over-boolean-function.js +75 -0
  41. package/dist/effect/rules/prefer-named-guard-predicate.d.ts +2 -0
  42. package/dist/effect/rules/prefer-named-guard-predicate.js +93 -0
  43. package/dist/effect/rules/prefer-option-pipeline.d.ts +2 -0
  44. package/dist/effect/rules/prefer-option-pipeline.js +87 -0
  45. package/dist/effect/rules/prefer-ordering-match.d.ts +2 -0
  46. package/dist/effect/rules/prefer-ordering-match.js +135 -0
  47. package/dist/effect/rules/prefer-tagged-enum.d.ts +2 -0
  48. package/dist/effect/rules/prefer-tagged-enum.js +66 -0
  49. package/dist/effect/rules/require-schema-type-derivation.d.ts +7 -0
  50. package/dist/effect/rules/require-schema-type-derivation.js +80 -0
  51. package/dist/index.d.ts +3 -0
  52. package/dist/index.js +104 -0
  53. package/dist/meta/index.d.ts +7 -0
  54. package/{src/meta/index.ts → dist/meta/index.js} +13 -16
  55. package/dist/meta/rules/no-disable-directives.d.ts +6 -0
  56. package/dist/meta/rules/no-disable-directives.js +35 -0
  57. package/dist/meta/rules/no-manual-ancestor-walks.d.ts +2 -0
  58. package/dist/meta/rules/no-manual-ancestor-walks.js +26 -0
  59. package/dist/meta/rules/prefer-before-file-scope.d.ts +2 -0
  60. package/dist/meta/rules/prefer-before-file-scope.js +57 -0
  61. package/dist/meta/rules/require-create-once.d.ts +2 -0
  62. package/dist/meta/rules/require-create-once.js +51 -0
  63. package/dist/meta/rules/require-rule-tester.d.ts +2 -0
  64. package/dist/meta/rules/require-rule-tester.js +50 -0
  65. package/dist/rules/no-anonymous-wide-tuples.d.ts +7 -0
  66. package/dist/rules/no-anonymous-wide-tuples.js +34 -0
  67. package/dist/rules/no-barrel-export-star.d.ts +2 -0
  68. package/dist/rules/no-barrel-export-star.js +26 -0
  69. package/dist/rules/no-boolean-field-signals.d.ts +2 -0
  70. package/dist/rules/no-boolean-field-signals.js +279 -0
  71. package/dist/rules/no-builtin-throws.d.ts +6 -0
  72. package/dist/rules/no-builtin-throws.js +74 -0
  73. package/dist/rules/no-chained-type-assertions.d.ts +2 -0
  74. package/dist/rules/no-chained-type-assertions.js +54 -0
  75. package/dist/rules/no-conditional-empty-object-spread.d.ts +2 -0
  76. package/dist/rules/no-conditional-empty-object-spread.js +36 -0
  77. package/dist/rules/no-duplicated-literal-union.d.ts +6 -0
  78. package/dist/rules/no-duplicated-literal-union.js +62 -0
  79. package/dist/rules/no-exported-mutable-state.d.ts +7 -0
  80. package/dist/rules/no-exported-mutable-state.js +104 -0
  81. package/dist/rules/no-generic-export-names.d.ts +2 -0
  82. package/dist/rules/no-generic-export-names.js +141 -0
  83. package/dist/rules/no-impossible-branch-throw.d.ts +2 -0
  84. package/dist/rules/no-impossible-branch-throw.js +51 -0
  85. package/dist/rules/no-known-value-widening.d.ts +2 -0
  86. package/dist/rules/no-known-value-widening.js +176 -0
  87. package/dist/rules/no-module-mocking.d.ts +2 -0
  88. package/dist/rules/no-module-mocking.js +90 -0
  89. package/dist/rules/no-multiple-function-params.d.ts +2 -0
  90. package/dist/rules/no-multiple-function-params.js +155 -0
  91. package/dist/rules/no-mutable-environment-capture.d.ts +7 -0
  92. package/dist/rules/no-mutable-environment-capture.js +134 -0
  93. package/dist/rules/no-nondeterministic-core.d.ts +6 -0
  94. package/dist/rules/no-nondeterministic-core.js +63 -0
  95. package/dist/rules/no-object-parameters.d.ts +2 -0
  96. package/dist/rules/no-object-parameters.js +95 -0
  97. package/dist/rules/no-optional-function-parameters.d.ts +7 -0
  98. package/dist/rules/no-optional-function-parameters.js +44 -0
  99. package/dist/rules/no-product-of-state-booleans.d.ts +2 -0
  100. package/dist/rules/no-product-of-state-booleans.js +79 -0
  101. package/dist/rules/no-redundant-derived-field.d.ts +6 -0
  102. package/dist/rules/no-redundant-derived-field.js +194 -0
  103. package/dist/rules/no-reflect-apply.d.ts +2 -0
  104. package/dist/rules/no-reflect-apply.js +29 -0
  105. package/dist/rules/no-reflect-get.d.ts +2 -0
  106. package/dist/rules/no-reflect-get.js +29 -0
  107. package/dist/rules/no-reinterpret-cast.d.ts +2 -0
  108. package/dist/rules/no-reinterpret-cast.js +68 -0
  109. package/dist/rules/no-runtime-typeof.d.ts +2 -0
  110. package/dist/rules/no-runtime-typeof.js +54 -0
  111. package/dist/rules/no-sentinel-comparison-union.d.ts +2 -0
  112. package/dist/rules/no-sentinel-comparison-union.js +139 -0
  113. package/dist/rules/no-shape-in-symbol-names.d.ts +2 -0
  114. package/dist/rules/no-shape-in-symbol-names.js +39 -0
  115. package/dist/rules/no-single-use-private-functions.d.ts +17 -0
  116. package/dist/rules/no-single-use-private-functions.js +419 -0
  117. package/dist/rules/no-stacked-jsdoc-blocks.d.ts +2 -0
  118. package/dist/rules/no-stacked-jsdoc-blocks.js +50 -0
  119. package/dist/rules/no-stray-inline-comments.d.ts +2 -0
  120. package/dist/rules/no-stray-inline-comments.js +74 -0
  121. package/dist/rules/no-swappable-primitive-params.d.ts +2 -0
  122. package/dist/rules/no-swappable-primitive-params.js +96 -0
  123. package/dist/rules/no-tag-ladder-assertions.d.ts +6 -0
  124. package/dist/rules/no-tag-ladder-assertions.js +63 -0
  125. package/dist/rules/no-transposed-field-reads.d.ts +8 -0
  126. package/dist/rules/no-transposed-field-reads.js +101 -0
  127. package/dist/rules/no-unit-return-validators.d.ts +2 -0
  128. package/dist/rules/no-unit-return-validators.js +64 -0
  129. package/dist/rules/no-unknown-parameters.d.ts +2 -0
  130. package/dist/rules/no-unknown-parameters.js +82 -0
  131. package/dist/rules/no-unknown-returns.d.ts +2 -0
  132. package/dist/rules/no-unknown-returns.js +86 -0
  133. package/dist/rules/no-unknown-type-aliases.d.ts +2 -0
  134. package/dist/rules/no-unknown-type-aliases.js +64 -0
  135. package/dist/rules/no-unsafe-dictionary-type.d.ts +2 -0
  136. package/dist/rules/no-unsafe-dictionary-type.js +116 -0
  137. package/dist/rules/no-vague-test-filenames.d.ts +2 -0
  138. package/dist/rules/no-vague-test-filenames.js +61 -0
  139. package/dist/rules/no-widen-then-assert.d.ts +2 -0
  140. package/dist/rules/no-widen-then-assert.js +268 -0
  141. package/dist/rules/prefer-payload-brand.d.ts +2 -0
  142. package/dist/rules/prefer-payload-brand.js +57 -0
  143. package/dist/rules/prefer-property-tests.d.ts +5 -0
  144. package/dist/rules/prefer-property-tests.js +39 -0
  145. package/dist/rules/require-canonical-stringify-for-identity.d.ts +8 -0
  146. package/dist/rules/require-canonical-stringify-for-identity.js +72 -0
  147. package/dist/rules/require-deprecated-tag-for-legacy-comments.d.ts +2 -0
  148. package/dist/rules/require-deprecated-tag-for-legacy-comments.js +34 -0
  149. package/dist/rules/require-exhaustive-tag-switch.d.ts +7 -0
  150. package/dist/rules/require-exhaustive-tag-switch.js +34 -0
  151. package/dist/rules/require-fc-block-predicate.d.ts +2 -0
  152. package/dist/rules/require-fc-block-predicate.js +37 -0
  153. package/dist/rules/require-jsdoc-on-exported.d.ts +2 -0
  154. package/dist/rules/require-jsdoc-on-exported.js +66 -0
  155. package/dist/rules/require-published-order.d.ts +2 -0
  156. package/dist/rules/require-published-order.js +102 -0
  157. package/dist/rules/require-safety-comment-for-type-assertion.d.ts +2 -0
  158. package/dist/rules/require-safety-comment-for-type-assertion.js +53 -0
  159. package/dist/rules/require-sort-comparator.d.ts +7 -0
  160. package/dist/rules/require-sort-comparator.js +34 -0
  161. package/dist/rules/test-utils.d.ts +35 -0
  162. package/dist/rules/test-utils.js +53 -0
  163. package/{src/shared/ancestors.ts → dist/shared/ancestors.d.ts} +1 -4
  164. package/dist/shared/ancestors.js +19 -0
  165. package/dist/shared/child-nodes.d.ts +12 -0
  166. package/dist/shared/child-nodes.js +26 -0
  167. package/dist/shared/dictionary-types.d.ts +55 -0
  168. package/dist/shared/dictionary-types.js +413 -0
  169. package/{src/shared/is-node.ts → dist/shared/is-node.d.ts} +2 -6
  170. package/dist/shared/is-node.js +10 -0
  171. package/dist/shared/lexical-type-parameters.d.ts +12 -0
  172. package/dist/shared/lexical-type-parameters.js +50 -0
  173. package/dist/shared/reflect-method.d.ts +15 -0
  174. package/dist/shared/reflect-method.js +32 -0
  175. package/{src/shared/rule-options.ts → dist/shared/rule-options.d.ts} +2 -7
  176. package/dist/shared/rule-options.js +12 -0
  177. package/{src/shared/structural.ts → dist/shared/structural.d.ts} +17 -44
  178. package/dist/shared/structural.js +40 -0
  179. package/{src/testing/index.ts → dist/testing/index.d.ts} +0 -1
  180. package/dist/testing/index.js +1 -0
  181. package/dist/testing/testable-rule.d.ts +38 -0
  182. package/dist/testing/testable-rule.js +70 -0
  183. package/package.json +7 -6
  184. package/src/effect/index.ts +0 -59
  185. package/src/effect/rules/guarded-op-must-return-effect.ts +0 -236
  186. package/src/effect/rules/guarded-op-must-return-option.ts +0 -97
  187. package/src/effect/rules/no-cascading-layer-provide.ts +0 -80
  188. package/src/effect/rules/no-decode-unknown-option.ts +0 -41
  189. package/src/effect/rules/no-direct-browser-storage.ts +0 -91
  190. package/src/effect/rules/no-direct-fetch.ts +0 -44
  191. package/src/effect/rules/no-manual-field-guards.ts +0 -144
  192. package/src/effect/rules/no-nested-layer-provide.ts +0 -51
  193. package/src/effect/rules/no-schema-class-modeling.ts +0 -59
  194. package/src/effect/rules/no-service-constructor-imports.ts +0 -50
  195. package/src/effect/rules/no-silent-error-swallow.ts +0 -99
  196. package/src/effect/rules/no-static-effect-service-forwarders.ts +0 -227
  197. package/src/effect/rules/no-try-catch.ts +0 -32
  198. package/src/effect/rules/no-unguarded-json-parse.ts +0 -211
  199. package/src/effect/rules/option-core-needs-effect-public.ts +0 -81
  200. package/src/effect/rules/prefer-die-for-precondition-defects.ts +0 -118
  201. package/src/effect/rules/prefer-effect-gen-for-guard-ladders.ts +0 -76
  202. package/src/effect/rules/prefer-effect-match.ts +0 -78
  203. package/src/effect/rules/prefer-effect-predicate-over-boolean-function.ts +0 -79
  204. package/src/effect/rules/prefer-named-guard-predicate.ts +0 -105
  205. package/src/effect/rules/prefer-option-pipeline.ts +0 -95
  206. package/src/effect/rules/prefer-ordering-match.ts +0 -152
  207. package/src/effect/rules/prefer-tagged-enum.ts +0 -68
  208. package/src/effect/rules/require-schema-type-derivation.ts +0 -83
  209. package/src/index.ts +0 -106
  210. package/src/meta/rules/no-disable-directives.ts +0 -38
  211. package/src/meta/rules/no-manual-ancestor-walks.ts +0 -27
  212. package/src/meta/rules/prefer-before-file-scope.ts +0 -57
  213. package/src/meta/rules/require-create-once.ts +0 -51
  214. package/src/meta/rules/require-rule-tester.ts +0 -57
  215. package/src/rules/no-anonymous-wide-tuples.ts +0 -38
  216. package/src/rules/no-barrel-export-star.ts +0 -30
  217. package/src/rules/no-boolean-field-signals.ts +0 -305
  218. package/src/rules/no-builtin-throws.ts +0 -83
  219. package/src/rules/no-chained-type-assertions.ts +0 -65
  220. package/src/rules/no-conditional-empty-object-spread.ts +0 -42
  221. package/src/rules/no-duplicated-literal-union.ts +0 -66
  222. package/src/rules/no-exported-mutable-state.ts +0 -111
  223. package/src/rules/no-generic-export-names.ts +0 -149
  224. package/src/rules/no-impossible-branch-throw.ts +0 -55
  225. package/src/rules/no-known-value-widening.ts +0 -225
  226. package/src/rules/no-module-mocking.ts +0 -95
  227. package/src/rules/no-multiple-function-params.ts +0 -192
  228. package/src/rules/no-nondeterministic-core.ts +0 -73
  229. package/src/rules/no-object-parameters.ts +0 -127
  230. package/src/rules/no-optional-function-parameters.ts +0 -49
  231. package/src/rules/no-product-of-state-booleans.ts +0 -80
  232. package/src/rules/no-redundant-derived-field.ts +0 -192
  233. package/src/rules/no-reflect-apply.ts +0 -32
  234. package/src/rules/no-reflect-get.ts +0 -32
  235. package/src/rules/no-reinterpret-cast.ts +0 -78
  236. package/src/rules/no-runtime-typeof.ts +0 -59
  237. package/src/rules/no-sentinel-comparison-union.ts +0 -148
  238. package/src/rules/no-shape-in-symbol-names.ts +0 -45
  239. package/src/rules/no-single-use-private-functions.ts +0 -329
  240. package/src/rules/no-stacked-jsdoc-blocks.ts +0 -65
  241. package/src/rules/no-stray-inline-comments.ts +0 -79
  242. package/src/rules/no-swappable-primitive-params.ts +0 -109
  243. package/src/rules/no-tag-ladder-assertions.ts +0 -71
  244. package/src/rules/no-transposed-field-reads.ts +0 -135
  245. package/src/rules/no-unit-return-validators.ts +0 -65
  246. package/src/rules/no-unknown-parameters.ts +0 -97
  247. package/src/rules/no-unknown-returns.ts +0 -120
  248. package/src/rules/no-unknown-type-aliases.ts +0 -70
  249. package/src/rules/no-unsafe-dictionary-type.ts +0 -132
  250. package/src/rules/no-vague-test-filenames.ts +0 -67
  251. package/src/rules/no-widen-then-assert.ts +0 -345
  252. package/src/rules/prefer-payload-brand.ts +0 -67
  253. package/src/rules/prefer-property-tests.ts +0 -43
  254. package/src/rules/require-canonical-stringify-for-identity.ts +0 -80
  255. package/src/rules/require-deprecated-tag-for-legacy-comments.ts +0 -45
  256. package/src/rules/require-exhaustive-tag-switch.ts +0 -42
  257. package/src/rules/require-fc-block-predicate.ts +0 -42
  258. package/src/rules/require-jsdoc-on-exported.ts +0 -74
  259. package/src/rules/require-published-order.ts +0 -109
  260. package/src/rules/require-safety-comment-for-type-assertion.ts +0 -61
  261. package/src/rules/require-sort-comparator.ts +0 -41
  262. package/src/rules/test-utils.ts +0 -68
  263. package/src/shared/child-nodes.ts +0 -27
  264. package/src/shared/dictionary-types.ts +0 -524
  265. package/src/shared/lexical-type-parameters.ts +0 -62
  266. package/src/shared/reflect-method.ts +0 -41
  267. package/src/testing/testable-rule.test.ts +0 -68
  268. package/src/testing/testable-rule.ts +0 -86
@@ -1,80 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- import type { ESTree } from "@oxlint/plugins";
4
-
5
- import { isString } from "../../shared/structural.ts";
6
-
7
- const PROVISION_METHODS = new Set(["provide", "provideMerge"]);
8
-
9
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
10
-
11
- /** Multiple provision stages in one pipe entangle dependency tiers; combine independent layers or name each stage.
12
- *
13
- * Import tracking covers local names bound to the `Layer` export of
14
- * "effect"; re-exports are not tracked.
15
- */
16
- export const noCascadingLayerProvideRule = defineRule({
17
- meta: {
18
- type: "problem",
19
- docs: {
20
- description:
21
- "Disallow multiple Layer.provide/provideMerge stages in one pipe; combine independent dependencies in one Layer.provide([...]) and extract intentional dependency stages as named layers.",
22
- },
23
- messages: {
24
- cascadingProvide:
25
- "Multiple `Layer.provide` stages run in this pipe, entangling dependency tiers. Combine independent dependencies into one `Layer.provide([a, b])`; when a layer depends on another layer, extract that configured layer into a named value before providing it.",
26
- },
27
- },
28
- createOnce(context) {
29
- const layerNames = new Set<string>();
30
- return {
31
- before() {
32
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/"))) return false;
33
- },
34
- ImportDeclaration(node) {
35
- if (node.source.value !== "effect") return;
36
- for (const specifier of node.specifiers) {
37
- if (specifier.type === "ImportNamespaceSpecifier" || specifier.type === "ImportDefaultSpecifier") {
38
- if (specifier.local.name === "Layer") layerNames.add("Layer");
39
- continue;
40
- }
41
- if (specifier.type !== "ImportSpecifier") continue;
42
- const importedName =
43
- specifier.imported.type === "Identifier"
44
- ? specifier.imported.name
45
- : isString(specifier.imported.value)
46
- ? specifier.imported.value
47
- : undefined;
48
- if (importedName !== "Layer") continue;
49
- layerNames.add(specifier.local.name);
50
- }
51
- },
52
- CallExpression(node) {
53
- const callee = node.callee;
54
- if (
55
- callee.type !== "MemberExpression" ||
56
- callee.computed ||
57
- callee.property.type !== "Identifier" ||
58
- callee.property.name !== "pipe"
59
- ) {
60
- return;
61
- }
62
- let stages = 0;
63
- for (const argument of node.arguments) {
64
- if (
65
- argument.type === "CallExpression" &&
66
- argument.callee.type === "MemberExpression" &&
67
- !argument.callee.computed &&
68
- argument.callee.object.type === "Identifier" &&
69
- layerNames.has(argument.callee.object.name) &&
70
- argument.callee.property.type === "Identifier" &&
71
- PROVISION_METHODS.has(argument.callee.property.name)
72
- )
73
- stages += 1;
74
- }
75
- if (stages < 2) return;
76
- context.report({ node, messageId: "cascadingProvide" });
77
- },
78
- };
79
- },
80
- });
@@ -1,41 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- import type { ESTree } from "@oxlint/plugins";
4
-
5
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$/u;
6
-
7
- /**
8
- * decodeUnknownOption collapses every schema mismatch into None, discarding
9
- * the issue tree that explains why decoding failed. Prefer adapters that keep
10
- * the issues: SchemaParser.decodeUnknownResult for sync cores,
11
- * decodeUnknownEffect on the Effect channel.
12
- */
13
- export const noDecodeUnknownOptionRule = defineRule({
14
- meta: {
15
- type: "problem",
16
- docs: {
17
- description:
18
- "Disallow Schema.decodeUnknownOption outside tests: it discards mismatch details. Return the schema issues as typed failure evidence instead.",
19
- },
20
- messages: {
21
- noDecodeUnknownOption:
22
- "`decodeUnknownOption` intentionally discards mismatch details, so callers cannot learn why decoding failed. Use `SchemaParser.decodeUnknownResult(schema)` (sync cores) or `SchemaParser.decodeUnknownEffect(schema)` (Effect channel) and fold the issue into your tagged error's evidence.",
23
- },
24
- },
25
- createOnce(context) {
26
- return {
27
- before() {
28
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/"))) return false;
29
- },
30
- MemberExpression(node) {
31
- if (
32
- !node.computed &&
33
- node.property.type === "Identifier" &&
34
- node.property.name === "decodeUnknownOption"
35
- ) {
36
- context.report({ node, messageId: "noDecodeUnknownOption" });
37
- }
38
- },
39
- };
40
- },
41
- });
@@ -1,91 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- import type { ESTree } from "@oxlint/plugins";
4
-
5
- import { ancestorsOf } from "../../shared/ancestors.ts";
6
-
7
- import { isString } from "../../shared/structural.ts";
8
-
9
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
10
-
11
- const BANNED_STORAGE = new Set(["indexedDB", "localStorage", "sessionStorage"]);
12
-
13
- /**
14
- * The banned-storage global named by an identifier, if any.
15
- *
16
- * @param {ESTree.Node} node - The identifier node to test.
17
- * @returns {string | null} The banned storage name, or null.
18
- */
19
- function storageName(node: ESTree.Node): string | null {
20
- if (node.type !== "Identifier") return null;
21
- return BANNED_STORAGE.has(node.name) ? node.name : null;
22
- }
23
-
24
- /** Browser storage globals hide I/O from the Effect runtime; persist through KeyValueStore or an injected store. */
25
- export const noDirectBrowserStorageRule = defineRule({
26
- meta: {
27
- type: "problem",
28
- docs: {
29
- description:
30
- "Disallow direct browser storage globals (indexedDB, localStorage, sessionStorage); persist through Effect's KeyValueStore/IndexedDb modules or an injected storage service.",
31
- },
32
- messages: {
33
- directStorage:
34
- "`{{name}}` is reached directly, hiding I/O from the Effect runtime. Persist through Effect's KeyValueStore/IndexedDb layer or an injected storage service so access stays testable and swappable.",
35
- },
36
- },
37
- createOnce(context) {
38
- const reportStorage = (node: ESTree.Node, name: string): void => {
39
- context.report({ node, messageId: "directStorage", data: { name } });
40
- };
41
- return {
42
- before() {
43
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/"))) return false;
44
- },
45
- Identifier(node) {
46
- const name = storageName(node);
47
- if (name === null) return;
48
- const chain = ancestorsOf(context.sourceCode, node);
49
- const parent = chain[0];
50
- const grandparent = chain[1];
51
- if (parent === undefined) return;
52
- if (parent.type === "MemberExpression") {
53
- return;
54
- }
55
- if (parent.type === "Property") {
56
- const containerType = grandparent === undefined ? "" : grandparent.type;
57
- if (parent.key === node && parent.value !== node && containerType !== "ObjectPattern") {
58
- return;
59
- }
60
- }
61
- if (parent.type === "ImportSpecifier") {
62
- if (parent.imported === node && parent.local !== node) {
63
- return;
64
- }
65
- }
66
- reportStorage(node, name);
67
- },
68
- MemberExpression(node) {
69
- const direct = storageName(node.object);
70
- if (direct !== null) {
71
- reportStorage(node, direct);
72
- return;
73
- }
74
- if (node.object.type !== "Identifier") return;
75
- const objectName = node.object.name;
76
- if (objectName !== "globalThis" && objectName !== "window") return;
77
- let propertyName: string | undefined;
78
- if (node.computed) {
79
- if (node.property.type === "Literal" && isString(node.property.value)) {
80
- propertyName = node.property.value;
81
- }
82
- } else if (node.property.type === "Identifier") {
83
- propertyName = node.property.name;
84
- }
85
- if (propertyName !== undefined && BANNED_STORAGE.has(propertyName)) {
86
- reportStorage(node, propertyName);
87
- }
88
- },
89
- };
90
- },
91
- });
@@ -1,44 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- import type { ESTree } from "@oxlint/plugins";
4
-
5
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
6
-
7
- /** Bare `fetch` reaches past the application boundary un-injected; require a client service. */
8
- export const noDirectFetchRule = defineRule({
9
- meta: {
10
- type: "problem",
11
- docs: {
12
- description:
13
- "Disallow direct fetch calls; acquire an HTTP client service (e.g. Effect's HttpClient) so requests are injectable, cancellable, and testable.",
14
- },
15
- messages: {
16
- directFetch:
17
- "Bare `fetch` bypasses the injected HTTP client service. Route the request through a client dependency so calls are injectable, cancellable, and testable.",
18
- },
19
- },
20
- createOnce(context) {
21
- return {
22
- before() {
23
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/"))) return false;
24
- },
25
- CallExpression(node) {
26
- const callee = node.callee;
27
- if (callee.type === "Identifier" && callee.name === "fetch") {
28
- context.report({ node, messageId: "directFetch" });
29
- return;
30
- }
31
- if (
32
- callee.type === "MemberExpression" &&
33
- callee.computed !== true &&
34
- callee.property.type === "Identifier" &&
35
- callee.property.name === "fetch" &&
36
- callee.object.type === "Identifier" &&
37
- (callee.object.name === "window" || callee.object.name === "globalThis")
38
- ) {
39
- context.report({ node, messageId: "directFetch" });
40
- }
41
- },
42
- };
43
- },
44
- });
@@ -1,144 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- import type { ESTree } from "@oxlint/plugins";
4
- import { ancestorsOf } from "../../shared/ancestors.ts";
5
-
6
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
7
-
8
- function calleeName(node: ESTree.CallExpression): string | null {
9
- const callee = node.callee;
10
- if (callee.type === "MemberExpression" && callee.property.type === "Identifier") {
11
- return callee.property.name;
12
- }
13
- return null;
14
- }
15
-
16
- /** Whether this node sits inside a `Schema.makeFilter` predicate, where ad-hoc checks are the point.
17
- *
18
- * @param {ESTree.Node} node - The visited node.
19
- * @param {ReadonlyArray<ESTree.Node>} ancestors - Nearest-first ancestor chain of `node`.
20
- * @returns {boolean} True when enclosed by a makeFilter call.
21
- */
22
- function insideMakeFilter(node: ESTree.Node, ancestors: ReadonlyArray<ESTree.Node>): boolean {
23
- for (let index = ancestors.length - 1; index >= 0; index--) {
24
- const current = ancestors[index]!;
25
- if (current.type === "Program") break;
26
- if (current.type === "CallExpression" && calleeName(current) === "makeFilter") {
27
- return true;
28
- }
29
- }
30
- return false;
31
- }
32
-
33
- /**
34
- * Once a module decodes payloads through SchemaParser, per-field validation
35
- * belongs in Schema refinements (checks/filters) so evidence flows through the
36
- * schema issue channel instead of hand-rolled ladders beside the decoder.
37
- */
38
- export const noManualFieldGuardsRule = defineRule({
39
- meta: {
40
- type: "suggestion",
41
- docs: {
42
- description:
43
- "In modules that decode via SchemaParser, require field validation to live in Schema refinements rather than hand-rolled regex tests and Option-tag guards.",
44
- },
45
- messages: {
46
- regexTest:
47
- "Hand-rolled lexical check beside a SchemaParser decode. Move this predicate into a Schema refinement (`.check(Schema.makeFilter(...))`) so failures surface as schema issue evidence.",
48
- optionGuard:
49
- "Hand-rolled Option-tag guard beside a SchemaParser decode. Validate the field with a Schema refinement (or decode into the domain value via `SchemaGetter.transformOrFail`) so the ladder branch disappears.",
50
- },
51
- },
52
- createOnce(context) {
53
- let hasDecode = false;
54
- const pending: Array<{ node: ESTree.Node; messageId: "regexTest" | "optionGuard" }> = [];
55
- const optionVars = new Set<string>();
56
- const queue = (node: ESTree.Node, messageId: "regexTest" | "optionGuard"): void => {
57
- if (insideMakeFilter(node, ancestorsOf(context.sourceCode, node))) return;
58
- pending.push({ node, messageId });
59
- };
60
- return {
61
- before() {
62
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/"))) return false;
63
- hasDecode = false;
64
- pending.length = 0;
65
- optionVars.clear();
66
- },
67
- CallExpression(node) {
68
- const name = calleeName(node);
69
- if (name !== null && name.startsWith("decodeUnknown")) hasDecode = true;
70
- {
71
- const callee = node.callee;
72
- if (
73
- callee.type === "MemberExpression" &&
74
- !callee.computed &&
75
- callee.property.type === "Identifier" &&
76
- callee.property.name === "test"
77
- ) {
78
- queue(node, "regexTest");
79
- return;
80
- }
81
- }
82
- if (name === "isNone" || name === "isSome") {
83
- const argument = node.arguments[0];
84
- if (
85
- argument !== undefined &&
86
- argument.type === "Identifier" &&
87
- optionVars.has(argument.name)
88
- ) {
89
- queue(node, "optionGuard");
90
- }
91
- }
92
- },
93
- IfStatement(node) {
94
- const binaryTest = node.test;
95
- if (binaryTest.type !== "BinaryExpression") return;
96
- if (binaryTest.operator !== "===" && binaryTest.operator !== "!==") return;
97
- const sides = [binaryTest.left, binaryTest.right];
98
- const hasTagSide = sides.some(
99
- (side) =>
100
- side.type === "MemberExpression" &&
101
- side.property.type === "Identifier" &&
102
- side.property.name === "_tag",
103
- );
104
- const literal = sides.find((side) => side.type === "Literal");
105
- if (
106
- !hasTagSide ||
107
- literal === undefined ||
108
- literal.type !== "Literal" ||
109
- (literal.value !== "None" && literal.value !== "Some")
110
- )
111
- return;
112
- const tagMember = sides.find((side): side is ESTree.MemberExpression => {
113
- return side.type === "MemberExpression" && side.object.type === "Identifier";
114
- });
115
- if (
116
- tagMember !== undefined &&
117
- tagMember.object.type === "Identifier" &&
118
- optionVars.has(tagMember.object.name)
119
- ) {
120
- queue(node.test, "optionGuard");
121
- }
122
- },
123
- "Program:exit"() {
124
- if (!hasDecode) return;
125
- for (const { node, messageId } of pending) {
126
- context.report({ node, messageId });
127
- }
128
- },
129
- VariableDeclarator(node) {
130
- if (node.init !== null && node.init !== undefined && node.init.type === "CallExpression") {
131
- const name = calleeName(node.init);
132
- if (
133
- name !== null &&
134
- name.startsWith("from") &&
135
- name.endsWith("Option") &&
136
- node.id.type === "Identifier"
137
- ) {
138
- optionVars.add(node.id.name);
139
- }
140
- }
141
- },
142
- };
143
- },
144
- });
@@ -1,51 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- import type { ESTree } from "@oxlint/plugins";
4
-
5
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
6
-
7
- /**
8
- * Whether a call targets `Layer.provide`.
9
- *
10
- * @param {ESTree.Node} node - The candidate call expression.
11
- * @returns {boolean} True when the call is a Layer.provide invocation.
12
- */
13
- function isLayerProvide(node: ESTree.Node): boolean {
14
- if (node.type !== "CallExpression") return false;
15
- const callee = node.callee;
16
- if (callee.type !== "MemberExpression" || callee.computed) return false;
17
- if (callee.object.type !== "Identifier") return false;
18
- return callee.object.name === "Layer" && callee.property.type === "Identifier" && callee.property.name === "provide";
19
- }
20
- /** Nested Layer.provide calls hide the dependency stage; extract the inner layer or use provideMerge. */
21
- export const noNestedLayerProvideRule = defineRule({
22
- meta: {
23
- type: "problem",
24
- docs: {
25
- description:
26
- "Disallow Layer.provide nested inside Layer.provide; extract the inner layer to a named value or use Layer.provideMerge so each dependency stage is visible.",
27
- },
28
- messages: {
29
- nestedProvide:
30
- "`Layer.provide` inside `Layer.provide` hides this dependency stage. Extract the inner layer into a named value, or use `Layer.provideMerge` when the layers are independent.",
31
- },
32
- },
33
- createOnce(context) {
34
- return {
35
- before() {
36
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/"))) return false;
37
- },
38
- CallExpression(node) {
39
- if (!isLayerProvide(node)) return;
40
- for (const argument of node.arguments) {
41
- if (isLayerProvide(argument)) {
42
- context.report({
43
- node: argument,
44
- messageId: "nestedProvide",
45
- });
46
- }
47
- }
48
- },
49
- };
50
- },
51
- });
@@ -1,59 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- import type { ESTree } from "@oxlint/plugins";
4
-
5
- const BANNED = new Set(["Class", "TaggedClass"]);
6
-
7
- function isBannedSchemaStatic(
8
- expression: ESTree.Expression | ESTree.TSTypeName | null | undefined,
9
- ): expression is Extract<ESTree.Expression, { type: "MemberExpression" }> {
10
- return (
11
- expression?.type === "MemberExpression" &&
12
- expression.object.type === "Identifier" &&
13
- expression.object.name === "Schema" &&
14
- expression.property.type === "Identifier" &&
15
- BANNED.has(expression.property.name)
16
- );
17
- }
18
-
19
- /** Schema.Class/TaggedClass must not be the default data-modeling pattern. */
20
- export const noSchemaClassModelingRule = defineRule({
21
- meta: {
22
- type: "problem",
23
- docs: {
24
- description:
25
- "Disallow Schema.Class and Schema.TaggedClass as default data-modeling patterns; model records with Schema.Struct plus a same-name interface, variants with Schema.TaggedUnion/TaggedStruct, and typed errors with Schema.TaggedError.",
26
- },
27
- messages: {
28
- schemaClass:
29
- "Do not introduce `Schema.{{name}}` as a data-modeling pattern. Model records with `Schema.Struct(...)` plus a same-name interface, tagged variants with `Schema.TaggedStruct`/`Schema.TaggedUnion`, and typed errors with `Schema.TaggedError`.",
30
- },
31
- },
32
- createOnce(context) {
33
- const checkExpression = (callee: ESTree.Expression | null | undefined): void => {
34
- if (!isBannedSchemaStatic(callee)) return;
35
- const property = callee.property;
36
- if (property.type !== "Identifier") return;
37
- context.report({
38
- node: callee,
39
- messageId: "schemaClass",
40
- data: { name: property.name },
41
- });
42
- };
43
- return {
44
- CallExpression(node) {
45
- checkExpression(node.callee);
46
- },
47
- ClassDeclaration(node) {
48
- if (!isBannedSchemaStatic(node.superClass)) return;
49
- const property = node.superClass.property;
50
- if (property.type !== "Identifier") return;
51
- context.report({
52
- node: node.superClass,
53
- messageId: "schemaClass",
54
- data: { name: property.name },
55
- });
56
- },
57
- };
58
- },
59
- });
@@ -1,50 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- import type { ESTree } from "@oxlint/plugins";
4
-
5
- const SERVICE_CONSTRUCTOR_NAME = /^make[A-Z]/u;
6
- const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
7
-
8
- /** Keep dependency-bearing Effect service constructors local to their owning capability modules. */
9
- export const noServiceConstructorImportsRule = defineRule({
10
- meta: {
11
- type: "problem",
12
- docs: {
13
- description:
14
- "Disallow project-local make<CapabilityName> imports outside test and spec files.",
15
- },
16
- messages: {
17
- serviceConstructorImport:
18
- 'Do not import Effect service constructor "{{name}}" into runtime code. Import the owning Layer, yield the contextual service, and allow its requirements to propagate to the composition root.',
19
- },
20
- },
21
- createOnce(context) {
22
- let isTestFile = false;
23
-
24
- return {
25
- before() {
26
- isTestFile = TEST_FILE.test(context.filename.replaceAll("\\", "/"));
27
- },
28
- ImportDeclaration(node) {
29
- const source = node.source.value;
30
- if (isTestFile || !(source.startsWith("./") || source.startsWith("../"))) return;
31
-
32
- for (const specifier of node.specifiers) {
33
- if (specifier.type !== "ImportSpecifier") continue;
34
-
35
- const importedName =
36
- specifier.imported.type === "Identifier"
37
- ? specifier.imported.name
38
- : specifier.imported.value;
39
- if (!SERVICE_CONSTRUCTOR_NAME.test(importedName)) continue;
40
-
41
- context.report({
42
- node: specifier,
43
- messageId: "serviceConstructorImport",
44
- data: { name: importedName },
45
- });
46
- }
47
- },
48
- };
49
- },
50
- });
@@ -1,99 +0,0 @@
1
- import { defineRule } from "@oxlint/plugins";
2
-
3
- import type { ESTree } from "@oxlint/plugins";
4
-
5
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
6
-
7
- const CATCH_METHODS = new Set([
8
- "catch",
9
- "catchTag",
10
- "catchTags",
11
- "catchReason",
12
- "catchReasons",
13
- ]);
14
-
15
- const VOID_OR_UNIT_METHODS = new Set(["void", "unit"]);
16
-
17
- /**
18
- * Whether the expression is the bare `Effect.void` / `Effect.unit` member.
19
- *
20
- * @param {ESTree.Node | null | undefined} node - The candidate member expression.
21
- * @returns {boolean} True when the expression reads Effect.void or Effect.unit.
22
- */
23
- function isEffectVoidOrUnit(node: ESTree.Node | null | undefined): boolean {
24
- if (node === null || node === undefined || node.type !== "MemberExpression") return false;
25
- if (node.object.type !== "Identifier" || node.object.name !== "Effect") return false;
26
- return node.property.type === "Identifier" && VOID_OR_UNIT_METHODS.has(node.property.name);
27
- }
28
-
29
- /**
30
- * A recovery callback that reduces every failure to Effect.void/unit swallows it silently.
31
- *
32
- * @param {ESTree.Node} handler - The catch handler argument to inspect.
33
- * @returns {boolean} True when the handler can only produce Effect.void/unit.
34
- */
35
- function returnsOnlyVoid(handler: ESTree.Node): boolean {
36
- if (
37
- handler.type !== "ArrowFunctionExpression" &&
38
- handler.type !== "FunctionExpression"
39
- ) {
40
- return false;
41
- }
42
- const body = handler.body;
43
- if (body === null || body === undefined) return false;
44
- if (isEffectVoidOrUnit(body)) return true;
45
- if (body.type !== "BlockStatement") return false;
46
- if (body.body.length !== 1) return false;
47
- const statement = body.body[0]!;
48
- if (statement.type !== "ReturnStatement") return false;
49
- return isEffectVoidOrUnit(statement.argument);
50
- }
51
-
52
- /** Recovering into Effect.void/Effect.unit erases the failure; recover meaningfully or propagate. */
53
- export const noSilentErrorSwallowRule = defineRule({
54
- meta: {
55
- type: "problem",
56
- docs: {
57
- description:
58
- "Disallow Effect catch handlers that reduce failures to Effect.void or Effect.unit; recover meaningfully, transform the error, or let it propagate.",
59
- },
60
- messages: {
61
- silentSwallow:
62
- "This catch handler reduces every failure to `Effect.void`/`Effect.unit`, erasing the error. Recover meaningfully, transform it into a tagged failure, or remove the handler and let the error propagate.",
63
- },
64
- },
65
- createOnce(context) {
66
- return {
67
- before() {
68
- if (TEST_FILE.test(context.filename.replaceAll("\\", "/"))) return false;
69
- },
70
- CallExpression(node) {
71
- const callee = node.callee;
72
- if (
73
- callee.type !== "MemberExpression" ||
74
- callee.computed ||
75
- callee.object.type !== "Identifier" ||
76
- callee.object.name !== "Effect" ||
77
- callee.property.type !== "Identifier" ||
78
- !CATCH_METHODS.has(callee.property.name)
79
- ) {
80
- return;
81
- }
82
- for (const argument of node.arguments) {
83
- if (returnsOnlyVoid(argument)) {
84
- context.report({ node, messageId: "silentSwallow" });
85
- return;
86
- }
87
- if (argument.type !== "ObjectExpression") continue;
88
- for (const property of argument.properties) {
89
- if (property.type !== "Property") continue;
90
- if (returnsOnlyVoid(property.value)) {
91
- context.report({ node, messageId: "silentSwallow" });
92
- return;
93
- }
94
- }
95
- }
96
- },
97
- };
98
- },
99
- });