@autotelic/plumb 0.5.2 → 0.6.1

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 (282) hide show
  1. package/README.md +81 -8
  2. package/dist/configs/recommended-rules.d.ts +36 -0
  3. package/dist/configs/recommended-rules.js +57 -0
  4. package/dist/effect/index.js +4 -0
  5. package/dist/effect/rules/guarded-op-must-return-effect.js +1 -1
  6. package/dist/effect/rules/no-cascading-layer-provide.js +1 -1
  7. package/dist/effect/rules/no-decode-unknown-option.js +1 -1
  8. package/dist/effect/rules/no-direct-browser-storage.js +3 -3
  9. package/dist/effect/rules/no-direct-fetch.js +1 -1
  10. package/dist/effect/rules/no-manual-field-guards.js +1 -1
  11. package/dist/effect/rules/no-nested-layer-provide.js +1 -1
  12. package/dist/effect/rules/no-nullish-default-on-partial-input.d.ts +13 -0
  13. package/dist/effect/rules/no-nullish-default-on-partial-input.js +109 -0
  14. package/dist/effect/rules/no-raw-error-forwarding.d.ts +16 -0
  15. package/dist/effect/rules/no-raw-error-forwarding.js +108 -0
  16. package/dist/effect/rules/no-silent-error-swallow.js +1 -1
  17. package/dist/effect/rules/no-static-effect-service-forwarders.js +5 -4
  18. package/dist/effect/rules/no-try-catch.js +1 -1
  19. package/dist/effect/rules/no-unguarded-json-parse.js +1 -1
  20. package/dist/effect/rules/option-core-needs-effect-public.js +1 -1
  21. package/dist/effect/rules/prefer-die-for-precondition-defects.js +1 -1
  22. package/dist/effect/rules/prefer-effect-gen-for-guard-ladders.js +1 -1
  23. package/dist/effect/rules/prefer-effect-match.js +2 -2
  24. package/dist/effect/rules/prefer-effect-predicate-over-boolean-function.js +1 -1
  25. package/dist/effect/rules/prefer-named-guard-predicate.js +1 -1
  26. package/dist/effect/rules/prefer-option-pipeline.js +13 -12
  27. package/dist/effect/rules/prefer-ordering-match.js +1 -1
  28. package/dist/effect/rules/prefer-tagged-enum.js +1 -1
  29. package/dist/effect/rules/require-schema-type-derivation.d.ts +8 -2
  30. package/dist/effect/rules/require-schema-type-derivation.js +14 -4
  31. package/dist/index.js +10 -0
  32. package/dist/react/rules/require-dot-notation-exports.js +1 -1
  33. package/dist/react/rules/require-guarded-context-hook.js +1 -1
  34. package/dist/react/rules/require-tripartite-context.js +1 -1
  35. package/dist/react/rules/use-encapsulation.js +1 -1
  36. package/dist/rules/no-adapter-in-values.d.ts +12 -0
  37. package/dist/rules/no-adapter-in-values.js +110 -0
  38. package/dist/rules/no-builtin-throws.js +1 -1
  39. package/dist/rules/no-duplicated-literal-union.d.ts +7 -0
  40. package/dist/rules/no-duplicated-literal-union.js +5 -1
  41. package/dist/rules/no-generic-export-names.js +1 -1
  42. package/dist/rules/no-multiple-function-params.js +26 -12
  43. package/dist/rules/no-mutable-environment-capture.js +2 -2
  44. package/dist/rules/no-nondeterministic-core.js +1 -1
  45. package/dist/rules/no-nullable-value-field.d.ts +16 -0
  46. package/dist/rules/no-nullable-value-field.js +117 -0
  47. package/dist/rules/no-optional-function-parameters.js +1 -1
  48. package/dist/rules/no-row-coercion.d.ts +13 -0
  49. package/dist/rules/no-row-coercion.js +135 -0
  50. package/dist/rules/no-single-use-private-functions.js +1 -1
  51. package/dist/rules/no-sql-string-interpolation.d.ts +7 -0
  52. package/dist/rules/no-sql-string-interpolation.js +62 -0
  53. package/dist/rules/no-stray-inline-comments.js +1 -1
  54. package/dist/rules/no-string-instant.d.ts +15 -0
  55. package/dist/rules/no-string-instant.js +108 -0
  56. package/dist/rules/no-swappable-primitive-params.js +1 -1
  57. package/dist/rules/no-tag-ladder-assertions.js +1 -1
  58. package/dist/rules/no-vague-test-filenames.js +1 -1
  59. package/dist/rules/prefer-property-tests.d.ts +5 -0
  60. package/dist/rules/prefer-property-tests.js +7 -0
  61. package/dist/rules/require-jsdoc-on-exported.js +1 -1
  62. package/dist/shared/ancestors.d.ts +1 -1
  63. package/dist/shared/ancestors.js +1 -1
  64. package/dist/shared/values-path.d.ts +12 -0
  65. package/dist/shared/values-path.js +56 -0
  66. package/dist/src/configs/recommended-rules.d.ts +20 -0
  67. package/dist/src/configs/recommended-rules.js +22 -0
  68. package/dist/src/effect/index.d.ts +3 -0
  69. package/dist/src/effect/index.js +60 -0
  70. package/dist/src/effect/rules/guarded-op-must-return-effect.d.ts +6 -0
  71. package/dist/src/effect/rules/guarded-op-must-return-effect.js +235 -0
  72. package/dist/src/effect/rules/guarded-op-must-return-option.d.ts +2 -0
  73. package/dist/src/effect/rules/guarded-op-must-return-option.js +88 -0
  74. package/dist/src/effect/rules/no-cascading-layer-provide.d.ts +6 -0
  75. package/dist/src/effect/rules/no-cascading-layer-provide.js +73 -0
  76. package/dist/src/effect/rules/no-decode-unknown-option.d.ts +7 -0
  77. package/dist/src/effect/rules/no-decode-unknown-option.js +34 -0
  78. package/dist/src/effect/rules/no-direct-browser-storage.d.ts +2 -0
  79. package/dist/src/effect/rules/no-direct-browser-storage.js +88 -0
  80. package/dist/src/effect/rules/no-direct-fetch.d.ts +2 -0
  81. package/dist/src/effect/rules/no-direct-fetch.js +37 -0
  82. package/dist/src/effect/rules/no-manual-field-guards.d.ts +6 -0
  83. package/dist/src/effect/rules/no-manual-field-guards.js +129 -0
  84. package/dist/src/effect/rules/no-nested-layer-provide.d.ts +2 -0
  85. package/dist/src/effect/rules/no-nested-layer-provide.js +50 -0
  86. package/dist/src/effect/rules/no-nullish-default-on-partial-input.d.ts +13 -0
  87. package/dist/src/effect/rules/no-nullish-default-on-partial-input.js +109 -0
  88. package/dist/src/effect/rules/no-raw-error-forwarding.d.ts +12 -0
  89. package/dist/src/effect/rules/no-raw-error-forwarding.js +103 -0
  90. package/dist/src/effect/rules/no-schema-class-modeling.d.ts +2 -0
  91. package/dist/src/effect/rules/no-schema-class-modeling.js +52 -0
  92. package/dist/src/effect/rules/no-service-constructor-imports.d.ts +2 -0
  93. package/dist/src/effect/rules/no-service-constructor-imports.js +42 -0
  94. package/dist/src/effect/rules/no-silent-error-swallow.d.ts +2 -0
  95. package/dist/src/effect/rules/no-silent-error-swallow.js +95 -0
  96. package/dist/src/effect/rules/no-static-effect-service-forwarders.d.ts +6 -0
  97. package/dist/src/effect/rules/no-static-effect-service-forwarders.js +222 -0
  98. package/dist/src/effect/rules/no-try-catch.d.ts +2 -0
  99. package/dist/src/effect/rules/no-try-catch.js +30 -0
  100. package/dist/src/effect/rules/no-unguarded-json-parse.d.ts +5 -0
  101. package/dist/src/effect/rules/no-unguarded-json-parse.js +200 -0
  102. package/dist/src/effect/rules/option-core-needs-effect-public.d.ts +5 -0
  103. package/dist/src/effect/rules/option-core-needs-effect-public.js +76 -0
  104. package/dist/src/effect/rules/prefer-die-for-precondition-defects.d.ts +5 -0
  105. package/dist/src/effect/rules/prefer-die-for-precondition-defects.js +112 -0
  106. package/dist/src/effect/rules/prefer-effect-gen-for-guard-ladders.d.ts +5 -0
  107. package/dist/src/effect/rules/prefer-effect-gen-for-guard-ladders.js +72 -0
  108. package/dist/src/effect/rules/prefer-effect-match.d.ts +2 -0
  109. package/dist/src/effect/rules/prefer-effect-match.js +74 -0
  110. package/dist/src/effect/rules/prefer-effect-predicate-over-boolean-function.d.ts +2 -0
  111. package/dist/src/effect/rules/prefer-effect-predicate-over-boolean-function.js +75 -0
  112. package/dist/src/effect/rules/prefer-named-guard-predicate.d.ts +2 -0
  113. package/dist/src/effect/rules/prefer-named-guard-predicate.js +93 -0
  114. package/dist/src/effect/rules/prefer-option-pipeline.d.ts +2 -0
  115. package/dist/src/effect/rules/prefer-option-pipeline.js +87 -0
  116. package/dist/src/effect/rules/prefer-ordering-match.d.ts +2 -0
  117. package/dist/src/effect/rules/prefer-ordering-match.js +135 -0
  118. package/dist/src/effect/rules/prefer-tagged-enum.d.ts +2 -0
  119. package/dist/src/effect/rules/prefer-tagged-enum.js +66 -0
  120. package/dist/src/effect/rules/require-schema-type-derivation.d.ts +7 -0
  121. package/dist/src/effect/rules/require-schema-type-derivation.js +80 -0
  122. package/dist/src/index.d.ts +3 -0
  123. package/dist/src/index.js +106 -0
  124. package/dist/src/meta/index.d.ts +7 -0
  125. package/dist/src/meta/index.js +22 -0
  126. package/dist/src/meta/rules/no-disable-directives.d.ts +6 -0
  127. package/dist/src/meta/rules/no-disable-directives.js +35 -0
  128. package/dist/src/meta/rules/no-manual-ancestor-walks.d.ts +2 -0
  129. package/dist/src/meta/rules/no-manual-ancestor-walks.js +26 -0
  130. package/dist/src/meta/rules/prefer-before-file-scope.d.ts +2 -0
  131. package/dist/src/meta/rules/prefer-before-file-scope.js +57 -0
  132. package/dist/src/meta/rules/require-create-once.d.ts +2 -0
  133. package/dist/src/meta/rules/require-create-once.js +51 -0
  134. package/dist/src/meta/rules/require-rule-tester.d.ts +2 -0
  135. package/dist/src/meta/rules/require-rule-tester.js +50 -0
  136. package/dist/src/react/index.d.ts +3 -0
  137. package/dist/src/react/index.js +16 -0
  138. package/dist/src/react/role.d.ts +23 -0
  139. package/dist/src/react/role.js +30 -0
  140. package/dist/src/react/rules/require-dot-notation-exports.d.ts +27 -0
  141. package/dist/src/react/rules/require-dot-notation-exports.js +144 -0
  142. package/dist/src/react/rules/require-guarded-context-hook.d.ts +19 -0
  143. package/dist/src/react/rules/require-guarded-context-hook.js +167 -0
  144. package/dist/src/react/rules/require-tripartite-context.d.ts +17 -0
  145. package/dist/src/react/rules/require-tripartite-context.js +160 -0
  146. package/dist/src/react/rules/use-encapsulation.d.ts +22 -0
  147. package/dist/src/react/rules/use-encapsulation.js +97 -0
  148. package/dist/src/rules/no-anonymous-wide-tuples.d.ts +7 -0
  149. package/dist/src/rules/no-anonymous-wide-tuples.js +34 -0
  150. package/dist/src/rules/no-barrel-export-star.d.ts +2 -0
  151. package/dist/src/rules/no-barrel-export-star.js +26 -0
  152. package/dist/src/rules/no-boolean-field-signals.d.ts +2 -0
  153. package/dist/src/rules/no-boolean-field-signals.js +279 -0
  154. package/dist/src/rules/no-builtin-throws.d.ts +6 -0
  155. package/dist/src/rules/no-builtin-throws.js +74 -0
  156. package/dist/src/rules/no-chained-type-assertions.d.ts +2 -0
  157. package/dist/src/rules/no-chained-type-assertions.js +54 -0
  158. package/dist/src/rules/no-conditional-empty-object-spread.d.ts +2 -0
  159. package/dist/src/rules/no-conditional-empty-object-spread.js +36 -0
  160. package/dist/src/rules/no-duplicated-literal-union.d.ts +6 -0
  161. package/dist/src/rules/no-duplicated-literal-union.js +66 -0
  162. package/dist/src/rules/no-exported-mutable-state.d.ts +7 -0
  163. package/dist/src/rules/no-exported-mutable-state.js +104 -0
  164. package/dist/src/rules/no-generic-export-names.d.ts +2 -0
  165. package/dist/src/rules/no-generic-export-names.js +141 -0
  166. package/dist/src/rules/no-impossible-branch-throw.d.ts +2 -0
  167. package/dist/src/rules/no-impossible-branch-throw.js +51 -0
  168. package/dist/src/rules/no-known-value-widening.d.ts +2 -0
  169. package/dist/src/rules/no-known-value-widening.js +176 -0
  170. package/dist/src/rules/no-module-mocking.d.ts +2 -0
  171. package/dist/src/rules/no-module-mocking.js +90 -0
  172. package/dist/src/rules/no-multiple-function-params.d.ts +2 -0
  173. package/dist/src/rules/no-multiple-function-params.js +155 -0
  174. package/dist/src/rules/no-mutable-environment-capture.d.ts +7 -0
  175. package/dist/src/rules/no-mutable-environment-capture.js +134 -0
  176. package/dist/src/rules/no-nondeterministic-core.d.ts +6 -0
  177. package/dist/src/rules/no-nondeterministic-core.js +63 -0
  178. package/dist/src/rules/no-object-parameters.d.ts +2 -0
  179. package/dist/src/rules/no-object-parameters.js +95 -0
  180. package/dist/src/rules/no-optional-function-parameters.d.ts +7 -0
  181. package/dist/src/rules/no-optional-function-parameters.js +44 -0
  182. package/dist/src/rules/no-product-of-state-booleans.d.ts +2 -0
  183. package/dist/src/rules/no-product-of-state-booleans.js +79 -0
  184. package/dist/src/rules/no-redundant-derived-field.d.ts +6 -0
  185. package/dist/src/rules/no-redundant-derived-field.js +194 -0
  186. package/dist/src/rules/no-reflect-apply.d.ts +2 -0
  187. package/dist/src/rules/no-reflect-apply.js +29 -0
  188. package/dist/src/rules/no-reflect-get.d.ts +2 -0
  189. package/dist/src/rules/no-reflect-get.js +29 -0
  190. package/dist/src/rules/no-reinterpret-cast.d.ts +2 -0
  191. package/dist/src/rules/no-reinterpret-cast.js +68 -0
  192. package/dist/src/rules/no-runtime-typeof.d.ts +2 -0
  193. package/dist/src/rules/no-runtime-typeof.js +54 -0
  194. package/dist/src/rules/no-sentinel-comparison-union.d.ts +2 -0
  195. package/dist/src/rules/no-sentinel-comparison-union.js +139 -0
  196. package/dist/src/rules/no-shape-in-symbol-names.d.ts +2 -0
  197. package/dist/src/rules/no-shape-in-symbol-names.js +39 -0
  198. package/dist/src/rules/no-single-use-private-functions.d.ts +17 -0
  199. package/dist/src/rules/no-single-use-private-functions.js +419 -0
  200. package/dist/src/rules/no-sql-string-interpolation.d.ts +7 -0
  201. package/dist/src/rules/no-sql-string-interpolation.js +62 -0
  202. package/dist/src/rules/no-stacked-jsdoc-blocks.d.ts +2 -0
  203. package/dist/src/rules/no-stacked-jsdoc-blocks.js +50 -0
  204. package/dist/src/rules/no-stray-inline-comments.d.ts +2 -0
  205. package/dist/src/rules/no-stray-inline-comments.js +74 -0
  206. package/dist/src/rules/no-swappable-primitive-params.d.ts +2 -0
  207. package/dist/src/rules/no-swappable-primitive-params.js +96 -0
  208. package/dist/src/rules/no-tag-ladder-assertions.d.ts +6 -0
  209. package/dist/src/rules/no-tag-ladder-assertions.js +63 -0
  210. package/dist/src/rules/no-transposed-field-reads.d.ts +8 -0
  211. package/dist/src/rules/no-transposed-field-reads.js +101 -0
  212. package/dist/src/rules/no-unit-return-validators.d.ts +2 -0
  213. package/dist/src/rules/no-unit-return-validators.js +64 -0
  214. package/dist/src/rules/no-unknown-parameters.d.ts +2 -0
  215. package/dist/src/rules/no-unknown-parameters.js +82 -0
  216. package/dist/src/rules/no-unknown-returns.d.ts +2 -0
  217. package/dist/src/rules/no-unknown-returns.js +86 -0
  218. package/dist/src/rules/no-unknown-type-aliases.d.ts +2 -0
  219. package/dist/src/rules/no-unknown-type-aliases.js +64 -0
  220. package/dist/src/rules/no-unsafe-dictionary-type.d.ts +2 -0
  221. package/dist/src/rules/no-unsafe-dictionary-type.js +116 -0
  222. package/dist/src/rules/no-vague-test-filenames.d.ts +2 -0
  223. package/dist/src/rules/no-vague-test-filenames.js +61 -0
  224. package/dist/src/rules/no-widen-then-assert.d.ts +2 -0
  225. package/dist/src/rules/no-widen-then-assert.js +268 -0
  226. package/dist/src/rules/prefer-payload-brand.d.ts +2 -0
  227. package/dist/src/rules/prefer-payload-brand.js +57 -0
  228. package/dist/src/rules/prefer-property-tests.d.ts +5 -0
  229. package/dist/src/rules/prefer-property-tests.js +39 -0
  230. package/dist/src/rules/require-canonical-stringify-for-identity.d.ts +8 -0
  231. package/dist/src/rules/require-canonical-stringify-for-identity.js +72 -0
  232. package/dist/src/rules/require-deprecated-tag-for-legacy-comments.d.ts +2 -0
  233. package/dist/src/rules/require-deprecated-tag-for-legacy-comments.js +34 -0
  234. package/dist/src/rules/require-exhaustive-tag-switch.d.ts +7 -0
  235. package/dist/src/rules/require-exhaustive-tag-switch.js +34 -0
  236. package/dist/src/rules/require-fc-block-predicate.d.ts +2 -0
  237. package/dist/src/rules/require-fc-block-predicate.js +37 -0
  238. package/dist/src/rules/require-jsdoc-on-exported.d.ts +2 -0
  239. package/dist/src/rules/require-jsdoc-on-exported.js +66 -0
  240. package/dist/src/rules/require-published-order.d.ts +2 -0
  241. package/dist/src/rules/require-published-order.js +102 -0
  242. package/dist/src/rules/require-safety-comment-for-type-assertion.d.ts +2 -0
  243. package/dist/src/rules/require-safety-comment-for-type-assertion.js +53 -0
  244. package/dist/src/rules/require-sort-comparator.d.ts +7 -0
  245. package/dist/src/rules/require-sort-comparator.js +34 -0
  246. package/dist/src/rules/test-utils.d.ts +35 -0
  247. package/dist/src/rules/test-utils.js +53 -0
  248. package/dist/src/shared/ancestors.d.ts +18 -0
  249. package/dist/src/shared/ancestors.js +19 -0
  250. package/dist/src/shared/child-nodes.d.ts +12 -0
  251. package/dist/src/shared/child-nodes.js +26 -0
  252. package/dist/src/shared/dictionary-types.d.ts +55 -0
  253. package/dist/src/shared/dictionary-types.js +413 -0
  254. package/dist/src/shared/is-node.d.ts +9 -0
  255. package/dist/src/shared/is-node.js +10 -0
  256. package/dist/src/shared/lexical-type-parameters.d.ts +12 -0
  257. package/dist/src/shared/lexical-type-parameters.js +50 -0
  258. package/dist/src/shared/reflect-method.d.ts +15 -0
  259. package/dist/src/shared/reflect-method.js +32 -0
  260. package/dist/src/shared/rule-options.d.ts +18 -0
  261. package/dist/src/shared/rule-options.js +12 -0
  262. package/dist/src/shared/structural.d.ts +54 -0
  263. package/dist/src/shared/structural.js +40 -0
  264. package/dist/src/testing/index.d.ts +2 -0
  265. package/dist/src/testing/index.js +1 -0
  266. package/dist/src/testing/testable-rule.d.ts +39 -0
  267. package/dist/src/testing/testable-rule.js +84 -0
  268. package/dist/src/ui/index.d.ts +12 -0
  269. package/dist/src/ui/index.js +18 -0
  270. package/dist/src/ui/manifest.d.ts +34 -0
  271. package/dist/src/ui/manifest.js +75 -0
  272. package/dist/src/ui/rules/no-deprecated-parts.d.ts +3 -0
  273. package/dist/src/ui/rules/no-deprecated-parts.js +131 -0
  274. package/dist/testing/testable-rule.d.ts +6 -5
  275. package/dist/testing/testable-rule.js +20 -6
  276. package/dist/ui/index.d.ts +12 -0
  277. package/dist/ui/index.js +18 -0
  278. package/dist/ui/manifest.d.ts +49 -0
  279. package/dist/ui/manifest.js +90 -0
  280. package/dist/ui/rules/no-deprecated-parts.d.ts +3 -0
  281. package/dist/ui/rules/no-deprecated-parts.js +172 -0
  282. package/package.json +20 -11
