@agentvibes/guardrails 0.2.7 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (265) hide show
  1. package/README.md +252 -5
  2. package/candidates/README.md +13 -13
  3. package/candidates/r10-as-cast.yml +4 -4
  4. package/candidates/r1d-scattered-numeric-const-in-component.yml +3 -3
  5. package/candidates/r2-helper-fn-in-tsx.yml +3 -3
  6. package/candidates/r3-hooks-outside-layout.yml +4 -4
  7. package/candidates/r6-jsx-comment-smell.yml +2 -2
  8. package/candidates/r7-raw-hsl-outside-tokens.yml +3 -3
  9. package/candidates/r8-inline-style-prop.yml +2 -2
  10. package/candidates/r9-optional-store-arg.yml +2 -2
  11. package/dist/astGrep.js +4 -2
  12. package/dist/astGrep.js.map +1 -1
  13. package/dist/cli.js +89 -6
  14. package/dist/cli.js.map +1 -1
  15. package/dist/cliArgsTest.d.ts +1 -0
  16. package/dist/cliArgsTest.js +44 -0
  17. package/dist/cliArgsTest.js.map +1 -0
  18. package/dist/doctor.d.ts +1 -1
  19. package/dist/doctor.js +58 -6
  20. package/dist/doctor.js.map +1 -1
  21. package/dist/fileSloc.d.ts +28 -0
  22. package/dist/fileSloc.js +72 -0
  23. package/dist/fileSloc.js.map +1 -0
  24. package/dist/fileSlocBaseline.d.ts +78 -0
  25. package/dist/fileSlocBaseline.js +173 -0
  26. package/dist/fileSlocBaseline.js.map +1 -0
  27. package/dist/fileSlocGate.d.ts +17 -0
  28. package/dist/fileSlocGate.js +75 -0
  29. package/dist/fileSlocGate.js.map +1 -0
  30. package/dist/fileSlocTest.d.ts +1 -0
  31. package/dist/fileSlocTest.js +172 -0
  32. package/dist/fileSlocTest.js.map +1 -0
  33. package/dist/fileWalk.js +1 -1
  34. package/dist/fileWalk.js.map +1 -1
  35. package/dist/findings.d.ts +1 -1
  36. package/dist/gateRed.d.ts +1 -1
  37. package/dist/gateRed.js +1 -0
  38. package/dist/gateRed.js.map +1 -1
  39. package/dist/gitDiff.d.ts +6 -0
  40. package/dist/gitDiff.js +25 -0
  41. package/dist/gitDiff.js.map +1 -1
  42. package/dist/hookStop.d.ts +2 -1
  43. package/dist/hookStop.js +7 -1
  44. package/dist/hookStop.js.map +1 -1
  45. package/dist/hookStopTest.d.ts +1 -1
  46. package/dist/hookStopTest.js +1 -0
  47. package/dist/hookStopTest.js.map +1 -1
  48. package/dist/init.js +1 -1
  49. package/dist/init.js.map +1 -1
  50. package/dist/initTest.d.ts +1 -1
  51. package/dist/initTest.js +2 -1
  52. package/dist/initTest.js.map +1 -1
  53. package/dist/iterateTest.d.ts +1 -1
  54. package/dist/iterateTest.js +1 -0
  55. package/dist/iterateTest.js.map +1 -1
  56. package/dist/jsxSuppress.js +1 -1
  57. package/dist/jsxSuppress.js.map +1 -1
  58. package/dist/jsxSuppressTest.d.ts +1 -1
  59. package/dist/jsxSuppressTest.js +4 -2
  60. package/dist/jsxSuppressTest.js.map +1 -1
  61. package/dist/leaksRed.d.ts +1 -1
  62. package/dist/leaksRed.js +1 -0
  63. package/dist/leaksRed.js.map +1 -1
  64. package/dist/metrics.d.ts +9 -0
  65. package/dist/metrics.js +96 -7
  66. package/dist/metrics.js.map +1 -1
  67. package/dist/metricsBaseline.js +1 -1
  68. package/dist/metricsBaseline.js.map +1 -1
  69. package/dist/metricsCollect.js +2 -45
  70. package/dist/metricsCollect.js.map +1 -1
  71. package/dist/metricsCycle.d.ts +1 -1
  72. package/dist/metricsCycle.js +1 -0
  73. package/dist/metricsCycle.js.map +1 -1
  74. package/dist/metricsTypes.d.ts +1 -1
  75. package/dist/overrideDeclarations.d.ts +35 -0
  76. package/dist/overrideDeclarations.js +94 -0
  77. package/dist/overrideDeclarations.js.map +1 -0
  78. package/dist/overrides.d.ts +35 -0
  79. package/dist/overrides.js +284 -0
  80. package/dist/overrides.js.map +1 -0
  81. package/dist/overridesTest.d.ts +1 -0
  82. package/dist/overridesTest.js +183 -0
  83. package/dist/overridesTest.js.map +1 -0
  84. package/dist/pipeOutputTest.d.ts +1 -1
  85. package/dist/pipeOutputTest.js +2 -1
  86. package/dist/pipeOutputTest.js.map +1 -1
  87. package/dist/presetDrift.d.ts +8 -0
  88. package/dist/presetDrift.js +91 -34
  89. package/dist/presetDrift.js.map +1 -1
  90. package/dist/presetDriftTest.d.ts +1 -1
  91. package/dist/presetDriftTest.js +3 -3
  92. package/dist/presetDriftTest.js.map +1 -1
  93. package/dist/record/config.d.ts +17 -0
  94. package/dist/record/config.js +83 -0
  95. package/dist/record/config.js.map +1 -0
  96. package/dist/record/index.d.ts +69 -0
  97. package/dist/record/index.js +8 -0
  98. package/dist/record/index.js.map +1 -0
  99. package/dist/record/record.d.ts +56 -0
  100. package/dist/record/record.js +111 -0
  101. package/dist/record/record.js.map +1 -0
  102. package/dist/record/repoKey.d.ts +8 -0
  103. package/dist/record/repoKey.js +70 -0
  104. package/dist/record/repoKey.js.map +1 -0
  105. package/dist/record/repoMetrics.d.ts +14 -0
  106. package/dist/record/repoMetrics.js +124 -0
  107. package/dist/record/repoMetrics.js.map +1 -0
  108. package/dist/record/runRecord.d.ts +60 -0
  109. package/dist/record/runRecord.js +2 -0
  110. package/dist/record/runRecord.js.map +1 -0
  111. package/dist/record/schema.d.ts +31 -0
  112. package/dist/record/schema.js +201 -0
  113. package/dist/record/schema.js.map +1 -0
  114. package/dist/record/writer.d.ts +22 -0
  115. package/dist/record/writer.js +341 -0
  116. package/dist/record/writer.js.map +1 -0
  117. package/dist/recordTest.d.ts +1 -0
  118. package/dist/recordTest.js +422 -0
  119. package/dist/recordTest.js.map +1 -0
  120. package/dist/renameDiffTest.d.ts +1 -1
  121. package/dist/renameDiffTest.js +2 -1
  122. package/dist/renameDiffTest.js.map +1 -1
  123. package/dist/repoRules.js +1 -1
  124. package/dist/repoRules.js.map +1 -1
  125. package/dist/repoRulesTest.d.ts +1 -1
  126. package/dist/repoRulesTest.js +2 -1
  127. package/dist/repoRulesTest.js.map +1 -1
  128. package/dist/screenScope.js +4 -5
  129. package/dist/screenScope.js.map +1 -1
  130. package/dist/screenScopeTest.d.ts +1 -1
  131. package/dist/screenScopeTest.js +2 -1
  132. package/dist/screenScopeTest.js.map +1 -1
  133. package/dist/severityTest.d.ts +1 -1
  134. package/dist/severityTest.js +1 -0
  135. package/dist/severityTest.js.map +1 -1
  136. package/dist/siblingCloneTest.js +12 -12
  137. package/dist/siblingCloneTest.js.map +1 -1
  138. package/dist/snapshot.d.ts +2 -0
  139. package/dist/snapshot.js +118 -0
  140. package/dist/snapshot.js.map +1 -0
  141. package/dist/snapshotTest.d.ts +1 -0
  142. package/dist/snapshotTest.js +194 -0
  143. package/dist/snapshotTest.js.map +1 -0
  144. package/dist/structure.js +2 -2
  145. package/dist/structure.js.map +1 -1
  146. package/dist/testIsolation.d.ts +1 -0
  147. package/dist/testIsolation.js +7 -0
  148. package/dist/testIsolation.js.map +1 -0
  149. package/dist/testPaths.d.ts +4 -0
  150. package/dist/testPaths.js +9 -0
  151. package/dist/testPaths.js.map +1 -0
  152. package/dist/testRules.js +33 -3
  153. package/dist/testRules.js.map +1 -1
  154. package/dist/time.d.ts +22 -0
  155. package/dist/time.js +77 -0
  156. package/dist/time.js.map +1 -0
  157. package/dist/timeTest.d.ts +1 -0
  158. package/dist/timeTest.js +103 -0
  159. package/dist/timeTest.js.map +1 -0
  160. package/dist/tomlTable.d.ts +1 -1
  161. package/dist/tomlTable.js +6 -3
  162. package/dist/tomlTable.js.map +1 -1
  163. package/dist/toolResolve.d.ts +6 -0
  164. package/dist/toolResolve.js +18 -0
  165. package/dist/toolResolve.js.map +1 -1
  166. package/dist/twinCoverageTest.js +2 -20
  167. package/dist/twinCoverageTest.js.map +1 -1
  168. package/dist/verify.d.ts +2 -1
  169. package/dist/verify.js +33 -5
  170. package/dist/verify.js.map +1 -1
  171. package/dist/verifyDiff.d.ts +3 -2
  172. package/dist/verifyDiff.js +58 -8
  173. package/dist/verifyDiff.js.map +1 -1
  174. package/dist/wiring.d.ts +31 -0
  175. package/dist/wiring.js +262 -0
  176. package/dist/wiring.js.map +1 -0
  177. package/dist/wiringTest.d.ts +1 -0
  178. package/dist/wiringTest.js +127 -0
  179. package/dist/wiringTest.js.map +1 -0
  180. package/package.json +18 -6
  181. package/rules/__fixtures__/demo-mode-by-default/bad.ts +1 -1
  182. package/rules/__fixtures__/demo-mode-by-default/bad.tsx +1 -1
  183. package/rules/__fixtures__/direct-store-import/bad.tsx +1 -1
  184. package/rules/__fixtures__/direct-store-import/good.tsx +2 -2
  185. package/rules/__fixtures__/discriminator-ternary/bad.ts +9 -0
  186. package/rules/__fixtures__/discriminator-ternary/bad.tsx +1 -1
  187. package/rules/__fixtures__/discriminator-ternary/good.ts +17 -0
  188. package/rules/__fixtures__/discriminator-ternary/good.tsx +1 -1
  189. package/rules/__fixtures__/hardcoded-url-in-component/components/bad.ts +9 -0
  190. package/rules/__fixtures__/hardcoded-url-in-component/components/good.ts +13 -0
  191. package/rules/__fixtures__/inline-map-row/bad.tsx +1 -1
  192. package/rules/__fixtures__/inline-map-row/good.tsx +1 -1
  193. package/rules/__fixtures__/match-bool-to-null/bad.ts +14 -0
  194. package/rules/__fixtures__/match-bool-to-null/bad.tsx +8 -0
  195. package/rules/__fixtures__/match-bool-to-null/good.ts +12 -0
  196. package/rules/__fixtures__/match-bool-to-null/good.tsx +12 -0
  197. package/rules/__fixtures__/missing-observer/bad.tsx +2 -2
  198. package/rules/__fixtures__/missing-observer/good.tsx +2 -2
  199. package/rules/__fixtures__/no-local-kit-clone/bad.ts +2 -2
  200. package/rules/__fixtures__/no-local-kit-clone/bad.tsx +2 -2
  201. package/rules/__fixtures__/state-loading-boolean-shape/good.ts +1 -1
  202. package/rules/__fixtures__/state-loading-boolean-shape/good.tsx +1 -1
  203. package/rules/__fixtures__/store-async-method/good.ts +1 -1
  204. package/rules/__fixtures__/store-async-method/good.tsx +1 -1
  205. package/rules/__fixtures__/store-context-provider/bad.ts +1 -1
  206. package/rules/__fixtures__/store-delegation-getter/bad.ts +1 -1
  207. package/rules/__fixtures__/store-delegation-getter/bad.tsx +1 -1
  208. package/rules/__fixtures__/store-delegation-getter/good.ts +3 -3
  209. package/rules/__fixtures__/store-delegation-getter/good.tsx +3 -3
  210. package/rules/__fixtures__/store-no-runinaction/bad.ts +1 -1
  211. package/rules/__fixtures__/store-no-runinaction/bad.tsx +1 -1
  212. package/rules/__fixtures__/store-no-runinaction/good.ts +1 -1
  213. package/rules/__fixtures__/store-no-runinaction/good.tsx +1 -1
  214. package/rules/__fixtures__/ts-pattern-dangling-match/bad.ts +1 -1
  215. package/rules/__fixtures__/ts-pattern-dangling-match/good.ts +2 -2
  216. package/rules/__fixtures__/ui-imports-app-store/src/ui/bad.ts +11 -0
  217. package/rules/__fixtures__/ui-imports-app-store/src/ui/good.ts +13 -0
  218. package/rules/__fixtures__/ui-imports-app-store/src/ui/good.tsx +1 -1
  219. package/rules/__fixtures__/view-imports-store/good.view.tsx +1 -1
  220. package/rules/as-any-escape-tsx.yml +2 -2
  221. package/rules/as-any-escape.yml +2 -2
  222. package/rules/catch-empty-tsx.yml +3 -3
  223. package/rules/catch-empty.yml +3 -3
  224. package/rules/demo-mode-by-default-ts.yml +6 -7
  225. package/rules/demo-mode-by-default.yml +6 -7
  226. package/rules/direct-store-import.yml +15 -16
  227. package/rules/discriminator-ternary-ts.yml +46 -0
  228. package/rules/discriminator-ternary.yml +3 -3
  229. package/rules/hardcoded-url-in-component-ts.yml +40 -0
  230. package/rules/hardcoded-url-in-component.yml +5 -8
  231. package/rules/inline-map-row.yml +7 -7
  232. package/rules/instanceof-map-set-tsx.yml +2 -2
  233. package/rules/instanceof-map-set.yml +2 -2
  234. package/rules/kind-if-without-match-tsx.yml +1 -1
  235. package/rules/literal-union-in-component-tsx.yml +2 -2
  236. package/rules/literal-union-in-component.yml +7 -7
  237. package/rules/match-bool-to-null-ts.yml +27 -0
  238. package/rules/missing-observer.yml +5 -5
  239. package/rules/no-local-kit-clone-tsx.yml +2 -2
  240. package/rules/no-local-kit-clone.yml +2 -2
  241. package/rules/non-exhaustive-match-tsx.yml +4 -7
  242. package/rules/non-exhaustive-match.yml +2 -2
  243. package/rules/page-store-bare-usememo-tsx.yml +1 -1
  244. package/rules/page-store-bare-usememo.yml +1 -1
  245. package/rules/screen-file-styling.yml +3 -3
  246. package/rules/silent-default-return-tsx.yml +1 -1
  247. package/rules/store-async-method-tsx.yml +1 -1
  248. package/rules/store-async-method.yml +1 -1
  249. package/rules/store-context-provider-tsx.yml +3 -3
  250. package/rules/store-context-provider.yml +5 -5
  251. package/rules/store-delegation-getter-tsx.yml +2 -2
  252. package/rules/store-delegation-getter.yml +2 -2
  253. package/rules/store-no-runinaction-tsx.yml +2 -2
  254. package/rules/store-no-runinaction.yml +2 -2
  255. package/rules/store-no-setinterval-poll-tsx.yml +1 -1
  256. package/rules/store-no-setinterval-poll.yml +1 -1
  257. package/rules/ts-pattern-dangling-match-tsx.yml +4 -4
  258. package/rules/ts-pattern-dangling-match.yml +4 -4
  259. package/rules/ui-imports-app-store-ts.yml +61 -0
  260. package/rules/ui-imports-app-store.yml +1 -1
  261. package/rules/view-file-logic.yml +5 -5
  262. package/rules/view-imports-store.yml +4 -5
  263. package/rules/zod-optional-nullable-tsx.yml +2 -2
  264. package/rules/zod-optional-nullable.yml +2 -2
  265. package/structure/rules/component-decl.yml +1 -1
