@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
@@ -0,0 +1,2 @@
1
+ export { createTester, testableRule, wireRuleTester } from "./testable-rule.ts";
2
+ export type { TestRunner } from "./testable-rule.ts";
@@ -0,0 +1 @@
1
+ export { createTester, testableRule, wireRuleTester } from "./testable-rule.js";
@@ -0,0 +1,39 @@
1
+ import { RuleTester } from "oxlint/plugins-dev";
2
+ import type { Rule } from "@oxlint/plugins";
3
+ /**
4
+ * Structural surface of a test runner, satisfied by vitest's `describe`/`it`/
5
+ * `it.only` (and by jest/mocha equivalents).
6
+ */
7
+ export interface TestRunner {
8
+ describe: (name: string, fn: () => void) => void;
9
+ it: (name: string, fn: () => void) => void;
10
+ itOnly?: (name: string, fn: () => void) => void;
11
+ }
12
+ /** Bind a test runner's hooks to RuleTester's statics.
13
+ *
14
+ * Call once at module scope of a test file (or setup file) before running suites.
15
+ *
16
+ * @param {TestRunner} runner - The ambient runner's hooks.
17
+ */
18
+ export declare function wireRuleTester(runner: TestRunner): void;
19
+ /** A tester instance bound to the wired runner.
20
+ *
21
+ * @returns {RuleTester} A fresh RuleTester.
22
+ */
23
+ export declare function createTester(): RuleTester;
24
+ /**
25
+ * Adapt a `createOnce` rule for Oxlint's RuleTester.
26
+ *
27
+ * RuleTester drives rules through their ESLint-compatible `create` method and
28
+ * does not understand `before`/`after` lifecycle hooks. Like native Oxlint, the
29
+ * adapter invokes `createOnce` once and reuses its visitors for every linted
30
+ * file, so state a rule forgets to reset in `before` leaks between test cases
31
+ * exactly as it would leak between files in a real run. It also honours the
32
+ * skip contract (`before` returning `false` skips the file), and chains the
33
+ * rule's own `Program:exit` visitor with the after hook instead of clobbering it.
34
+ *
35
+ * @param {CreateOnceRule | Rule} rule - The createOnce-style rule to adapt. A
36
+ * rule already in ESLint-style passes through untouched.
37
+ * @returns {Rule} An ESLint-compatible rule with an identical per-file lifecycle.
38
+ */
39
+ export declare function testableRule(rule: Rule): Rule;
@@ -0,0 +1,84 @@
1
+ import { RuleTester } from "oxlint/plugins-dev";
2
+ /** Narrow to the createOnce surface the tester adapts.
3
+ *
4
+ * @param {Rule} rule - The rule to test.
5
+ * @returns {boolean} True when the rule carries a createOnce factory.
6
+ */
7
+ function isCreateOnceRule(rule) {
8
+ return "createOnce" in rule;
9
+ }
10
+ /** Bind a test runner's hooks to RuleTester's statics.
11
+ *
12
+ * Call once at module scope of a test file (or setup file) before running suites.
13
+ *
14
+ * @param {TestRunner} runner - The ambient runner's hooks.
15
+ */
16
+ export function wireRuleTester(runner) {
17
+ RuleTester.describe = runner.describe;
18
+ RuleTester.it = runner.it;
19
+ if (runner.itOnly !== undefined) {
20
+ RuleTester.itOnly = runner.itOnly;
21
+ }
22
+ }
23
+ /** A tester instance bound to the wired runner.
24
+ *
25
+ * @returns {RuleTester} A fresh RuleTester.
26
+ */
27
+ export function createTester() {
28
+ return new RuleTester();
29
+ }
30
+ /**
31
+ * Adapt a `createOnce` rule for Oxlint's RuleTester.
32
+ *
33
+ * RuleTester drives rules through their ESLint-compatible `create` method and
34
+ * does not understand `before`/`after` lifecycle hooks. Like native Oxlint, the
35
+ * adapter invokes `createOnce` once and reuses its visitors for every linted
36
+ * file, so state a rule forgets to reset in `before` leaks between test cases
37
+ * exactly as it would leak between files in a real run. It also honours the
38
+ * skip contract (`before` returning `false` skips the file), and chains the
39
+ * rule's own `Program:exit` visitor with the after hook instead of clobbering it.
40
+ *
41
+ * @param {CreateOnceRule | Rule} rule - The createOnce-style rule to adapt. A
42
+ * rule already in ESLint-style passes through untouched.
43
+ * @returns {Rule} An ESLint-compatible rule with an identical per-file lifecycle.
44
+ */
45
+ export function testableRule(rule) {
46
+ if (!isCreateOnceRule(rule))
47
+ return rule;
48
+ let currentContext;
49
+ const sharedContext = new Proxy({}, {
50
+ get(_target, key) {
51
+ // SAFETY: the proxy stands in for the per-file context, so every key
52
+ // read is a key of that context.
53
+ const value = currentContext[key];
54
+ return value instanceof Function ? value.bind(currentContext) : value;
55
+ },
56
+ });
57
+ let hooks;
58
+ const adapter = {
59
+ meta: rule.meta,
60
+ create(context) {
61
+ currentContext = context;
62
+ // SAFETY: the proxy forwards every read to the current file's context.
63
+ hooks ??= rule.createOnce(sharedContext);
64
+ const { after, before, ...visitor } = hooks;
65
+ // SAFETY: visitor fragments come from this plugin's own createOnce
66
+ // contract; method keys map one-to-one onto the tester's call shape.
67
+ const visitors = visitor;
68
+ const skip = before !== undefined && before() === false;
69
+ if (skip)
70
+ return {};
71
+ const previousExit = visitors["Program:exit"];
72
+ return {
73
+ ...visitors,
74
+ "Program:exit"(...callArguments) {
75
+ previousExit?.(...callArguments);
76
+ after?.();
77
+ },
78
+ };
79
+ },
80
+ };
81
+ // SAFETY: the adapter reproduces Rule's meta/create surface; its visitors
82
+ // are the createOnce fragments the tester already consumes.
83
+ return adapter;
84
+ }
@@ -0,0 +1,12 @@
1
+ import { noDeprecatedPartsRule } from "./rules/no-deprecated-parts.ts";
2
+ /**
3
+ * Rules that read the catalog's lint manifest.
4
+ *
5
+ * These are separate from `plumb-react` because they need a second input — the generated
6
+ * manifest — and a repository without a catalog should not enable them. A rule here is a
7
+ * lookup, never a second analysis: cutlist already decided which part is deprecated and
8
+ * what replaces it.
9
+ */
10
+ declare const plumbUiPlugin: import("@oxlint/plugins").Plugin;
11
+ export default plumbUiPlugin;
12
+ export { noDeprecatedPartsRule };
@@ -0,0 +1,18 @@
1
+ import { eslintCompatPlugin } from "@oxlint/plugins";
2
+ import { noDeprecatedPartsRule } from "./rules/no-deprecated-parts.js";
3
+ /**
4
+ * Rules that read the catalog's lint manifest.
5
+ *
6
+ * These are separate from `plumb-react` because they need a second input — the generated
7
+ * manifest — and a repository without a catalog should not enable them. A rule here is a
8
+ * lookup, never a second analysis: cutlist already decided which part is deprecated and
9
+ * what replaces it.
10
+ */
11
+ const plumbUiPlugin = eslintCompatPlugin({
12
+ meta: { name: "plumb-ui" },
13
+ rules: {
14
+ "no-deprecated-parts": noDeprecatedPartsRule,
15
+ },
16
+ });
17
+ export default plumbUiPlugin;
18
+ export { noDeprecatedPartsRule };
@@ -0,0 +1,34 @@
1
+ /** Where a part is in its life. */
2
+ export type UiPartStatus = "stable" | "beta" | "experimental" | "deprecated";
3
+ /** The subset of a manifest component the deprecation rule reads. */
4
+ export interface UiPart {
5
+ readonly path: string;
6
+ readonly name: string;
7
+ readonly exports?: ReadonlyArray<string>;
8
+ readonly status?: UiPartStatus;
9
+ readonly useInstead?: ReadonlyArray<string>;
10
+ }
11
+ /** A manifest, reduced to the parts the rule can act on. */
12
+ export interface UiManifest {
13
+ readonly components: ReadonlyArray<UiPart>;
14
+ }
15
+ /**
16
+ * Read one component, or `undefined` when it cannot be identified.
17
+ *
18
+ * `tier`, `owners`, `props` and `tags` are required by the manifest schema but not by
19
+ * this rule. Requiring them here would make a hand-written fixture verbose for no gain,
20
+ * and the rule's question is only "who is deprecated, and what replaces it".
21
+ */
22
+ export declare function decodeUiPart(value: unknown): UiPart | undefined;
23
+ /** Read a manifest, or `undefined` when it is not one. */
24
+ export declare function decodeUiManifest(value: unknown): UiManifest | undefined;
25
+ /**
26
+ * Read a manifest from disk, degrading to `undefined`.
27
+ *
28
+ * A missing or malformed manifest is not a lint error: the rule goes quiet, exactly as
29
+ * every other manifest reader in this workspace does. `cutlist build --check` is the
30
+ * gate that makes a stale manifest loud.
31
+ */
32
+ export declare function readUiManifest(path: string): UiManifest | undefined;
33
+ /** Resolve a configured path against the process working directory. */
34
+ export declare function manifestAt(path: string): UiManifest | undefined;
@@ -0,0 +1,75 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ const STATUSES = ["stable", "beta", "experimental", "deprecated"];
4
+ function isRecord(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6
+ }
7
+ function str(value) {
8
+ return typeof value === "string" ? value : undefined;
9
+ }
10
+ function strings(value) {
11
+ if (!Array.isArray(value))
12
+ return undefined;
13
+ if (!value.every((entry) => typeof entry === "string"))
14
+ return undefined;
15
+ return value;
16
+ }
17
+ function status(value) {
18
+ return STATUSES.find((entry) => entry === value);
19
+ }
20
+ /**
21
+ * Read one component, or `undefined` when it cannot be identified.
22
+ *
23
+ * `tier`, `owners`, `props` and `tags` are required by the manifest schema but not by
24
+ * this rule. Requiring them here would make a hand-written fixture verbose for no gain,
25
+ * and the rule's question is only "who is deprecated, and what replaces it".
26
+ */
27
+ export function decodeUiPart(value) {
28
+ if (!isRecord(value))
29
+ return undefined;
30
+ const path = str(value.path);
31
+ const name = str(value.name);
32
+ if (path === undefined || name === undefined)
33
+ return undefined;
34
+ const exports = strings(value.exports);
35
+ const partStatus = status(value.status);
36
+ const useInstead = strings(value.useInstead);
37
+ return {
38
+ path,
39
+ name,
40
+ ...(exports === undefined ? {} : { exports }),
41
+ ...(partStatus === undefined ? {} : { status: partStatus }),
42
+ ...(useInstead === undefined ? {} : { useInstead }),
43
+ };
44
+ }
45
+ /** Read a manifest, or `undefined` when it is not one. */
46
+ export function decodeUiManifest(value) {
47
+ if (!isRecord(value) || !Array.isArray(value.components))
48
+ return undefined;
49
+ const components = [];
50
+ for (const entry of value.components) {
51
+ const part = decodeUiPart(entry);
52
+ if (part !== undefined)
53
+ components.push(part);
54
+ }
55
+ return { components };
56
+ }
57
+ /**
58
+ * Read a manifest from disk, degrading to `undefined`.
59
+ *
60
+ * A missing or malformed manifest is not a lint error: the rule goes quiet, exactly as
61
+ * every other manifest reader in this workspace does. `cutlist build --check` is the
62
+ * gate that makes a stale manifest loud.
63
+ */
64
+ export function readUiManifest(path) {
65
+ try {
66
+ return decodeUiManifest(JSON.parse(readFileSync(path, "utf8")));
67
+ }
68
+ catch {
69
+ return undefined;
70
+ }
71
+ }
72
+ /** Resolve a configured path against the process working directory. */
73
+ export function manifestAt(path) {
74
+ return readUiManifest(resolve(process.cwd(), path));
75
+ }
@@ -0,0 +1,3 @@
1
+ declare const RULE_ID = "plumb-ui/no-deprecated-parts";
2
+ export declare const noDeprecatedPartsRule: import("@oxlint/plugins").Rule;
3
+ export { RULE_ID };
@@ -0,0 +1,131 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { firstOptionRecord } from "../../shared/rule-options.js";
3
+ import { decodeUiManifest, manifestAt, } from "../manifest.js";
4
+ /*
5
+ * A deprecated part is a promise, and an import is the place the promise is checked.
6
+ *
7
+ * Cutlist records `status: deprecated` and `useInstead` in the manifest; this rule reads
8
+ * that record and reports the call sites that have not migrated. It is the lint-shaped
9
+ * half of the same idea as a design system's "preferred instance": the catalog says what
10
+ * replaced the old thing, and the rule makes the old path visible instead of merely
11
+ * documented.
12
+ *
13
+ * The rule fails open. A missing or malformed manifest means no findings, because a lint
14
+ * rule that invents a migration from a file it could not read is worse than one that is
15
+ * briefly quiet; `cutlist build --check` is the gate that makes the manifest current.
16
+ */
17
+ const RULE_ID = "plumb-ui/no-deprecated-parts";
18
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
19
+ const CACHE = new Map();
20
+ function isRecord(value) {
21
+ return typeof value === "object" && value !== null && !Array.isArray(value);
22
+ }
23
+ function manifestFrom(value) {
24
+ // An inline manifest is what a rule test uses; a path is what a config uses. Both
25
+ // decode through the same reader, so a test cannot pass a shape the real rule rejects.
26
+ if (isRecord(value) && Array.isArray(value.components))
27
+ return decodeUiManifest(value);
28
+ if (typeof value !== "string")
29
+ return undefined;
30
+ if (!CACHE.has(value))
31
+ CACHE.set(value, manifestAt(value));
32
+ return CACHE.get(value);
33
+ }
34
+ /** A module path without its source extension or trailing `/index`. */
35
+ function moduleOf(path) {
36
+ return path.replace(/\.(?:tsx?|jsx?)$/u, "").replace(/\/index$/u, "");
37
+ }
38
+ /**
39
+ * Whether an import specifier names a manifest part.
40
+ *
41
+ * The specifier is resolved by suffix rather than by the repository's alias table: the
42
+ * rule has no tsconfig reader, and every alias in use (`@/`, `~/`, relative) leaves the
43
+ * tail of the path intact. A named import must also match an exported name when the
44
+ * manifest carries one; a default or namespace import matches by path alone.
45
+ */
46
+ function namesPart(source, imported, part) {
47
+ const clean = source.replace(/^[.@~]+/u, "").replace(/^\/+/u, "").replace(/\.(?:tsx?|jsx?)$/u, "");
48
+ const target = moduleOf(part.path);
49
+ const pathMatches = target === clean || target.endsWith("/" + clean);
50
+ if (imported === "default" || imported === "*")
51
+ return pathMatches;
52
+ return pathMatches || (part.exports?.includes(imported) ?? false);
53
+ }
54
+ /** The imported binding name, or `*` for a namespace import. */
55
+ function importedOf(specifier) {
56
+ if (specifier.type === "ImportSpecifier") {
57
+ return specifier.imported.type === "Identifier"
58
+ ? specifier.imported.name
59
+ : String(specifier.imported.value);
60
+ }
61
+ if (specifier.type === "ImportDefaultSpecifier")
62
+ return "default";
63
+ return "*";
64
+ }
65
+ function localOf(specifier) {
66
+ return specifier.local.name;
67
+ }
68
+ function deprecatedPartFor(manifest, source, imported) {
69
+ return manifest.components.find((part) => part.status === "deprecated" && namesPart(source, imported, part));
70
+ }
71
+ export const noDeprecatedPartsRule = defineRule({
72
+ meta: {
73
+ type: "problem",
74
+ docs: {
75
+ description: "Imports from a part whose catalog entry is deprecated must move to its recorded replacement.",
76
+ },
77
+ messages: {
78
+ deprecatedImport: "`{{name}}` comes from the deprecated part `{{part}}`; use {{useInstead}} instead.",
79
+ deprecatedWithoutTarget: "`{{name}}` comes from the deprecated part `{{part}}`, which records no replacement.",
80
+ },
81
+ schema: [
82
+ {
83
+ type: "object",
84
+ properties: {
85
+ manifest: {
86
+ anyOf: [{ type: "string" }, { type: "object" }],
87
+ },
88
+ },
89
+ additionalProperties: false,
90
+ },
91
+ ],
92
+ defaultOptions: [{ manifest: "tools/ui-catalog/plumb-ui.config.json" }],
93
+ },
94
+ createOnce(context) {
95
+ const option = firstOptionRecord(context.options);
96
+ const manifest = manifestFrom(option.manifest);
97
+ if (manifest === undefined)
98
+ return {};
99
+ const deprecated = manifest.components.filter((part) => part.status === "deprecated");
100
+ if (deprecated.length === 0)
101
+ return {};
102
+ return {
103
+ before() {
104
+ if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
105
+ return false;
106
+ },
107
+ ImportDeclaration(node) {
108
+ const source = node.source.value;
109
+ if (typeof source !== "string")
110
+ return;
111
+ for (const specifier of node.specifiers) {
112
+ const imported = importedOf(specifier);
113
+ const part = deprecatedPartFor(manifest, source, imported);
114
+ if (part === undefined)
115
+ continue;
116
+ const useInstead = part.useInstead ?? [];
117
+ context.report({
118
+ node: specifier,
119
+ messageId: useInstead.length === 0 ? "deprecatedWithoutTarget" : "deprecatedImport",
120
+ data: {
121
+ name: localOf(specifier),
122
+ part: part.name,
123
+ useInstead: useInstead.map((name) => `\`${name}\``).join(" or "),
124
+ },
125
+ });
126
+ }
127
+ },
128
+ };
129
+ },
130
+ });
131
+ export { RULE_ID };
@@ -25,11 +25,12 @@ export declare function createTester(): RuleTester;
25
25
  * Adapt a `createOnce` rule for Oxlint's RuleTester.
