@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,50 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ const RULE_TEST_FILE = /[/\\](?:rules|effect[/\\]rules|meta[/\\]rules)[/\\][^/\\]+\.test\.[cm]?[jt]sx?$/u;
3
+ /** Tests for lint rules belong in Oxlint's RuleTester: valid/invalid cases with message and span assertions. */
4
+ export const requireRuleTesterRule = defineRule({
5
+ meta: {
6
+ type: "suggestion",
7
+ docs: {
8
+ description: "Require test files co-located with lint rules to drive the rule through `RuleTester` (oxlint/plugins-dev).",
9
+ },
10
+ messages: {
11
+ useRuleTester: "This test file sits next to a lint rule but does not import `RuleTester` from `oxlint/plugins-dev`. Rule behavior should be pinned through valid/invalid cases with message and span assertions.",
12
+ neverRuns: "`RuleTester` is imported but `run()` is never called. Every rule suite must execute `ruleTester.run(...)`.",
13
+ },
14
+ },
15
+ createOnce(context) {
16
+ let program = null;
17
+ let importsRuleTester = false;
18
+ let callsRun = false;
19
+ return {
20
+ before() {
21
+ if (!RULE_TEST_FILE.test(context.filename.replaceAll("\\", "/")))
22
+ return false;
23
+ },
24
+ Program(node) {
25
+ program = node;
26
+ },
27
+ ImportDeclaration(node) {
28
+ const usesRuleTester = node.specifiers.some((specifier) => specifier.type === "ImportSpecifier" && specifier.imported.type === "Identifier" && specifier.imported.name === "RuleTester");
29
+ if (usesRuleTester)
30
+ importsRuleTester = true;
31
+ },
32
+ CallExpression(node) {
33
+ if (node.callee.type === "MemberExpression" &&
34
+ !node.callee.computed &&
35
+ node.callee.property.type === "Identifier" &&
36
+ node.callee.property.name === "run") {
37
+ callsRun = true;
38
+ }
39
+ },
40
+ "Program:exit"() {
41
+ if (program === null)
42
+ return;
43
+ if (!importsRuleTester)
44
+ context.report({ node: program, messageId: "useRuleTester" });
45
+ else if (!callsRun)
46
+ context.report({ node: program, messageId: "neverRuns" });
47
+ },
48
+ };
49
+ },
50
+ });
@@ -0,0 +1,3 @@
1
+ /** Opt-in Oxlint rules for React composition (the "perfect component" contract). */
2
+ declare const plumbReactPlugin: import("@oxlint/plugins").Plugin;
3
+ export default plumbReactPlugin;
@@ -0,0 +1,16 @@
1
+ import { eslintCompatPlugin } from "@oxlint/plugins";
2
+ import { requireTripartiteContextRule } from "./rules/require-tripartite-context.js";
3
+ import { requireGuardedContextHookRule } from "./rules/require-guarded-context-hook.js";
4
+ import { requireDotNotationExportsRule } from "./rules/require-dot-notation-exports.js";
5
+ import { useEncapsulationRule } from "./rules/use-encapsulation.js";
6
+ /** Opt-in Oxlint rules for React composition (the "perfect component" contract). */
7
+ const plumbReactPlugin = eslintCompatPlugin({
8
+ meta: { name: "plumb-react" },
9
+ rules: {
10
+ "require-tripartite-context": requireTripartiteContextRule,
11
+ "require-guarded-context-hook": requireGuardedContextHookRule,
12
+ "require-dot-notation-exports": requireDotNotationExportsRule,
13
+ "use-encapsulation": useEncapsulationRule,
14
+ },
15
+ });
16
+ export default plumbReactPlugin;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Whether a binding name denotes a context Provider (the generic Provider or a
3
+ * family-scoped XProvider). A Provider is the stateful root of a context family
4
+ * and the only component legitimately allowed to use React hooks inline.
5
+ *
6
+ * @param {string} name - The binding name.
7
+ * @returns {boolean} True when the name is `Provider` or ends with `Provider`.
8
+ */
9
+ export declare function isProviderName(name: string): boolean;
10
+ /**
11
+ * Family name contributed by a useXxx export binding.
12
+ *
13
+ * @param {string} name - The exported binding name.
14
+ * @returns {string | null} The family name, or null when not a useXxx hook.
15
+ */
16
+ export declare function hookFamily(name: string): string | null;
17
+ /**
18
+ * Whether a binding name denotes a custom hook (use + an uppercase letter).
19
+ *
20
+ * @param {string | null} name - The binding name, if known.
21
+ * @returns {name is string} True when the name starts with `use` + a capital.
22
+ */
23
+ export declare function isHookName(name: string | null): name is string;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Whether a binding name denotes a context Provider (the generic Provider or a
3
+ * family-scoped XProvider). A Provider is the stateful root of a context family
4
+ * and the only component legitimately allowed to use React hooks inline.
5
+ *
6
+ * @param {string} name - The binding name.
7
+ * @returns {boolean} True when the name is `Provider` or ends with `Provider`.
8
+ */
9
+ export function isProviderName(name) {
10
+ return name === "Provider" || name.endsWith("Provider");
11
+ }
12
+ /**
13
+ * Family name contributed by a useXxx export binding.
14
+ *
15
+ * @param {string} name - The exported binding name.
16
+ * @returns {string | null} The family name, or null when not a useXxx hook.
17
+ */
18
+ export function hookFamily(name) {
19
+ const match = /^use([A-Z]\w*)$/u.exec(name);
20
+ return match === null ? null : (match[1] ?? null);
21
+ }
22
+ /**
23
+ * Whether a binding name denotes a custom hook (use + an uppercase letter).
24
+ *
25
+ * @param {string | null} name - The binding name, if known.
26
+ * @returns {name is string} True when the name starts with `use` + a capital.
27
+ */
28
+ export function isHookName(name) {
29
+ return name !== null && /^use[A-Z]/u.test(name);
30
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Whether a component family (a Provider plus a useXxx hook sharing one family
3
+ * name) must carry a dot-notation aggregate export. The useXxx hook is the
4
+ * family's consumption API and is exported separately by convention, so
5
+ * `aggregateOk` only asks whether the aggregate (export const Family = {
6
+ * Provider, ... }) exists and carries its Provider.
7
+ *
8
+ * @param {{ providerFamily: string | null; hookFamily: string; singleFamily: boolean; aggregateOk: boolean }} input - The family's export facts.
9
+ * @returns {boolean} True when an aggregate is required but absent.
10
+ */
11
+ export declare function familyRequiresAggregate(input: {
12
+ providerFamily: string | null;
13
+ hookFamily: string;
14
+ singleFamily: boolean;
15
+ aggregateOk: boolean;
16
+ }): boolean;
17
+ /**
18
+ * A component family (a Provider plus a `useXxx` consumer hook) must be exported
19
+ * through a single dot-notation aggregate (`export const Family = { Provider, ... }`)
20
+ * so consumers compose `Family.Provider` / `Family.Header` and the blocks are
21
+ * discoverable. Bare re-exports of `Provider`/`useXxx` without the aggregate
22
+ * hide the family boundary.
23
+ *
24
+ * Uses createOnce; per-file state is reset in before() (which oxlint calls per
25
+ * file), so a family seen in one file cannot leak into another.
26
+ */
27
+ export declare const requireDotNotationExportsRule: import("@oxlint/plugins").Rule;
@@ -0,0 +1,144 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { isString } from "../../shared/structural.js";
3
+ import { hookFamily, isProviderName } from "../role.js";
4
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
5
+ /**
6
+ * Whether a component family (a Provider plus a useXxx hook sharing one family
7
+ * name) must carry a dot-notation aggregate export. The useXxx hook is the
8
+ * family's consumption API and is exported separately by convention, so
9
+ * `aggregateOk` only asks whether the aggregate (export const Family = {
10
+ * Provider, ... }) exists and carries its Provider.
11
+ *
12
+ * @param {{ providerFamily: string | null; hookFamily: string; singleFamily: boolean; aggregateOk: boolean }} input - The family's export facts.
13
+ * @returns {boolean} True when an aggregate is required but absent.
14
+ */
15
+ export function familyRequiresAggregate(input) {
16
+ const providerPresent = input.providerFamily === input.hookFamily ||
17
+ (input.providerFamily === "" && input.singleFamily);
18
+ return providerPresent && !input.aggregateOk;
19
+ }
20
+ /**
21
+ * Property key names of an object literal.
22
+ *
23
+ * @param {ESTree.Node} node - The object expression node.
24
+ * @returns {Set<string>} The property key names.
25
+ */
26
+ function objectPropKeys(node) {
27
+ const keys = new Set();
28
+ if (node.type !== "ObjectExpression")
29
+ return keys;
30
+ for (const prop of node.properties) {
31
+ if (prop.type === "Property") {
32
+ const key = prop.key;
33
+ if (key.type === "Identifier")
34
+ keys.add(key.name);
35
+ else if (key.type === "Literal" && isString(key.value))
36
+ keys.add(key.value);
37
+ }
38
+ }
39
+ return keys;
40
+ }
41
+ /**
42
+ * Whether an aggregate's keys include the Provider (the family's stateful root).
43
+ * The useXxx hook is the family's consumption API and is exported separately by
44
+ * convention, so it need not appear as a key of the aggregate.
45
+ *
46
+ * @param {Set<string>} keys - The aggregate object's property keys.
47
+ * @returns {boolean} True when both the Provider and the hook are present.
48
+ */
49
+ function hasProviderKey(keys) {
50
+ for (const k of keys)
51
+ if (k === "Provider" || /Provider$/u.test(k))
52
+ return true;
53
+ return false;
54
+ }
55
+ /**
56
+ * A component family (a Provider plus a `useXxx` consumer hook) must be exported
57
+ * through a single dot-notation aggregate (`export const Family = { Provider, ... }`)
58
+ * so consumers compose `Family.Provider` / `Family.Header` and the blocks are
59
+ * discoverable. Bare re-exports of `Provider`/`useXxx` without the aggregate
60
+ * hide the family boundary.
61
+ *
62
+ * Uses createOnce; per-file state is reset in before() (which oxlint calls per
63
+ * file), so a family seen in one file cannot leak into another.
64
+ */
65
+ export const requireDotNotationExportsRule = defineRule({
66
+ meta: {
67
+ type: "problem",
68
+ docs: {
69
+ description: "Require a component family (Provider + useXxx hook) to be exported via a single dot-notation aggregate (export const Family = { Provider, ... }).",
70
+ },
71
+ messages: {
72
+ missingAggregate: "Component family `{{family}}` exports a Provider and a `use{{family}}` hook but no dot-notation aggregate `export const {{family}} = { Provider, ... }`. Export the family as one object so consumers compose `{{family}}.Provider` / `{{family}}.Header` and the blocks are discoverable.",
73
+ },
74
+ },
75
+ createOnce(context) {
76
+ const providerBases = new Set();
77
+ const hookFamilies = new Set();
78
+ const aggregates = new Map();
79
+ let reportNode = null;
80
+ const recordName = (entry) => {
81
+ if (reportNode === null)
82
+ reportNode = entry.node;
83
+ if (isProviderName(entry.name)) {
84
+ providerBases.add(entry.name === "Provider" ? "" : entry.name.slice(0, -"Provider".length));
85
+ }
86
+ const hf = hookFamily(entry.name);
87
+ if (hf !== null)
88
+ hookFamilies.add(hf);
89
+ };
90
+ return {
91
+ before() {
92
+ providerBases.clear();
93
+ hookFamilies.clear();
94
+ aggregates.clear();
95
+ reportNode = null;
96
+ if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
97
+ return false;
98
+ },
99
+ ExportNamedDeclaration(node) {
100
+ const decl = node.declaration;
101
+ if (decl !== null && decl !== undefined) {
102
+ if (decl.type === "VariableDeclaration") {
103
+ for (const declarator of decl.declarations) {
104
+ if (declarator.id.type !== "Identifier")
105
+ continue;
106
+ recordName({ name: declarator.id.name, node });
107
+ if (declarator.init?.type === "ObjectExpression") {
108
+ aggregates.set(declarator.id.name, objectPropKeys(declarator.init));
109
+ }
110
+ }
111
+ }
112
+ else if (decl.type === "FunctionDeclaration" && decl.id !== null) {
113
+ recordName({ name: decl.id.name, node });
114
+ }
115
+ }
116
+ for (const specifier of node.specifiers) {
117
+ if (specifier.type !== "ExportSpecifier")
118
+ continue;
119
+ const exported = specifier.exported;
120
+ const name = exported.type === "Identifier" ? exported.name : (exported.value ?? "");
121
+ recordName({ name, node });
122
+ }
123
+ },
124
+ "Program:exit"() {
125
+ if (hookFamilies.size === 0)
126
+ return;
127
+ const node = reportNode;
128
+ if (node === null)
129
+ return;
130
+ const singleFamily = hookFamilies.size === 1;
131
+ for (const family of hookFamilies) {
132
+ const providerPresent = providerBases.has(family) || (providerBases.has("") && singleFamily);
133
+ if (!providerPresent)
134
+ continue;
135
+ const agg = aggregates.get(family);
136
+ const ok = agg !== undefined && hasProviderKey(agg);
137
+ if (ok)
138
+ continue;
139
+ context.report({ node, messageId: "missingAggregate", data: { family } });
140
+ }
141
+ },
142
+ };
143
+ },
144
+ });
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Whether a custom context hook that reads context must be reported for
3
+ * lacking a guard against a missing Provider.
4
+ *
5
+ * @param {{ isHook: boolean; callsUseContext: boolean; guarded: boolean }} input - The hook's shape facts.
6
+ * @returns {boolean} True when the hook needs a guard but has none.
7
+ */
8
+ export declare function requiresContextGuard(input: {
9
+ isHook: boolean;
10
+ callsUseContext: boolean;
11
+ guarded: boolean;
12
+ }): boolean;
13
+ /**
14
+ * A custom hook that reads context with `useContext` must throw when the
15
+ * Provider is missing, rather than returning `undefined` and pushing a
16
+ * null-check onto every consumer. Returning a possibly-undefined context is the
17
+ * same hidden-nullable defect the rest of the library forbids.
18
+ */
19
+ export declare const requireGuardedContextHookRule: import("@oxlint/plugins").Rule;
@@ -0,0 +1,167 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { ancestorsOf } from "../../shared/ancestors.js";
3
+ import { isHookName } from "../role.js";
4
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
5
+ /**
6
+ * Whether a custom context hook that reads context must be reported for
7
+ * lacking a guard against a missing Provider.
8
+ *
9
+ * @param {{ isHook: boolean; callsUseContext: boolean; guarded: boolean }} input - The hook's shape facts.
10
+ * @returns {boolean} True when the hook needs a guard but has none.
11
+ */
12
+ export function requiresContextGuard(input) {
13
+ return input.isHook && input.callsUseContext && !input.guarded;
14
+ }
15
+ /**
16
+ * The variable name an `if` test guards against a nullish value.
17
+ *
18
+ * @param {ESTree.Node} test - The if-statement test expression.
19
+ * @returns {string | null} The guarded variable name, or null when not a nullish guard.
20
+ */
21
+ function checkedVar(test) {
22
+ if (test.type === "UnaryExpression" && test.operator === "!" && test.argument.type === "Identifier") {
23
+ return test.argument.name;
24
+ }
25
+ if (test.type === "BinaryExpression") {
26
+ const nullish = (operand) => (operand.type === "Identifier" && (operand.name === "undefined" || operand.name === "null")) ||
27
+ (operand.type === "Literal" && (operand.value === null || operand.value === undefined));
28
+ if (test.operator === "===" || test.operator === "!==" || test.operator === "==" || test.operator === "!=") {
29
+ if (test.left.type === "Identifier" && nullish(test.right))
30
+ return test.left.name;
31
+ if (test.right.type === "Identifier" && nullish(test.left))
32
+ return test.right.name;
33
+ }
34
+ }
35
+ return null;
36
+ }
37
+ /**
38
+ * Whether a statement (or its block body) throws.
39
+ *
40
+ * @param {ESTree.Node} node - The statement node to inspect.
41
+ * @returns {boolean} True when the statement throws.
42
+ */
43
+ function containsThrow(node) {
44
+ if (node.type === "ThrowStatement")
45
+ return true;
46
+ if (node.type === "BlockStatement")
47
+ return node.body.some((s) => s.type === "ThrowStatement");
48
+ return false;
49
+ }
50
+ /**
51
+ * Whether the callee references `useContext`.
52
+ *
53
+ * @param {ESTree.Node} callee - The callee expression of a call.
54
+ * @returns {boolean} True when the callee is `useContext`.
55
+ */
56
+ function isUseContext(callee) {
57
+ if (callee.type === "Identifier")
58
+ return callee.name === "useContext";
59
+ if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier")
60
+ return callee.property.name === "useContext";
61
+ return false;
62
+ }
63
+ /**
64
+ * A custom hook that reads context with `useContext` must throw when the
65
+ * Provider is missing, rather than returning `undefined` and pushing a
66
+ * null-check onto every consumer. Returning a possibly-undefined context is the
67
+ * same hidden-nullable defect the rest of the library forbids.
68
+ */
69
+ export const requireGuardedContextHookRule = defineRule({
70
+ meta: {
71
+ type: "problem",
72
+ docs: {
73
+ description: "Require custom context hooks (useXxx calling useContext) to throw when the Provider is missing, instead of returning a possibly-undefined context.",
74
+ },
75
+ messages: {
76
+ unguardedContext: "`{{name}}` reads context with useContext but never guards against a missing Provider (no `if (!context) throw`). A context read outside the Provider returns undefined; throw when it is absent so consumers get a clear error instead of a nullable value.",
77
+ },
78
+ },
79
+ createOnce(context) {
80
+ const frames = [];
81
+ const push = (entry) => {
82
+ frames.push({ name: entry.name, node: entry.node, useContextVars: new Set(), guardedVars: new Set() });
83
+ };
84
+ const current = () => frames[frames.length - 1];
85
+ /**
86
+ * Nearest enclosing function name for a node (declaration or variable binding).
87
+ *
88
+ * @param {ESTree.Node} node - The reference node.
89
+ * @returns {string | null} The nearest function name, or null when anonymous.
90
+ */
91
+ function nearestFunctionName(node) {
92
+ const ancestors = ancestorsOf(context.sourceCode, node);
93
+ for (let i = ancestors.length - 1; i >= 0; i--) {
94
+ const a = ancestors[i];
95
+ if (a === undefined)
96
+ continue;
97
+ if (a.type === "FunctionDeclaration" && a.id !== null && a.id !== undefined)
98
+ return a.id.name;
99
+ if (a.type === "FunctionExpression" && a.id !== null && a.id !== undefined)
100
+ return a.id.name;
101
+ if (a.type === "VariableDeclarator" && a.id.type === "Identifier") {
102
+ const init = a.init;
103
+ if (init !== null &&
104
+ init !== undefined &&
105
+ (init.type === "ArrowFunctionExpression" || init.type === "FunctionExpression"))
106
+ return a.id.name;
107
+ }
108
+ }
109
+ return null;
110
+ }
111
+ return {
112
+ before() {
113
+ frames.length = 0;
114
+ if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
115
+ return false;
116
+ },
117
+ FunctionDeclaration(node) {
118
+ push({ name: node.id?.name ?? null, node });
119
+ },
120
+ "FunctionDeclaration:exit"() {
121
+ const frame = frames.pop();
122
+ if (frame !== undefined)
123
+ report(frame);
124
+ },
125
+ FunctionExpression(node) {
126
+ push({ name: node.id?.name ?? null, node });
127
+ },
128
+ "FunctionExpression:exit"() {
129
+ const frame = frames.pop();
130
+ if (frame !== undefined)
131
+ report(frame);
132
+ },
133
+ ArrowFunctionExpression(node) {
134
+ push({ name: nearestFunctionName(node), node });
135
+ },
136
+ "ArrowFunctionExpression:exit"() {
137
+ const frame = frames.pop();
138
+ if (frame !== undefined)
139
+ report(frame);
140
+ },
141
+ CallExpression(node) {
142
+ if (!isUseContext(node.callee))
143
+ return;
144
+ const parent = ancestorsOf(context.sourceCode, node).at(-1);
145
+ if (parent?.type === "VariableDeclarator" && parent.id.type === "Identifier") {
146
+ current()?.useContextVars.add(parent.id.name);
147
+ }
148
+ },
149
+ IfStatement(node) {
150
+ const variable = checkedVar(node.test);
151
+ if (variable === null)
152
+ return;
153
+ if (containsThrow(node.consequent) || (node.alternate !== null && containsThrow(node.alternate))) {
154
+ current()?.guardedVars.add(variable);
155
+ }
156
+ },
157
+ };
158
+ function report(frame) {
159
+ if (!isHookName(frame.name))
160
+ return;
161
+ const unguarded = [...frame.useContextVars].filter((v) => !frame.guardedVars.has(v));
162
+ if (unguarded.length === 0)
163
+ return;
164
+ context.report({ node: frame.node, messageId: "unguardedContext", data: { name: frame.name } });
165
+ }
166
+ },
167
+ });
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Whether a context value type's member keys form the tripartite
3
+ * state/actions/meta contract.
4
+ *
5
+ * @param {ReadonlyArray<string>} members - The declared member key names.
6
+ * @returns {boolean} True when `state`, `actions`, and `meta` are all present.
7
+ */
8
+ export declare function isTripartiteContextValue(members: ReadonlyArray<string>): boolean;
9
+ /**
10
+ * A React context's value must be shaped as `{ state, actions, meta }`: state is
11
+ * the data, actions are the functions that change it, and meta holds
12
+ * non-reactive configuration. This is the explicit I/O boundary of the
13
+ * component family - the same "perfect function" contract as the composition
14
+ * pattern. A context that omits one of the three leaks an implicit, unnamed
15
+ * channel that consumers cannot reason about.
16
+ */
17
+ export declare const requireTripartiteContextRule: import("@oxlint/plugins").Rule;
@@ -0,0 +1,160 @@
1
+ import { defineRule } from "@oxlint/plugins";
2
+ import { isString } from "../../shared/structural.js";
3
+ const TEST_FILE = /\.(?:test|spec)\.[cm]?[jt]sx?$/u;
4
+ /** The three required keys of a context value type. */
5
+ const REQUIRED_KEYS = ["state", "actions", "meta"];
6
+ /**
7
+ * Whether a context value type's member keys form the tripartite
8
+ * state/actions/meta contract.
9
+ *
10
+ * @param {ReadonlyArray<string>} members - The declared member key names.
11
+ * @returns {boolean} True when `state`, `actions`, and `meta` are all present.
12
+ */
13
+ export function isTripartiteContextValue(members) {
14
+ const present = new Set(members);
15
+ return REQUIRED_KEYS.every((key) => present.has(key));
16
+ }
17
+ /**
18
+ * Member key names of a TS object type (interface body or inline literal).
19
+ *
20
+ * @param {ESTree.Node} node - The interface or type-literal node.
21
+ * @returns {ReadonlyArray<string>} The declared member key names.
22
+ */
23
+ function memberKeys(node) {
24
+ const keys = [];
25
+ const addKey = (key) => {
26
+ if (key.type === "Identifier")
27
+ keys.push(key.name);
28
+ else if (key.type === "Literal" && isString(key.value))
29
+ keys.push(key.value);
30
+ };
31
+ if (node.type === "TSInterfaceDeclaration") {
32
+ for (const member of node.body.body) {
33
+ if (member.type === "TSPropertySignature" || member.type === "TSMethodSignature")
34
+ addKey(member.key);
35
+ }
36
+ }
37
+ else if (node.type === "TSTypeLiteral") {
38
+ for (const member of node.members) {
39
+ if (member.type === "TSPropertySignature" || member.type === "TSMethodSignature")
40
+ addKey(member.key);
41
+ }
42
+ }
43
+ return keys;
44
+ }
45
+ /**
46
+ * Final segment of a type reference name.
47
+ *
48
+ * @param {ESTree.TSTypeReference} node - The type reference node.
49
+ * @returns {string | null} The unqualified type name, or null when unavailable.
50
+ */
51
+ function typeName(node) {
52
+ const tn = node.typeName;
53
+ if (tn.type === "Identifier")
54
+ return tn.name;
55
+ if (tn.type === "TSQualifiedName")
56
+ return tn.right.name;
57
+ return null;
58
+ }
59
+ /**
60
+ * Whether the callee references `createContext`.
61
+ *
62
+ * @param {ESTree.Node} callee - The callee expression of a call.
63
+ * @returns {boolean} True when the callee is `createContext`.
64
+ */
65
+ function isCreateContext(callee) {
66
+ if (callee.type === "Identifier")
67
+ return callee.name === "createContext";
68
+ if (callee.type === "MemberExpression" && !callee.computed && callee.property.type === "Identifier")
69
+ return callee.property.name === "createContext";
70
+ return false;
71
+ }
72
+ /**
73
+ * A React context's value must be shaped as `{ state, actions, meta }`: state is
74
+ * the data, actions are the functions that change it, and meta holds
75
+ * non-reactive configuration. This is the explicit I/O boundary of the
76
+ * component family - the same "perfect function" contract as the composition
77
+ * pattern. A context that omits one of the three leaks an implicit, unnamed
78
+ * channel that consumers cannot reason about.
79
+ */
80
+ export const requireTripartiteContextRule = defineRule({
81
+ meta: {
82
+ type: "problem",
83
+ docs: {
84
+ description: "Require React context value types to be the tripartite { state, actions, meta } shape; missing keys leak an implicit, unnamed I/O channel.",
85
+ },
86
+ messages: {
87
+ tripartiteContext: "Context value type is missing required key(s): {{missing}}. A context value must be { state, actions, meta } so its I/O boundary is explicit.",
88
+ },
89
+ },
90
+ createOnce(context) {
91
+ const localTypes = new Map();
92
+ const calls = [];
93
+ /**
94
+ * Resolve a context type argument to declared member keys, if local.
95
+ *
96
+ * @param {ESTree.Node} typeArg - The type argument node passed to createContext.
97
+ * @returns {ReadonlyArray<string> | null} The member keys, or null when unresolved.
98
+ */
99
+ function resolveKeys(typeArg) {
100
+ if (typeArg.type === "TSTypeLiteral")
101
+ return memberKeys(typeArg);
102
+ if (typeArg.type === "TSTypeReference") {
103
+ const name = typeName(typeArg);
104
+ return name === null ? null : localTypes.get(name) ?? null;
105
+ }
106
+ if (typeArg.type === "TSUnionType") {
107
+ for (const member of typeArg.types) {
108
+ if (member.type === "TSUndefinedKeyword" || member.type === "TSNullKeyword")
109
+ continue;
110
+ const resolved = resolveKeys(member);
111
+ if (resolved !== null)
112
+ return resolved;
113
+ }
114
+ }
115
+ return null;
116
+ }
117
+ return {
118
+ before() {
119
+ localTypes.clear();
120
+ calls.length = 0;
121
+ if (TEST_FILE.test(context.filename.replaceAll("\\", "/")))
122
+ return false;
123
+ },
124
+ TSInterfaceDeclaration(node) {
125
+ localTypes.set(node.id.name, memberKeys(node));
126
+ },
127
+ TSTypeAliasDeclaration(node) {
128
+ if (node.typeAnnotation.type === "TSTypeLiteral") {
129
+ localTypes.set(node.id.name, memberKeys(node.typeAnnotation));
130
+ }
131
+ },
132
+ CallExpression(node) {
133
+ if (isCreateContext(node.callee))
134
+ calls.push(node);
135
+ },
136
+ "Program:exit"() {
137
+ for (const call of calls) {
138
+ const params = call.typeArguments?.params;
139
+ if (params === undefined || params.length === 0)
140
+ continue;
141
+ const first = params[0];
142
+ if (first === undefined)
143
+ continue;
144
+ const keys = resolveKeys(first);
145
+ if (keys === null)
146
+ continue;
147
+ if (isTripartiteContextValue(keys))
148
+ continue;
149
+ const present = new Set(keys);
150
+ const missing = REQUIRED_KEYS.filter((key) => !present.has(key));
151
+ context.report({
152
+ node: call,
153
+ messageId: "tripartiteContext",
154
+ data: { missing: missing.join(", ") },
155
+ });
156
+ }
157
+ },
158
+ };
159
+ },
160
+ });