@@ -38,7 +38,7 @@ utils:
38
38
  kind: identifier
39
39
  regex: '^runInAction$'
40
40
  # An observable MUTATION — which is the whole defect. Without this clause the
41
- # rule fires on any async method, and in SiteCraft 10 of its 12 hits were
41
+ # rule fires on any async method, and in a site-builder repo 10 of its 12 hits were
42
42
  # private I/O helpers (`walkDir`, `collectAllFiles`, `uploadFile`) that await
43
43
  # a filesystem and never touch a field. Those have no action coverage to lose,
44
44
  # so at warning tier they were pure noise.
@@ -1,5 +1,5 @@
1
1
  # ADOPTION NOTE (canon promotion): brownfield-heavy — ~48-105 whole-tree hits
2
- # per useStore-era repo (tg-gallery/observatory/ppa). Run it DIFF-SCOPED
2
+ # per useStore-era repo (three consumer apps). Run it DIFF-SCOPED
3
3
  # (verify-diff / hook) until a repo's useStore migration campaign lands;
4
4
  # whole-tree `verify` output will be loud there by design, not by accident.
5
5
  # ── simple-components, rule 1 of 4 — the .tsx half ─────────────────────
@@ -17,7 +17,7 @@ ignores:
17
17
  - '**/*.spec.tsx'