26
26
  *
27
27
  * RuleTester drives rules through their ESLint-compatible `create` method and
28
- * does not understand `before`/`after` lifecycle hooks. The adapter invokes
29
- * `createOnce` once per linted file (fresh state per file, exactly like native
30
- * Oxlint), honours the skip contract (`before` returning `false` skips the
31
- * file), and chains the rule's own `Program:exit` visitor with the after hook
32
- * instead of clobbering it.
28
+ * does not understand `before`/`after` lifecycle hooks. Like native Oxlint, the
29
+ * adapter invokes `createOnce` once and reuses its visitors for every linted
30
+ * file, so state a rule forgets to reset in `before` leaks between test cases
31
+ * exactly as it would leak between files in a real run. It also honours the
32
+ * skip contract (`before` returning `false` skips the file), and chains the
33
+ * rule's own `Program:exit` visitor with the after hook instead of clobbering it.
33
34
  *
34
35
  * @param {CreateOnceRule | Rule} rule - The createOnce-style rule to adapt. A
35
36
  * rule already in ESLint-style passes through untouched.
@@ -31,11 +31,12 @@ export function createTester() {
31
31
  * Adapt a `createOnce` rule for Oxlint's RuleTester.
32
32
  *
33
33
  * RuleTester drives rules through their ESLint-compatible `create` method and
34
- * does not understand `before`/`after` lifecycle hooks. The adapter invokes
35
- * `createOnce` once per linted file (fresh state per file, exactly like native
36
- * Oxlint), honours the skip contract (`before` returning `false` skips the
37
- * file), and chains the rule's own `Program:exit` visitor with the after hook
38
- * instead of clobbering it.
34
+ * does not understand `before`/`after` lifecycle hooks. Like native Oxlint, the
35
+ * adapter invokes `createOnce` once and reuses its visitors for every linted
36
+ * file, so state a rule forgets to reset in `before` leaks between test cases
37
+ * exactly as it would leak between files in a real run. It also honours the
38
+ * skip contract (`before` returning `false` skips the file), and chains the
39
+ * rule's own `Program:exit` visitor with the after hook instead of clobbering it.
39
40
  *
40
41
  * @param {CreateOnceRule | Rule} rule - The createOnce-style rule to adapt. A
41
42
  * rule already in ESLint-style passes through untouched.
@@ -44,10 +45,23 @@ export function createTester() {
44
45
  export function testableRule(rule) {
45
46
  if (!isCreateOnceRule(rule))
46
47
  return rule;
48
+ let currentContext;
49
+ const sharedContext = new Proxy({}, {
50
+ get(_target, key) {
51
+ // SAFETY: the proxy stands in for the per-file context, so every key
52
+ // read is a key of that context.
53
+ const value = currentContext[key];
54
+ return value instanceof Function ? value.bind(currentContext) : value;
55
+ },
56
+ });
57
+ let hooks;
47
58
  const adapter = {
48
59
  meta: rule.meta,
49
60
  create(context) {
50
- const { after, before, ...visitor } = rule.createOnce(context);
61
+ currentContext = context;
62
+ // SAFETY: the proxy forwards every read to the current file's context.
63
+ hooks ??= rule.createOnce(sharedContext);
64
+ const { after, before, ...visitor } = hooks;
51
65
  // SAFETY: visitor fragments come from this plugin's own createOnce
52
66
  // contract; method keys map one-to-one onto the tester's call shape.
53
67
  const visitors = visitor;
@@ -0,0 +1,12 @@
1
+ import { noDeprecatedPartsRule } from "./rules/no-deprecated-parts.ts";
2
+ /**
3
+ * Rules that read the catalog's lint manifest.
4
+ *
5
+ * These are separate from `plumb-react` because they need a second input — the generated
6
+ * manifest — and a repository without a catalog should not enable them. A rule here is a
7
+ * lookup, never a second analysis: cutlist already decided which part is deprecated and
8
+ * what replaces it.
9
+ */
10
+ declare const plumbUiPlugin: import("@oxlint/plugins").Plugin;
11
+ export default plumbUiPlugin;
12
+ export { noDeprecatedPartsRule };
@@ -0,0 +1,18 @@
1
+ import { eslintCompatPlugin } from "@oxlint/plugins";
2
+ import { noDeprecatedPartsRule } from "./rules/no-deprecated-parts.js";
3
+ /**
4
+ * Rules that read the catalog's lint manifest.
5
+ *
6
+ * These are separate from `plumb-react` because they need a second input — the generated
7
+ * manifest — and a repository without a catalog should not enable them. A rule here is a
8
+ * lookup, never a second analysis: cutlist already decided which part is deprecated and
9
+ * what replaces it.
10
+ */
11
+ const plumbUiPlugin = eslintCompatPlugin({
12
+ meta: { name: "plumb-ui" },
13
+ rules: {
14
+ "no-deprecated-parts": noDeprecatedPartsRule,
15
+ },
16
+ });
17
+ export default plumbUiPlugin;
18
+ export { noDeprecatedPartsRule };
@@ -0,0 +1,49 @@
1
+ /** Where a part is in its life. */
2
+ export type UiPartStatus = "stable" | "beta" | "experimental" | "deprecated";
3
+ /** The subset of a manifest component the deprecation rule reads. */
4
+ export interface UiPart {
5
+ readonly path: string;
6
+ readonly name: string;
7
+ readonly exports?: ReadonlyArray<string>;
8
+ readonly status?: UiPartStatus;
9
+ readonly useInstead?: ReadonlyArray<string>;
10
+ }
11
+ /** A manifest, reduced to the parts the rule can act on. */
12
+ export interface UiManifest {
13
+ readonly components: ReadonlyArray<UiPart>;
14
+ }
15
+ /**
16
+ * Read one component, or `undefined` when it cannot be identified.
17
+ *
18
+ * `tier`, `owners`, `props` and `tags` are required by the manifest schema but not by
19
+ * this rule. Requiring them here would make a hand-written fixture verbose for no gain,
20
+ * and the rule's question is only "who is deprecated, and what replaces it".
21
+ * @param {unknown} value - The decoded JSON entry.
22
+ * @returns {UiPart | undefined} The part, or `undefined` when it cannot be identified.
23
+ */
24
+ export declare function decodeUiPart(value: unknown): UiPart | undefined;
25
+ /**
26
+ * Read a manifest, or `undefined` when it is not one.
27
+ *
28
+ * @param {unknown} value - The decoded JSON document.
29
+ * @returns {UiManifest | undefined} The manifest, or `undefined` when it is malformed.
30
+ */
31
+ export declare function decodeUiManifest(value: unknown): UiManifest | undefined;
32
+ /**
33
+ * Read a manifest from disk, degrading to `undefined`.
34
+ *
35
+ * A missing or malformed manifest is not a lint error: the rule goes quiet, exactly as
36
+ * every other manifest reader in this workspace does. `cutlist build --check` is the
37
+ * gate that makes a stale manifest loud.
38
+ *
39
+ * @param {string} path - The manifest file to read.
40
+ * @returns {UiManifest | undefined} The manifest, or `undefined` when it is absent or bad.
41
+ */
42
+ export declare function readUiManifest(path: string): UiManifest | undefined;
43
+ /**
44
+ * Resolve a configured path against the process working directory.
45
+ *
46
+ * @param {string} path - The manifest path, relative to the process cwd.
47
+ * @returns {UiManifest | undefined} The manifest, or `undefined` when it is absent or bad.
48
+ */
49
+ export declare function manifestAt(path: string): UiManifest | undefined;
@@ -0,0 +1,90 @@
1
+ import { readFileSync } from "node:fs";
2
+ import { resolve } from "node:path";
3
+ const STATUSES = ["stable", "beta", "experimental", "deprecated"];
4
+ function isRecord(value) {
5
+ return typeof value === "object" && value !== null && !Array.isArray(value);
6
+ }
7
+ function str(value) {
8
+ return typeof value === "string" ? value : undefined;
9
+ }
10
+ function strings(value) {
11
+ if (!Array.isArray(value))
12
+ return undefined;
13
+ if (!value.every((entry) => typeof entry === "string"))
14
+ return undefined;
15
+ return value;
16
+ }
17
+ function status(value) {
18
+ return STATUSES.find((entry) => entry === value);
19
+ }
20
+ /**
21
+ * Read one component, or `undefined` when it cannot be identified.
22
+ *
23
+ * `tier`, `owners`, `props` and `tags` are required by the manifest schema but not by
24
+ * this rule. Requiring them here would make a hand-written fixture verbose for no gain,
25
+ * and the rule's question is only "who is deprecated, and what replaces it".
26
+ * @param {unknown} value - The decoded JSON entry.
27
+ * @returns {UiPart | undefined} The part, or `undefined` when it cannot be identified.
28
+ */
29
+ export function decodeUiPart(value) {
30
+ if (!isRecord(value))
31
+ return undefined;
32
+ const path = str(value.path);
33
+ const name = str(value.name);
34
+ if (path === undefined || name === undefined)
35
+ return undefined;
36
+ const exports = strings(value.exports);
37
+ const partStatus = status(value.status);
38
+ const useInstead = strings(value.useInstead);
39
+ return {
40
+ path,
41
+ name,
42
+ ...(exports === undefined ? {} : { exports }),
43
+ ...(partStatus === undefined ? {} : { status: partStatus }),
44
+ ...(useInstead === undefined ? {} : { useInstead }),
45
+ };
46
+ }
47
+ /**
48
+ * Read a manifest, or `undefined` when it is not one.
49
+ *
50
+ * @param {unknown} value - The decoded JSON document.
51
+ * @returns {UiManifest | undefined} The manifest, or `undefined` when it is malformed.
52
+ */
53
+ export function decodeUiManifest(value) {
54
+ if (!isRecord(value) || !Array.isArray(value.components))
55
+ return undefined;
56
+ const components = [];
57
+ for (const entry of value.components) {
58
+ const part = decodeUiPart(entry);
59
+ if (part !== undefined)
60
+ components.push(part);
61
+ }
62
+ return { components };
63
+ }
64
+ /**
65
+ * Read a manifest from disk, degrading to `undefined`.
66
+ *
67
+ * A missing or malformed manifest is not a lint error: the rule goes quiet, exactly as
68
+ * every other manifest reader in this workspace does. `cutlist build --check` is the
69
+ * gate that makes a stale manifest loud.
70
+ *
71
+ * @param {string} path - The manifest file to read.
72
+ * @returns {UiManifest | undefined} The manifest, or `undefined` when it is absent or bad.
73
+ */
74
+ export function readUiManifest(path) {
75
+ try {
76
+ return decodeUiManifest(JSON.parse(readFileSync(path, "utf8")));
77
+ }
78
+ catch {
79
+ return undefined;
80
+ }
81
+ }
82
+ /**
83
+ * Resolve a configured path against the process working directory.
84
+ *
85
+ * @param {string} path - The manifest path, relative to the process cwd.
86
+ * @returns {UiManifest | undefined} The manifest, or `undefined` when it is absent or bad.
87
+ */
88
+ export function manifestAt(path) {
89
+ return readUiManifest(resolve(process.cwd(), path));
90
+ }
@@ -0,0 +1,3 @@
1
+ declare const RULE_ID = "plumb-ui/no-deprecated-parts";
2
+ export declare const noDeprecatedPartsRule: import("@oxlint/plugins").Rule;
3
+ export { RULE_ID };