package/README.md CHANGED
@@ -1,11 +1,14 @@
1
1
  # plumb
2
2
 
3
- Opinionated [Oxlint](https://oxc.rs) rules that keep TypeScript *true*: a plumb line for your codebase.
3
+ Opinionated [Oxlint](https://oxc.rs) rules that keep TypeScript *true*: a plumb line for your codebase. The plugins also run under ESLint (see [Using Plumb with ESLint](#using-plumb-with-eslint)).
4
4
 
5
5
  ## Plugins
6
6
 
7
- - **`plumb`**: generic rules that reject low-evidence and low-signal implementation patterns (43 rules).
8
- - **`plumb-effect`**: opt-in rules for Effect service and Layer architecture (16 rules). Enable only in repos that depend on `effect`.
7
+ - **`plumb`**: generic rules that reject low-evidence and low-signal implementation patterns (49 rules).
8
+ - **`plumb-effect`**: opt-in rules for Effect service and Layer architecture (26 rules). Enable only in repos that depend on `effect`.
9
+ - **`plumb-react`**: opt-in React composition rules (4 rules). Enable only in React repos.
10
+ - **`plumb-ui`**: opt-in catalog rules (1 rule). Reads cutlist's generated manifest; `no-deprecated-parts` reports an import of a part whose authored intent marks it `deprecated`, naming the recorded replacement. Fails open when the manifest is missing or malformed; `cutlist build --check` is the gate that keeps it current.
11
+ - **`plumb/configs`**: shared rule sets (`plumbRecommendedRules`, `plumbEffectRecommendedRules`, `plumbReactRecommendedRules`) that enable every rule in a plugin at `error`, for either linter.
9
12
  - **`plumb/testing`**: RuleTester lifecycle adapter (`testableRule`, `wireRuleTester`, `createTester`) so `createOnce` rules with `before`/`after` hooks test correctly under the ESLint-compatible `create` path.
10
13
 
11
14
  ## Consuming
@@ -32,16 +35,86 @@ rules: {
32
35
  },
33
36
  ```
34
37
 
35
- If your setup does not resolve package exports for plugin specifiers, point directly at the source files instead:
38
+ If your setup does not resolve package exports for plugin specifiers, point directly at the compiled files instead (the package ships `dist/` only):
36
39
 
37
40
  ```ts
38
41
  jsPlugins: [
39
- { name: "plumb", specifier: "./node_modules/@autotelic/plumb/src/index.ts" },
40
- { name: "plumb-effect", specifier: "./node_modules/@autotelic/plumb/src/effect/index.ts" },
42
+ { name: "plumb", specifier: "./node_modules/@autotelic/plumb/dist/index.js" },
43
+ { name: "plumb-effect", specifier: "./node_modules/@autotelic/plumb/dist/effect/index.js" },
41
44
  ],
42
45
  ignorePatterns: ["node_modules/**"],
43
46
  ```
44
47
 
48
+ ### 3. Or enable whole plugins with the shared rule sets
49
+
50
+ Each rule set enables every rule in its plugin at `error`, and grows automatically when a release adds rules. Spread it into `rules`, then override individual rules after it. This needs a JS/TS config (`oxlint.config.ts`), since `.oxlintrc.json` can't import modules.
51
+
52
+ ```ts
53
+ // oxlint.config.ts
54
+ import { defineConfig } from "oxlint";
55
+ import { plumbRecommendedRules, plumbEffectRecommendedRules } from "@autotelic/plumb/configs";
56
+
57
+ export default defineConfig({
58
+ jsPlugins: [
59
+ { name: "plumb", specifier: "@autotelic/plumb" },
60
+ { name: "plumb-effect", specifier: "@autotelic/plumb/effect" },
61
+ ],
62
+ rules: {
63
+ ...plumbRecommendedRules,
64
+ ...plumbEffectRecommendedRules,
65
+ "plumb/require-jsdoc-on-exported": "off",
66
+ },
67
+ });
68
+ ```
69
+
70
+ The rule ids assume each plugin is registered under its own name: `plumb`, `plumb-effect`, `plumb-react`.
71
+
72
+ ### 4. Catalog rules (`plumb-ui`)
73
+
74
+ `plumb-ui` is separate from the recommended sets because it needs a generated manifest. Point it at the file `cutlist build` writes:
75
+
76
+ ```ts
77
+ // oxlint.config.ts
78
+ jsPlugins: [{ name: "plumb-ui", specifier: "@autotelic/plumb/ui" }],
79
+ rules: {
80
+ "plumb-ui/no-deprecated-parts": [
81
+ "error",
82
+ { manifest: "tools/ui-catalog/plumb-ui.config.json" },
83
+ ],
84
+ },
85
+ ```
86
+
87
+ The manifest option is a path or an already-decoded manifest object; it defaults to `tools/ui-catalog/plumb-ui.config.json`. A part is a promise: the catalog records `status: deprecated` and `useInstead`, and the rule makes an unmigrated import visible at the call site. If the manifest cannot be read, the rule reports nothing rather than inventing a migration.
88
+
89
+
90
+ ## Using Plumb with ESLint
91
+
92
+ Every plugin is ESLint-compatible, so the same rules run under ESLint with the same findings. Use this where Oxlint can't parse the files: Astro, Vue and Svelte templates. Pair ESLint's framework parser with `@typescript-eslint/parser` for the script parts, and keep Oxlint for plain TypeScript if you want its speed.
93
+
94
+ ```js
95
+ // eslint.config.js
96
+ import astroParser from "astro-eslint-parser";
97
+ import tsParser from "@typescript-eslint/parser";
98
+ import plumb from "@autotelic/plumb";
99
+ import { plumbRecommendedRules } from "@autotelic/plumb/configs";
100
+
101
+ export default [
102
+ {
103
+ files: ["**/*.astro"],
104
+ languageOptions: {
105
+ parser: astroParser,
106
+ parserOptions: { parser: tsParser, extraFileExtensions: [".astro"] },
107
+ },
108
+ plugins: { plumb },
109
+ rules: { ...plumbRecommendedRules },
110
+ },
111
+ ];
112
+ ```
113
+
114
+ Vue (`vue-eslint-parser`) and Svelte (`svelte-eslint-parser`) work the same way: swap the parser and file glob. Register the plugins under the same names as in Oxlint so rule ids, and the shared rule sets, line up across both linters.
115
+
116
+ If you type-check an `eslint.config.ts`, the plugin objects need a cast: Oxlint's `Plugin` type allows `meta.fixable: null`, which ESLint's type doesn't. The runtime objects are what ESLint expects.
117
+
45
118
  ## Updating
46
119
 
47
120
  ```sh
@@ -50,11 +123,11 @@ pnpm up @autotelic/plumb # bump to the latest published version
50
123
 
51
124
  ## Releasing (maintainers)
52
125
 
53
- Releases publish to public npm automatically when a GitHub Release is published; the `Publish` workflow runs `pnpm check`, then publishes with provenance via npm trusted publishing (no stored npm token).
126
+ Releases publish to public npm automatically when a GitHub Release is published; the `Publish` workflow runs `pnpm check` and `pnpm build`, then runs `npm publish` authenticated with the `NPM_PUBLISH_TOKEN` repository secret.
54
127
 
55
128
  1. Update `version` in `package.json` and merge.
56
129
  2. Create a GitHub Release for `vX.Y.Z`.
57
- 3. The workflow publishes to npmjs; verify on the release page.
130
+ 3. The workflow publishes to npmjs; verify the package version on npm.
58
131
 
59
132
  ## Development
60
133
 
@@ -0,0 +1,36 @@
1
+ import type { Plugin } from "@oxlint/plugins";
2
+ /** The parts of a plugin a shared rule set is derived from. */
3
+ type RuleSetSource = Pick<Plugin, "meta" | "rules">;
4
+ /** Every rule a plugin ships, enabled at `error` under the plugin's own name.
5
+ *
6
+ * The keys assume the plugin is registered under `meta.name` (`plumb`,
7
+ * `plumb-effect`, `plumb-react`), in `jsPlugins` for Oxlint or `plugins` for
8
+ * ESLint. The result drops straight into either linter's `rules` object.
9
+ *
10
+ * @param {RuleSetSource} plugin - The plugin whose rules to enable.
11
+ * @returns {Readonly<Record<string, "error">>} Namespaced rule ids mapped to `error`.
12
+ */
13
+ export declare function recommendedRulesFor(plugin: RuleSetSource): Readonly<Record<string, "error">>;
14
+ /** Every rule a plugin ships, at the severity its own `meta.type` asks for.
15
+ *
16
+ * A `problem` is an error; a `suggestion` (or any other type) is a warning. Same
17
+ * namespacing as {@link recommendedRulesFor}, so the two are interchangeable in a
18
+ * config that wants the split rather than a flat `error`.
19
+ *
20
+ * @param {RuleSetSource} plugin - The plugin whose rules to enable.
21
+ * @returns {Readonly<Record<string, "error" | "warn">>} Namespaced rule ids mapped to severity.
22
+ */
23
+ export declare function rulesByMetaTypeFor(plugin: RuleSetSource): Readonly<Record<string, "error" | "warn">>;
24
+ /** Every `plumb` rule at `error`. */
25
+ export declare const plumbRecommendedRules: Readonly<Record<string, "error">>;
26
+ /** Every `plumb-effect` rule at `error`; enable only in repos that depend on `effect`. */
27
+ export declare const plumbEffectRecommendedRules: Readonly<Record<string, "error">>;
28
+ /** Every `plumb-react` rule at `error`; enable only in React repos. */
29
+ export declare const plumbReactRecommendedRules: Readonly<Record<string, "error">>;
30
+ /** Every `plumb` rule at the severity its own metadata asks for. */
31
+ export declare const plumbRulesByMetaType: Readonly<Record<string, "error" | "warn">>;
32
+ /** Every `plumb-effect` rule at the severity its own metadata asks for. */
33
+ export declare const plumbEffectRulesByMetaType: Readonly<Record<string, "error" | "warn">>;
34
+ /** Every `plumb-react` rule at the severity its own metadata asks for. */
35
+ export declare const plumbReactRulesByMetaType: Readonly<Record<string, "error" | "warn">>;
36
+ export {};
@@ -0,0 +1,57 @@
1
+ import plumbPlugin from "../index.js";
2
+ import plumbEffectPlugin from "../effect/index.js";
3
+ import plumbReactPlugin from "../react/index.js";
4
+ /** Every rule a plugin ships, enabled at `error` under the plugin's own name.
5
+ *
6
+ * The keys assume the plugin is registered under `meta.name` (`plumb`,
7
+ * `plumb-effect`, `plumb-react`), in `jsPlugins` for Oxlint or `plugins` for
8
+ * ESLint. The result drops straight into either linter's `rules` object.
9
+ *
10
+ * @param {RuleSetSource} plugin - The plugin whose rules to enable.
11
+ * @returns {Readonly<Record<string, "error">>} Namespaced rule ids mapped to `error`.
12
+ */
13
+ export function recommendedRulesFor(plugin) {
14
+ const name = plugin.meta?.name ?? "";
15
+ return Object.fromEntries(Object.keys(plugin.rules).map((rule) => [`${name}/${rule}`, "error"]));
16
+ }
17
+ /** The severity a rule's own metadata asks for: a `problem` is an error, anything else a warning.
18
+ *
19
+ * This mirrors how Oxlint's own categories and the Effect language service's presets
20
+ * split their rulebooks, so a rule that merely suggests a shape does not fail a build
21
+ * the way a rule that catches a defect does.
22
+ *
23
+ * @param {unknown} rule - A rule definition from a plugin's `rules` record.
24
+ * @returns {"error" | "warn"} The severity for that rule.
25
+ */
26
+ function severityOfMetaType(rule) {
27
+ const type = rule.meta?.type;
28
+ return type === "problem" ? "error" : "warn";
29
+ }
30
+ /** Every rule a plugin ships, at the severity its own `meta.type` asks for.
31
+ *
32
+ * A `problem` is an error; a `suggestion` (or any other type) is a warning. Same
33
+ * namespacing as {@link recommendedRulesFor}, so the two are interchangeable in a
34
+ * config that wants the split rather than a flat `error`.
35
+ *
36
+ * @param {RuleSetSource} plugin - The plugin whose rules to enable.
37
+ * @returns {Readonly<Record<string, "error" | "warn">>} Namespaced rule ids mapped to severity.
38
+ */
39
+ export function rulesByMetaTypeFor(plugin) {
40
+ const name = plugin.meta?.name ?? "";
41
+ return Object.fromEntries(Object.entries(plugin.rules).map(([rule, definition]) => [
42
+ `${name}/${rule}`,
43
+ severityOfMetaType(definition),
44
+ ]));
45
+ }
46
+ /** Every `plumb` rule at `error`. */
47
+ export const plumbRecommendedRules = recommendedRulesFor(plumbPlugin);
48
+ /** Every `plumb-effect` rule at `error`; enable only in repos that depend on `effect`. */
49
+ export const plumbEffectRecommendedRules = recommendedRulesFor(plumbEffectPlugin);
50
+ /** Every `plumb-react` rule at `error`; enable only in React repos. */
51
+ export const plumbReactRecommendedRules = recommendedRulesFor(plumbReactPlugin);
52
+ /** Every `plumb` rule at the severity its own metadata asks for. */
53
+ export const plumbRulesByMetaType = rulesByMetaTypeFor(plumbPlugin);
54
+ /** Every `plumb-effect` rule at the severity its own metadata asks for. */
55
+ export const plumbEffectRulesByMetaType = rulesByMetaTypeFor(plumbEffectPlugin);
56
+ /** Every `plumb-react` rule at the severity its own metadata asks for. */
57
+ export const plumbReactRulesByMetaType = rulesByMetaTypeFor(plumbReactPlugin);
@@ -23,6 +23,8 @@ import { preferEffectMatchRule } from "./rules/prefer-effect-match.js";
23
23
  import { noNestedLayerProvideRule } from "./rules/no-nested-layer-provide.js";
24
24
  import { noCascadingLayerProvideRule } from "./rules/no-cascading-layer-provide.js";
25
25
  import { noStaticEffectServiceForwardersRule } from "./rules/no-static-effect-service-forwarders.js";
26
+ import { noRawErrorForwardingRule } from "./rules/no-raw-error-forwarding.js";
27
+ import { noNullishDefaultOnPartialInputRule } from "./rules/no-nullish-default-on-partial-input.js";
26
28
  /** Opt-in Oxlint rules for Effect service and Layer architecture. */
27
29
  const plumbEffectPlugin = eslintCompatPlugin({
28
30
  meta: { name: "plumb-effect" },
@@ -51,6 +53,8 @@ const plumbEffectPlugin = eslintCompatPlugin({
51
53
  "no-nested-layer-provide": noNestedLayerProvideRule,
52
54
  "no-cascading-layer-provide": noCascadingLayerProvideRule,
53
55
  "no-static-effect-service-forwarders": noStaticEffectServiceForwardersRule,
56
+ "no-raw-error-forwarding": noRawErrorForwardingRule,
57
+ "no-nullish-default-on-partial-input": noNullishDefaultOnPartialInputRule,
54
58
  },
55
59
  });
56
60
  export default plumbEffectPlugin;
@@ -1,6 +1,6 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { ancestorsOf } from "../../shared/ancestors.js";
3
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
3
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
4
4
  /** Whether the member chain ends in the Option namespace, e.g. `Option` or `O`.
5
5
  *
6
6
  * @param {ESTree.Expression | ESTree.Super} node - The callee object to inspect.
@@ -1,7 +1,7 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { isString } from "../../shared/structural.js";
3
3
  const PROVISION_METHODS = new Set(["provide", "provideMerge"]);
4
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
4
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
5
5
  /** Multiple provision stages in one pipe entangle dependency tiers; combine independent layers or name each stage.
6
6
  *
7
7
  * Import tracking covers local names bound to the `Layer` export of
@@ -1,5 +1,5 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$/u;
2
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
3
3
  /**
4
4
  * decodeUnknownOption collapses every schema mismatch into None, discarding
5
5
  * the issue tree that explains why decoding failed. Prefer adapters that keep
@@ -1,7 +1,7 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { ancestorsOf } from "../../shared/ancestors.js";
3
3
  import { isString } from "../../shared/structural.js";
4
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
4
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
5
5
  const BANNED_STORAGE = new Set(["indexedDB", "localStorage", "sessionStorage"]);
6
6
  /**
7
7
  * The banned-storage global named by an identifier, if any.
@@ -39,8 +39,8 @@ export const noDirectBrowserStorageRule = defineRule({
39
39
  if (name === null)
40
40
  return;
41
41
  const chain = ancestorsOf(context.sourceCode, node);
42
- const parent = chain[0];
43
- const grandparent = chain[1];
42
+ const parent = chain.at(-1);
43
+ const grandparent = chain.at(-2);
44
44
  if (parent === undefined)
45
45
  return;
46
46
  if (parent.type === "MemberExpression") {
@@ -1,5 +1,5 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
2
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
3
3
  /** Bare `fetch` reaches past the application boundary un-injected; require a client service. */
4
4
  export const noDirectFetchRule = defineRule({
5
5
  meta: {
@@ -1,6 +1,6 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { ancestorsOf } from "../../shared/ancestors.js";
3
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
3
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
4
4
  function calleeName(node) {
5
5
  const callee = node.callee;
6
6
  if (callee.type === "MemberExpression" && callee.property.type === "Identifier") {
@@ -1,5 +1,5 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
2
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
3
3
  /**
4
4
  * Whether a call targets `Layer.provide`.
5
5
  *
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Disallow using nullish coalescing (`??`) with a literal default on a
3
+ * member expression of an external input object. In partial updates
4
+ * (PATCH/PUT), a field might be intentionally absent; `?? false` conflates
5
+ * "absent" with "explicitly false", so you can't distinguish "don't change
6
+ * this field" from "set it to false".
7
+ *
8
+ * This pattern re-invent's Effect's Schema: it manually detects absence where
9
+ * `Schema.optional` / `Schema.nullable` would distinguish absent from falsy
10
+ * with full type safety. The schema also centralizes the rule so it can't
11
+ * drift between the API and the UI.
12
+ */
13
+ export declare const noNullishDefaultOnPartialInputRule: import("@oxlint/plugins").Rule;
@@ -0,0 +1,109 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { firstOptionRecord } from "../../shared/rule-options.js";
3
+ import { isString } from "../../shared/structural.js";
4
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
5
+ /** Object names that suggest external input: request bodies, params, etc. */
6
+ const DEFAULT_INPUT_NAMES = new Set([
7
+ "body",
8
+ "params",
9
+ "query",
10
+ "data",
11
+ "input",
12
+ "payload",
13
+ ]);
14
+ /**
15
+ * Whether a node is a literal value (boolean, string, number, null).
16
+ * @param {ESTree.Node} node - The node to test.
17
+ * @returns {boolean} True when the node is a literal.
18
+ */
19
+ function isLiteral(node) {
20
+ return node.type === "Literal";
21
+ }
22
+ /**
23
+ * The display string for a literal value.
24
+ * @param {ESTree.Expression} node - The literal node.
25
+ * @returns {string} The display string.
26
+ */
27
+ function literalDisplay(node) {
28
+ if (node.type === "Literal" && node.value === null)
29
+ return "null";
30
+ if (node.type === "Literal")
31
+ return String(node.value);
32
+ if (node.type === "UnaryExpression" && node.argument.type === "Literal")
33
+ return String(node.argument.value);
34
+ return "unknown";
35
+ }
36
+ /**
37
+ * Disallow using nullish coalescing (`??`) with a literal default on a
38
+ * member expression of an external input object. In partial updates
39
+ * (PATCH/PUT), a field might be intentionally absent; `?? false` conflates
40
+ * "absent" with "explicitly false", so you can't distinguish "don't change
41
+ * this field" from "set it to false".
42
+ *
43
+ * This pattern re-invent's Effect's Schema: it manually detects absence where
44
+ * `Schema.optional` / `Schema.nullable` would distinguish absent from falsy
45
+ * with full type safety. The schema also centralizes the rule so it can't
46
+ * drift between the API and the UI.
47
+ */
48
+ export const noNullishDefaultOnPartialInputRule = defineRule({
49
+ meta: {
50
+ type: "problem",
51
+ docs: {
52
+ description: "Disallow nullish coalescing (??) with literal defaults on member expressions of external input objects; this conflates 'absent' with 'falsy' in partial updates and re-invent's Effect's Schema. Use Schema.optional / Schema.nullable to distinguish absent from falsy.",
53
+ },
54
+ messages: {
55
+ nullishDefaultOnPartialInput: "`?? {{default}}` on `{{object}}.{{property}}` conflates 'absent' with '{{default}}' in partial updates and re-invent's Effect's Schema. Use `Schema.optional` / `Schema.nullable` to distinguish absent from falsy with full type safety.",
56
+ },
57
+ schema: [
58
+ {
59
+ type: "object",
60
+ properties: {
61
+ allow: { type: "array", items: { type: "string" } },
62
+ },
63
+ additionalProperties: false,
64
+ },
65
+ ],
66
+ defaultOptions: [{ allow: [] }],
67
+ },
68
+ createOnce(context) {
69
+ const option = firstOptionRecord(context.options);
70
+ const allowed = new Set(Array.isArray(option.allow) ? option.allow.filter(isString) : []);
71
+ const inputNames = new Set(DEFAULT_INPUT_NAMES);
72
+ for (const name of allowed)
73
+ inputNames.delete(name);
74
+ return {
75
+ before() {
76
+ if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
77
+ return false;
78
+ },
79
+ LogicalExpression(node) {
80
+ if (node.operator !== "??")
81
+ return;
82
+ if (node.left.type !== "MemberExpression")
83
+ return;
84
+ if (!isLiteral(node.right))
85
+ return;
86
+ const member = node.left;
87
+ if (member.object.type !== "Identifier")
88
+ return;
89
+ const objectName = member.object.name;
90
+ if (!inputNames.has(objectName))
91
+ return;
92
+ const propertyName = !member.computed && member.property.type === "Identifier"
93
+ ? member.property.name
94
+ : undefined;
95
+ if (propertyName === undefined)
96
+ return;
97
+ context.report({
98
+ node,
99
+ messageId: "nullishDefaultOnPartialInput",
100
+ data: {
101
+ default: literalDisplay(node.right),
102
+ object: objectName,
103
+ property: propertyName,
104
+ },
105
+ });
106
+ },
107
+ };
108
+ },
109
+ });
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Disallow forwarding raw error messages from caught exceptions. This pattern
3
+ * re-invent's Effect's typed error channel: raw strings leak internal details
4
+ * (stack traces, file paths, database errors) and lose structure so callers
5
+ * can't match on the failure kind.
6
+ *
7
+ * Use Effect's `TaggedError`: a tagged class per failure kind carrying
8
+ * structured evidence as fields, rendering its message from those fields. The
9
+ * error then flows through Effect's typed error channel instead of being
10
+ * stringified at every boundary.
11
+ *
12
+ * The catch-param stack is emptied in `before`: it is balanced by `CatchClause`
13
+ * enter/exit, but a file whose parse bails out never reaches the exit, and an empty
14
+ * stack at file start is the invariant every other per-file rule keeps.
15
+ */
16
+ export declare const noRawErrorForwardingRule: import("@oxlint/plugins").Rule;
@@ -0,0 +1,108 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { ancestorsOf } from "../../shared/ancestors.js";
3
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
4
+ /** Error properties that carry internal details and must not be forwarded raw. */
5
+ const ERROR_PROPS = new Set(["message", "stack"]);
6
+ /**
7
+ * Whether a member expression accesses an error property on a catch parameter.
8
+ * @param {ESTree.MemberExpression} member - The member expression to test.
9
+ * @param {ReadonlySet<string>} catchParams - Names of catch parameters in scope.
10
+ * @returns {boolean} True when the member accesses an error property on a catch param.
11
+ */
12
+ function isErrorPropAccess(member, catchParams) {
13
+ if (member.object.type !== "Identifier")
14
+ return false;
15
+ if (!catchParams.has(member.object.name))
16
+ return false;
17
+ if (member.computed)
18
+ return false;
19
+ return member.property.type === "Identifier" && ERROR_PROPS.has(member.property.name);
20
+ }
21
+ /**
22
+ * Whether the error property access is inside a console.* call (logging, not forwarding).
23
+ * @param {SourceCode} sourceCode - The rule's source-code accessor.
24
+ * @param {ESTree.Node} node - The node to test.
25
+ * @returns {boolean} True when the access is inside a console.* call.
26
+ */
27
+ function isLoggingCall(sourceCode, node) {
28
+ const chain = ancestorsOf(sourceCode, node);
29
+ for (let i = chain.length - 1; i >= 0; i--) {
30
+ const ancestor = chain[i];
31
+ if (ancestor === undefined)
32
+ continue;
33
+ if (ancestor.type === "CallExpression" && ancestor.callee.type === "MemberExpression") {
34
+ const obj = ancestor.callee.object;
35
+ if (obj.type === "Identifier" && obj.name === "console")
36
+ return true;
37
+ }
38
+ if (ancestor.type === "Program" || ancestor.type === "BlockStatement")
39
+ return false;
40
+ }
41
+ return false;
42
+ }
43
+ /**
44
+ * Disallow forwarding raw error messages from caught exceptions. This pattern
45
+ * re-invent's Effect's typed error channel: raw strings leak internal details
46
+ * (stack traces, file paths, database errors) and lose structure so callers
47
+ * can't match on the failure kind.
48
+ *
49
+ * Use Effect's `TaggedError`: a tagged class per failure kind carrying
50
+ * structured evidence as fields, rendering its message from those fields. The
51
+ * error then flows through Effect's typed error channel instead of being
52
+ * stringified at every boundary.
53
+ *
54
+ * The catch-param stack is emptied in `before`: it is balanced by `CatchClause`
55
+ * enter/exit, but a file whose parse bails out never reaches the exit, and an empty
56
+ * stack at file start is the invariant every other per-file rule keeps.
57
+ */
58
+ export const noRawErrorForwardingRule = defineRule({
59
+ meta: {
60
+ type: "problem",
61
+ docs: {
62
+ description: "Disallow forwarding raw error messages (e.message, e.stack) from caught exceptions; this pattern re-invent's Effect's typed error channel. Use Effect's TaggedError so failures carry structured evidence and flow through the typed channel.",
63
+ },
64
+ messages: {
65
+ rawErrorForwarding: "Forwarding the raw error '{{prop}}' re-invent's Effect's typed error channel: it leaks internal details and loses structure so callers can't match on the failure kind. Use Effect's TaggedError (a tagged class per failure kind carrying structured evidence as fields) so the error flows through the typed channel.",
66
+ },
67
+ },
68
+ createOnce(context) {
69
+ const catchParamStack = [];
70
+ return {
71
+ before() {
72
+ catchParamStack.length = 0;
73
+ if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
74
+ return false;
75
+ },
76
+ CatchClause(node) {
77
+ const param = node.param;
78
+ if (param !== null && param !== undefined && param.type === "Identifier") {
79
+ catchParamStack.push(new Set([param.name]));
80
+ }
81
+ else {
82
+ catchParamStack.push(new Set());
83
+ }
84
+ },
85
+ "CatchClause:exit"() {
86
+ catchParamStack.pop();
87
+ },
88
+ MemberExpression(node) {
89
+ if (catchParamStack.length === 0)
90
+ return;
91
+ const allParams = new Set();
92
+ for (const params of catchParamStack) {
93
+ for (const name of params)
94
+ allParams.add(name);
95
+ }
96
+ if (!isErrorPropAccess(node, allParams))
97
+ return;
98
+ if (isLoggingCall(context.sourceCode, node))
99
+ return;
100
+ context.report({
101
+ node,
102
+ messageId: "rawErrorForwarding",
103
+ data: { prop: node.property.type === "Identifier" ? node.property.name : "message" },
104
+ });
105
+ },
106
+ };
107
+ },
108
+ });
@@ -1,5 +1,5 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
2
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
3
3
  const CATCH_METHODS = new Set([
4
4
  "catch",
5
5
  "catchTag",
@@ -1,7 +1,7 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { ancestorsOf } from "../../shared/ancestors.js";
3
3
  import { isString } from "../../shared/structural.js";
4
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
4
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
5
5
  /** Computed or plain property name on a member expression.
6
6
  *
7
7
  * @param {ESTree.MemberExpression} member - The member expression node.
@@ -37,17 +37,18 @@ function localNameOf(specifier) {
37
37
  : undefined;
38
38
  }
39
39
  /** Whether the call site sits inside a `static` class property initializer.
40
+ *
41
+ * Walks from the node outward, since `ancestorsOf` is outermost-first and `Program` would
42
+ * otherwise be the first node seen.
40
43
  *
41
44
  * @param {SourceCode} sourceCode - The rule's source-code accessor.
42
45
  * @param {ESTree.Node} node - The call expression being visited.
43
46
  * @returns {boolean} True when enclosed by a static property definition.
44
47
  */
45
48
  function inStaticClassField(sourceCode, node) {
46
- for (const current of ancestorsOf(sourceCode, node)) {
49
+ for (const current of [...ancestorsOf(sourceCode, node)].reverse()) {
47
50
  if (current.type === "PropertyDefinition")
48
51
  return current.static === true;
49
- if (current.type === "Program")
50
- return false;
51
52
  }
52
53
  return false;
53
54
  }
@@ -1,5 +1,5 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
2
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
3
3
  /** Raw `try`/`catch` detours failures around the typed error channel; route them through `Effect.try` instead. */
4
4
  export const noTryCatchRule = defineRule({
5
5
  meta: {
@@ -1,7 +1,7 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { ancestorsOf } from "../../shared/ancestors.js";
3
3
  import { readField } from "../../shared/structural.js";
4
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
4
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
5
5
  const commentOwnerKinds = new Set([
6
6
  "ExpressionStatement",
7
7
  "ReturnStatement",
@@ -1,5 +1,5 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
2
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
3
3
  /** The exported name declared by this statement, if any.
4
4
  *
5
5
  * @param {ESTree.Node} node - The export or declaration statement.
@@ -1,7 +1,7 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { readField } from "../../shared/structural.js";
3
3
  import { ancestorsOf } from "../../shared/ancestors.js";
4
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
4
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
5
5
  /** Unwrap a tuple element to the type node it contributes to the annotation walk.
6
6
  *
7
7
  * @param {ESTree.TSTupleElement} element - Tuple element node.
@@ -1,6 +1,6 @@
1
1
  import { defineRule } from "@oxlint/plugins";
2
2
  import { ancestorsOf } from "../../shared/ancestors.js";
3
- const TEST_FILE = /.(?:test|spec).[cm]?[jt]sx?$|\/test\//u;
3
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$|\/test\//u;
4
4
  const LADDER_THRESHOLD = 3;
5
5
  /** Whether this call is an Effect combinator chained in the flatMap/map ladder family.
6
6
  *