18
18
  - '**/__tests__/**'
19
19
  message: |
20
- A store reached through React context. Decision D1: MobX already gives every
20
+ A store reached through React context. Rule: MobX already gives every
21
21
  component a live channel to the data — a second one buys nothing and costs a
22
22
  provider, a null-check and a hook on every file that reads state.
23
23
  Do instead:
@@ -29,7 +29,7 @@ message: |
29
29
  - everything below a screen receives `model={...}` as a prop.
30
30
  Tests stop needing a provider at all: `new XxxStore(fakeDeps)` directly, and
31
31
  `*.view.tsx` files mount with nothing around them.
32
- See the simple-components skill (§store access) and report §8.
32
+ See the simple-components skill (§store access).
33
33
  rule:
34
34
  any:
35
35
  - all:
@@ -1,15 +1,15 @@
1
1
  # ADOPTION NOTE (canon promotion): brownfield-heavy — ~48-105 whole-tree hits
2
- # per useStore-era repo (tg-gallery/observatory/ppa). Run it DIFF-SCOPED
2
+ # per useStore-era repo (three consumer apps). Run it DIFF-SCOPED
3
3
  # (verify-diff / hook) until a repo's useStore migration campaign lands;
4
4
  # whole-tree `verify` output will be loud there by design, not by accident.
5
5
  # ── simple-components, rule 1 of 4 ─────────────────────────────────────
6
6
  #
7
- # Decision D1: a MobX project has NO store context. One module-level `rootStore`,
7
+ # Rule: a MobX project has NO store context. One module-level `rootStore`,
8
8
  # imported at screen level only; everything below gets models through props.
9
9
  #
10
10
  # The canon rule `direct-store-import` covers the other half — where a store
11
11
  # import is legal. Nothing in the canon bans the context CHANNEL itself, which is
12
- # what this rule is for. Audit basis (report §8): all four store-bearing apps
12
+ # what this rule is for. Audit basis: all four store-bearing apps
13
13
  # route through a `useStore()` context hook (215/97/69/46 call sites) and not one
14
14
  # of them uses it for anything context is needed for: in one of them the provider
15
15
  # hands out a module-level singleton unconditionally, and its own tests bypass
@@ -27,7 +27,7 @@ ignores:
27
27
  - '**/*.spec.ts'
28
28
  - '**/__tests__/**'
29
29
  message: |
30
- A store reached through React context. Decision D1: MobX already gives every
30
+ A store reached through React context. Rule: MobX already gives every
31
31
  component a live channel to the data — a second one buys nothing and costs a
32
32
  provider, a null-check and a hook on every file that reads state.
33
33
  Do instead:
@@ -39,7 +39,7 @@ message: |
39
39
  - everything below a screen receives `model={...}` as a prop.
40
40
  Tests stop needing a provider at all: `new XxxStore(fakeDeps)` directly, and
41
41
  `*.view.tsx` files mount with nothing around them.
42
- See the simple-components skill (§store access) and report §8.
42
+ See the simple-components skill (§store access).
43
43
  rule:
44
44
  any:
45
45
  # `useStore()` — the call...
@@ -19,10 +19,10 @@
19
19
  # THE NEGATIVE IS THE WHOLE DESIGN OF THIS RULE. The identical shape,
20
20
  # `return this.data.x`, is the house data-wrapper pattern and is completely
21
21
  # legal: a `Model` class holding a plain record and exposing its fields as
22
- # observable getters. Measured across SiteCraft, observatory, byok and metro,
22
+ # observable getters. Measured across four consumer repos,
23
23
  # single-line `return this.X.y` getters break down as:
24
24
  #
25
- # 89 × this.data.* byok Model, metro domain stores — LEGAL
25
+ # 89 × this.data.* a model class, domain stores — LEGAL
26
26
  # 2 × this.connectionStore.* — the real store→store alias
27
27
  #
28
28
  # So the discriminator is the intermediate NAME, and the rule matches only
@@ -8,10 +8,10 @@
8
8
  # THE NEGATIVE IS THE WHOLE DESIGN OF THIS RULE. The identical shape,
9
9
  # `return this.data.x`, is the house data-wrapper pattern and is completely
10
10
  # legal: a `Model` class holding a plain record and exposing its fields as
11
- # observable getters. Measured across SiteCraft, observatory, byok and metro,
11
+ # observable getters. Measured across four consumer repos,
12
12
  # single-line `return this.X.y` getters break down as:
13
13
  #
14
- # 89 × this.data.* byok Model, metro domain stores — LEGAL
14
+ # 89 × this.data.* a model class, domain stores — LEGAL
15
15
  # 2 × this.connectionStore.* — the real store→store alias
16
16
  #
17
17
  # So the discriminator is the intermediate NAME, and the rule matches only
@@ -24,7 +24,7 @@
24
24
  #
25
25
  # Note the callee is matched as an identifier rather than with
26
26
  # `pattern: makeAutoObservable($$$)`. A pattern does not match a call carrying
27
- # explicit type arguments, and SiteCraft writes
27
+ # explicit type arguments, and a site-builder repo writes
28
28
  # `makeAutoObservable<this, '_buildTimer' | 'buildManager'>(this, {…})` — which
29
29
  # silently cost the whole of project.store.ts, 7 real call sites, until the
30
30
  # count came up short against the grep.
@@ -33,7 +33,7 @@ language: tsx
33
33
  severity: error
34
34
  ignores:
35
35
  # A test may drive a store's state directly to set up a scenario; that is the
36
- # sanctioned way to test a store without a render. All 6 of tg-gallery's
36
+ # sanctioned way to test a store without a render. All 6 of a gallery app's
37
37
  # runInAction sites are tests, which is why the report counts it as 0.
38
38
  - '**/*.test.tsx'
39
39
  - '**/*.spec.tsx'
@@ -13,7 +13,7 @@
13
13
  #
14
14
  # Note the callee is matched as an identifier rather than with
15
15
  # `pattern: makeAutoObservable($$$)`. A pattern does not match a call carrying
16
- # explicit type arguments, and SiteCraft writes
16
+ # explicit type arguments, and a site-builder repo writes
17
17
  # `makeAutoObservable<this, '_buildTimer' | 'buildManager'>(this, {…})` — which
18
18
  # silently cost the whole of project.store.ts, 7 real call sites, until the
19
19
  # count came up short against the grep.
@@ -22,7 +22,7 @@ language: typescript
22
22
  severity: error
23
23
  ignores:
24
24
  # A test may drive a store's state directly to set up a scenario; that is the
25
- # sanctioned way to test a store without a render. All 6 of tg-gallery's
25
+ # sanctioned way to test a store without a render. All 6 of a gallery app's
26
26
  # runInAction sites are tests, which is why the report counts it as 0.
27
27
  - '**/*.test.ts'
28
28
  - '**/*.spec.ts'
@@ -49,7 +49,7 @@ message: |
49
49
  with progress and no notion of revalidation) legitimately ticks on a timer.
50
50
  There is no manifest glob for that yet, so mark those with a reason:
51
51
  // ast-grep-ignore: store-no-setinterval-poll -- progress tick for a render job
52
- See report §14 and the mobx-models skill.
52
+ See the mobx-models skill.
53
53
  rule:
54
54
  all:
55
55
  - kind: call_expression
@@ -38,7 +38,7 @@ message: |
38
38
  with progress and no notion of revalidation) legitimately ticks on a timer.
39
39
  There is no manifest glob for that yet, so mark those with a reason:
40
40
  // ast-grep-ignore: store-no-setinterval-poll -- progress tick for a render job
41
- See report §14 and the mobx-models skill.
41
+ See the mobx-models skill.
42
42
  rule:
43
43
  all:
44
44
  - kind: call_expression
@@ -1,10 +1,10 @@
1
- # PROMOTED to canon in wave 2 from faceless-photo-lib/.ast-grep (rule-triage).
1
+ # PROMOTED to canon in wave 2 from a consumer repo's .ast-grep (rule-triage).
2
2
  # No canon equivalent existed: `non-exhaustive-match` is about PREFERRING
3
- # `.exhaustive()` over `.otherwise()`, which is a style call the owner has
4
- # explicitly deferred (decision #4). This is the different, non-negotiable
3
+ # `.exhaustive()` over `.otherwise()`, which is a style question
4
+ # that is deliberately left open. This is the different, non-negotiable
5
5
  # half — a chain with NO terminator evaluates to a builder object, so every
6
6
  # arm body is dead code and the truthy builder keeps the caller compiling.
7
- # Verified on real code: took a terminated chain out of observatory, deleted
7
+ # Verified on real code: took a terminated chain out of a consumer app, deleted
8
8
  # `.exhaustive()` -> fires; left it -> silent; a dangling chain nested in a
9
9
  # callback of an OUTER terminated chain -> fires on the inner one only;
10
10
  # `"abc".match(/b/)` -> silent.
@@ -1,10 +1,10 @@
1
- # PROMOTED to canon in wave 2 from faceless-photo-lib/.ast-grep (rule-triage).
1
+ # PROMOTED to canon in wave 2 from a consumer repo's .ast-grep (rule-triage).
2
2
  # No canon equivalent existed: `non-exhaustive-match` is about PREFERRING
3
- # `.exhaustive()` over `.otherwise()`, which is a style call the owner has
4
- # explicitly deferred (decision #4). This is the different, non-negotiable
3
+ # `.exhaustive()` over `.otherwise()`, which is a style question
4
+ # that is deliberately left open. This is the different, non-negotiable
5
5
  # half — a chain with NO terminator evaluates to a builder object, so every
6
6
  # arm body is dead code and the truthy builder keeps the caller compiling.
7
- # Verified on real code: took a terminated chain out of observatory, deleted
7
+ # Verified on real code: took a terminated chain out of a consumer app, deleted
8
8
  # `.exhaustive()` -> fires; left it -> silent; a dangling chain nested in a
9
9
  # callback of an OUTER terminated chain -> fires on the inner one only;
10
10
  # `"abc".match(/b/)` -> silent.
@@ -0,0 +1,61 @@
1
+ # ── the .ts half of `ui-imports-app-store` ──────────────────────────────────────────────
2
+ #
3
+ # `ui-imports-app-store` is `language: tsx`, so it reads `.tsx` and never `.ts` — ast-grep's
4
+ # languages are disjoint. What it matches needs no JSX, so it can sit in a plain
5
+ # `.ts` file just as well. The `.ts` twin closes that gap.
6
+ #
7
+ # Keep this file's `severity`, `files`, `ignores`, `utils` and `rule:`
8
+ # blocks IDENTICAL to `ui-imports-app-store.yml` (`.tsx` globs spelled `.ts`);
9
+ # `pnpm test:twins` fails when they drift.
10
+ #
11
+ id: ui-imports-app-store-ts
12
+ language: typescript
13
+ severity: error
14
+ message: |
15
+ A reusable UI component importing an app store. The moment it knows where the
16
+ data comes from it stops being reusable — and the boundary is the whole point:
17
+ a UI component consumes an interface (props, or a view-model interface the
18
+ store implements), never the store itself.
19
+ Take the values as props and let the app component do the reading. See the
20
+ ui-components skill.
21
+ Suppressing this one needs the id you see above — `ast-grep-ignore: ui-imports-app-store-ts`.
22
+ `ui-imports-app-store` is a DIFFERENT rule (the .tsx arm) and does not cover it.
23
+ files:
24
+ - '**/packages/ui/**'
25
+ - '**/components/ui/**'
26
+ - '**/src/ui/**'
27
+ utils:
28
+ # A type-only import: erased at build time, so it creates no dependency on the
29
+ # store — only on its shape. Covers all four spellings TypeScript allows.
30
+ type-only-import:
31
+ any:
32
+ - pattern: import type { $$$S } from $SRC
33
+ - pattern: import type $D from $SRC
34
+ - pattern: import type * as $NS from $SRC
35
+ # `import { type A, type B }` — every named specifier inline-typed.
36
+ - all:
37
+ - kind: import_statement
38
+ - has:
39
+ stopBy: end
40
+ kind: named_imports
41
+ - not:
42
+ has:
43
+ stopBy: end
44
+ all:
45
+ - kind: import_specifier
46
+ - not:
47
+ regex: '^type\s'
48
+ rule:
49
+ all:
50
+ - kind: import_statement
51
+ - has:
52
+ stopBy: end
53
+ kind: string_fragment
54
+ regex: '(^|/)stores?(/|$)'
55
+ # The view-model pattern this rule exists to protect tells a
56
+ # UI component to type itself against `IXxxModel` — which lives in the store
57
+ # module. Firing at `error` on that import made the rule contradict the
58
+ # pattern it enforces, so a compliant component could not be written without
59
+ # a suppression comment. A type import is the compliant shape, not a breach.
60
+ - not:
61
+ matches: type-only-import
@@ -40,7 +40,7 @@ rule:
40
40
  stopBy: end
41
41
  kind: string_fragment
42
42
  regex: '(^|/)stores?(/|$)'
43
- # X7 (report §2): the view-model pattern this rule exists to protect tells a
43
+ # The view-model pattern this rule exists to protect tells a
44
44
  # UI component to type itself against `IXxxModel` — which lives in the store
45
45
  # module. Firing at `error` on that import made the rule contradict the
46
46
  # pattern it enforces, so a compliant component could not be written without
@@ -1,18 +1,18 @@
1
1
  # ── simple-components, rule 3 of 4 ─────────────────────────────────────
2
2
  #
3
- # The view half of the two-tier split (decision D8, report §9): a `*.view.tsx`
3
+ # The view half of the two-tier split: a `*.view.tsx`
4
4
  # is props in, JSX out. No hooks, no `match`, no ternary, no data transformation.
5
5
  # That contract is what makes a view the file a cheap model writes without
6
6
  # getting it wrong, and what lets its test mount it with nothing around it.
7
7
  #
8
- # WARNING TIER ON PURPOSE. D8 ships the split as a recommendation first, with a
8
+ # WARNING TIER ON PURPOSE. The two-tier split ships as a recommendation first, with a
9
9
  # ratchet on the share of view files — not as a hard gate. Raising this to error
10
- # would decide a question the owner deliberately parked. The store half of the
10
+ # would decide a question that is deliberately left open. The store half of the
11
11
  # same contract is the canon's `view-imports-store` (error), which is a narrower
12
12
  # claim: no store access anywhere in the app's view files.
13
13
  #
14
14
  # `useTheme` / `useTokens` / `useStyles` / `useColorScheme` are exempt: the house
15
- # styling idiom is RN inline objects read from a theme hook (report §10), so
15
+ # styling idiom is RN inline objects read from a theme hook, so
16
16
  # banning that hook would ban styling from the file that owns styling.
17
17
  id: view-file-logic
18
18
  language: tsx
@@ -28,7 +28,7 @@ message: |
28
28
  is the same branch, laundered.
29
29
  Exempt: `useTheme` / `useTokens` / `useStyles` / `useColorScheme` — styling is
30
30
  what a view owns.
31
- See the simple-components skill (§two-tier) and report §9.
31
+ See the simple-components skill (§two-tier).
32
32
  rule:
33
33
  any:
34
34
  # Any hook call that is not a styling hook.
@@ -6,16 +6,15 @@
6
6
  #
7
7
  # Report §9 fixes the view contract as props → JSX and nothing else: no hooks, no
8
8
  # `match`, no data transformation, no store. That is stricter than the rest of
9
- # `.tsx`, where decision D1 makes a `rootStore` import legal at screen level — a
9
+ # `.tsx`, where the house store layout makes a `rootStore` import legal at screen level — a
10
10
  # view is never a screen, so `rootStore` is banned here too, and so is `useStore`.
11
11
  #
12
- # The only store-path import a view may keep is a type: C40 has the view take
12
+ # The only store-path import a view may keep is a type: the view-model contract has the view take
13
13
  # `model={store}` typed by `IXxxModel`, which lives in the store module and
14
14
  # erases at build time.
15
15
  #
16
16
  # Expected hit count today: zero. `*.view.tsx` does not exist anywhere in the
17
- # park yet (the two-tier split ships as a recommendation first, report §9 /
18
- # decision #8). This is a guardrail waiting at the convention's door, not a
17
+ # park yet (the two-tier split ships as a recommendation first, see the simple-components skill). This is a guardrail waiting at the convention's door, not a
19
18
  # finding about current code.
20
19
  id: view-imports-store
21
20
  language: tsx
@@ -49,7 +48,7 @@ message: |
49
48
  Unlike the rest of the app, the global `rootStore` is not an exception here:
50
49
  a view is never a screen.
51
50
  `import type { IXxxModel }` IS allowed — typing the view against the model
52
- interface it renders is the prescribed shape (C40). See report §9 and the
51
+ interface it renders is the prescribed shape. See the
53
52
  mobx-components skill.
54
53
  rule:
55
54
  all:
@@ -1,5 +1,5 @@
1
- # ── rule body adopted from faceless-photo-lib `zod-no-optional-nullable` (wave 2 triage) ──
2
- # The two rules were duplicates; the faceless implementation is strictly better,
1
+ # ── rule body adopted from a consumer repo's `zod-no-optional-nullable` (wave 2 triage) ──
2
+ # The two rules were duplicates; the consumer's implementation is strictly better,
3
3
  # so the canon id keeps its message and takes that body. Why it is better here:
4
4
  # `z.$T().optional()` only matched a DIRECT call on `z` — it missed both
5
5
  # `UserSchema.optional()` and any chained builder (`z.string().min(1).optional()`).
@@ -1,5 +1,5 @@
1
- # ── rule body adopted from faceless-photo-lib `zod-no-optional-nullable` (wave 2 triage) ──
2
- # The two rules were duplicates; the faceless implementation is strictly better,
1
+ # ── rule body adopted from a consumer repo's `zod-no-optional-nullable` (wave 2 triage) ──
2
+ # The two rules were duplicates; the consumer's implementation is strictly better,
3
3
  # so the canon id keeps its message and takes that body. Why it is better here:
4
4
  # `z.$T().optional()` only matched a DIRECT call on `z` — it missed both
5
5
  # `UserSchema.optional()` and any chained builder (`z.string().min(1).optional()`).
@@ -4,7 +4,7 @@ severity: info
4
4
  # Same out-of-scope surface every canon rule declares: tests, stories, and
5
5
  # showcase files are legitimate multi-component / oversized territory (a
6
6
  # showcase screen IS a bundle of demo components). Found by the first real
7
- # adoption (observatory): without this, a reformat touching a showcase file's
7
+ # adoption (a consumer app): without this, a reformat touching a showcase file's
8
8
  # declaration lines turned the verify-diff ratchet red on fixture code.
9
9
  # Metrics already excluded these paths on its own; now the structure findings
10
10
  # agree with it.