@agentvibes/guardrails 0.2.8 → 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.
- package/README.md +252 -5
- package/candidates/README.md +13 -13
- package/candidates/r10-as-cast.yml +4 -4
- package/candidates/r1d-scattered-numeric-const-in-component.yml +3 -3
- package/candidates/r2-helper-fn-in-tsx.yml +3 -3
- package/candidates/r3-hooks-outside-layout.yml +4 -4
- package/candidates/r6-jsx-comment-smell.yml +2 -2
- package/candidates/r7-raw-hsl-outside-tokens.yml +3 -3
- package/candidates/r8-inline-style-prop.yml +2 -2
- package/candidates/r9-optional-store-arg.yml +2 -2
- package/dist/astGrep.js +4 -2
- package/dist/astGrep.js.map +1 -1
- package/dist/cli.js +89 -6
- package/dist/cli.js.map +1 -1
- package/dist/cliArgsTest.d.ts +1 -0
- package/dist/cliArgsTest.js +44 -0
- package/dist/cliArgsTest.js.map +1 -0
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.js +58 -6
- package/dist/doctor.js.map +1 -1
- package/dist/fileSloc.d.ts +28 -0
- package/dist/fileSloc.js +72 -0
- package/dist/fileSloc.js.map +1 -0
- package/dist/fileSlocBaseline.d.ts +78 -0
- package/dist/fileSlocBaseline.js +173 -0
- package/dist/fileSlocBaseline.js.map +1 -0
- package/dist/fileSlocGate.d.ts +17 -0
- package/dist/fileSlocGate.js +75 -0
- package/dist/fileSlocGate.js.map +1 -0
- package/dist/fileSlocTest.d.ts +1 -0
- package/dist/fileSlocTest.js +172 -0
- package/dist/fileSlocTest.js.map +1 -0
- package/dist/fileWalk.js +1 -1
- package/dist/fileWalk.js.map +1 -1
- package/dist/findings.d.ts +1 -1
- package/dist/gateRed.d.ts +1 -1
- package/dist/gateRed.js +1 -0
- package/dist/gateRed.js.map +1 -1
- package/dist/gitDiff.d.ts +6 -0
- package/dist/gitDiff.js +25 -0
- package/dist/gitDiff.js.map +1 -1
- package/dist/hookStop.d.ts +2 -1
- package/dist/hookStop.js +7 -1
- package/dist/hookStop.js.map +1 -1
- package/dist/hookStopTest.d.ts +1 -1
- package/dist/hookStopTest.js +1 -0
- package/dist/hookStopTest.js.map +1 -1
- package/dist/init.js +1 -1
- package/dist/init.js.map +1 -1
- package/dist/initTest.d.ts +1 -1
- package/dist/initTest.js +2 -1
- package/dist/initTest.js.map +1 -1
- package/dist/iterateTest.d.ts +1 -1
- package/dist/iterateTest.js +1 -0
- package/dist/iterateTest.js.map +1 -1
- package/dist/jsxSuppress.js +1 -1
- package/dist/jsxSuppress.js.map +1 -1
- package/dist/jsxSuppressTest.d.ts +1 -1
- package/dist/jsxSuppressTest.js +4 -2
- package/dist/jsxSuppressTest.js.map +1 -1
- package/dist/leaksRed.d.ts +1 -1
- package/dist/leaksRed.js +1 -0
- package/dist/leaksRed.js.map +1 -1
- package/dist/metrics.d.ts +9 -0
- package/dist/metrics.js +96 -7
- package/dist/metrics.js.map +1 -1
- package/dist/metricsBaseline.js +1 -1
- package/dist/metricsBaseline.js.map +1 -1
- package/dist/metricsCollect.js +2 -45
- package/dist/metricsCollect.js.map +1 -1
- package/dist/metricsCycle.d.ts +1 -1
- package/dist/metricsCycle.js +1 -0
- package/dist/metricsCycle.js.map +1 -1
- package/dist/metricsTypes.d.ts +1 -1
- package/dist/overrideDeclarations.d.ts +35 -0
- package/dist/overrideDeclarations.js +94 -0
- package/dist/overrideDeclarations.js.map +1 -0
- package/dist/overrides.d.ts +35 -0
- package/dist/overrides.js +284 -0
- package/dist/overrides.js.map +1 -0
- package/dist/overridesTest.d.ts +1 -0
- package/dist/overridesTest.js +183 -0
- package/dist/overridesTest.js.map +1 -0
- package/dist/pipeOutputTest.d.ts +1 -1
- package/dist/pipeOutputTest.js +2 -1
- package/dist/pipeOutputTest.js.map +1 -1
- package/dist/presetDrift.d.ts +8 -0
- package/dist/presetDrift.js +91 -34
- package/dist/presetDrift.js.map +1 -1
- package/dist/presetDriftTest.d.ts +1 -1
- package/dist/presetDriftTest.js +3 -3
- package/dist/presetDriftTest.js.map +1 -1
- package/dist/record/config.d.ts +17 -0
- package/dist/record/config.js +83 -0
- package/dist/record/config.js.map +1 -0
- package/dist/record/index.d.ts +69 -0
- package/dist/record/index.js +8 -0
- package/dist/record/index.js.map +1 -0
- package/dist/record/record.d.ts +56 -0
- package/dist/record/record.js +111 -0
- package/dist/record/record.js.map +1 -0
- package/dist/record/repoKey.d.ts +8 -0
- package/dist/record/repoKey.js +70 -0
- package/dist/record/repoKey.js.map +1 -0
- package/dist/record/repoMetrics.d.ts +14 -0
- package/dist/record/repoMetrics.js +124 -0
- package/dist/record/repoMetrics.js.map +1 -0
- package/dist/record/runRecord.d.ts +60 -0
- package/dist/record/runRecord.js +2 -0
- package/dist/record/runRecord.js.map +1 -0
- package/dist/record/schema.d.ts +31 -0
- package/dist/record/schema.js +201 -0
- package/dist/record/schema.js.map +1 -0
- package/dist/record/writer.d.ts +22 -0
- package/dist/record/writer.js +341 -0
- package/dist/record/writer.js.map +1 -0
- package/dist/recordTest.d.ts +1 -0
- package/dist/recordTest.js +422 -0
- package/dist/recordTest.js.map +1 -0
- package/dist/renameDiffTest.d.ts +1 -1
- package/dist/renameDiffTest.js +2 -1
- package/dist/renameDiffTest.js.map +1 -1
- package/dist/repoRules.js +1 -1
- package/dist/repoRules.js.map +1 -1
- package/dist/repoRulesTest.d.ts +1 -1
- package/dist/repoRulesTest.js +2 -1
- package/dist/repoRulesTest.js.map +1 -1
- package/dist/screenScope.js +4 -5
- package/dist/screenScope.js.map +1 -1
- package/dist/screenScopeTest.d.ts +1 -1
- package/dist/screenScopeTest.js +2 -1
- package/dist/screenScopeTest.js.map +1 -1
- package/dist/severityTest.d.ts +1 -1
- package/dist/severityTest.js +1 -0
- package/dist/severityTest.js.map +1 -1
- package/dist/siblingCloneTest.js +12 -12
- package/dist/siblingCloneTest.js.map +1 -1
- package/dist/snapshot.d.ts +2 -0
- package/dist/snapshot.js +118 -0
- package/dist/snapshot.js.map +1 -0
- package/dist/snapshotTest.d.ts +1 -0
- package/dist/snapshotTest.js +194 -0
- package/dist/snapshotTest.js.map +1 -0
- package/dist/structure.js +2 -2
- package/dist/structure.js.map +1 -1
- package/dist/testIsolation.d.ts +1 -0
- package/dist/testIsolation.js +7 -0
- package/dist/testIsolation.js.map +1 -0
- package/dist/testPaths.d.ts +4 -0
- package/dist/testPaths.js +9 -0
- package/dist/testPaths.js.map +1 -0
- package/dist/testRules.js +3 -3
- package/dist/testRules.js.map +1 -1
- package/dist/time.d.ts +22 -0
- package/dist/time.js +77 -0
- package/dist/time.js.map +1 -0
- package/dist/timeTest.d.ts +1 -0
- package/dist/timeTest.js +103 -0
- package/dist/timeTest.js.map +1 -0
- package/dist/tomlTable.d.ts +1 -1
- package/dist/tomlTable.js +6 -3
- package/dist/tomlTable.js.map +1 -1
- package/dist/toolResolve.d.ts +6 -0
- package/dist/toolResolve.js +18 -0
- package/dist/toolResolve.js.map +1 -1
- package/dist/twinCoverageTest.js +1 -2
- package/dist/twinCoverageTest.js.map +1 -1
- package/dist/verify.d.ts +2 -1
- package/dist/verify.js +33 -5
- package/dist/verify.js.map +1 -1
- package/dist/verifyDiff.d.ts +3 -2
- package/dist/verifyDiff.js +58 -8
- package/dist/verifyDiff.js.map +1 -1
- package/dist/wiring.d.ts +31 -0
- package/dist/wiring.js +262 -0
- package/dist/wiring.js.map +1 -0
- package/dist/wiringTest.d.ts +1 -0
- package/dist/wiringTest.js +127 -0
- package/dist/wiringTest.js.map +1 -0
- package/package.json +18 -6
- package/rules/__fixtures__/demo-mode-by-default/bad.ts +1 -1
- package/rules/__fixtures__/demo-mode-by-default/bad.tsx +1 -1
- package/rules/__fixtures__/direct-store-import/bad.tsx +1 -1
- package/rules/__fixtures__/direct-store-import/good.tsx +2 -2
- package/rules/__fixtures__/discriminator-ternary/bad.tsx +1 -1
- package/rules/__fixtures__/discriminator-ternary/good.tsx +1 -1
- package/rules/__fixtures__/inline-map-row/bad.tsx +1 -1
- package/rules/__fixtures__/inline-map-row/good.tsx +1 -1
- package/rules/__fixtures__/missing-observer/bad.tsx +2 -2
- package/rules/__fixtures__/missing-observer/good.tsx +2 -2
- package/rules/__fixtures__/no-local-kit-clone/bad.ts +2 -2
- package/rules/__fixtures__/no-local-kit-clone/bad.tsx +2 -2
- package/rules/__fixtures__/state-loading-boolean-shape/good.ts +1 -1
- package/rules/__fixtures__/state-loading-boolean-shape/good.tsx +1 -1
- package/rules/__fixtures__/store-async-method/good.ts +1 -1
- package/rules/__fixtures__/store-async-method/good.tsx +1 -1
- package/rules/__fixtures__/store-context-provider/bad.ts +1 -1
- package/rules/__fixtures__/store-delegation-getter/bad.ts +1 -1
- package/rules/__fixtures__/store-delegation-getter/bad.tsx +1 -1
- package/rules/__fixtures__/store-delegation-getter/good.ts +3 -3
- package/rules/__fixtures__/store-delegation-getter/good.tsx +3 -3
- package/rules/__fixtures__/store-no-runinaction/bad.ts +1 -1
- package/rules/__fixtures__/store-no-runinaction/bad.tsx +1 -1
- package/rules/__fixtures__/store-no-runinaction/good.ts +1 -1
- package/rules/__fixtures__/store-no-runinaction/good.tsx +1 -1
- package/rules/__fixtures__/ts-pattern-dangling-match/bad.ts +1 -1
- package/rules/__fixtures__/ts-pattern-dangling-match/good.ts +2 -2
- package/rules/__fixtures__/ui-imports-app-store/src/ui/good.tsx +1 -1
- package/rules/__fixtures__/view-imports-store/good.view.tsx +1 -1
- package/rules/as-any-escape-tsx.yml +2 -2
- package/rules/as-any-escape.yml +2 -2
- package/rules/catch-empty-tsx.yml +3 -3
- package/rules/catch-empty.yml +3 -3
- package/rules/demo-mode-by-default-ts.yml +6 -7
- package/rules/demo-mode-by-default.yml +6 -7
- package/rules/direct-store-import.yml +15 -16
- package/rules/discriminator-ternary-ts.yml +1 -1
- package/rules/discriminator-ternary.yml +3 -3
- package/rules/hardcoded-url-in-component-ts.yml +1 -1
- package/rules/hardcoded-url-in-component.yml +5 -5
- package/rules/inline-map-row.yml +7 -7
- package/rules/instanceof-map-set-tsx.yml +2 -2
- package/rules/instanceof-map-set.yml +2 -2
- package/rules/kind-if-without-match-tsx.yml +1 -1
- package/rules/literal-union-in-component-tsx.yml +2 -2
- package/rules/literal-union-in-component.yml +7 -7
- package/rules/match-bool-to-null-ts.yml +1 -1
- package/rules/missing-observer.yml +5 -5
- package/rules/no-local-kit-clone-tsx.yml +2 -2
- package/rules/no-local-kit-clone.yml +2 -2
- package/rules/non-exhaustive-match-tsx.yml +4 -7
- package/rules/non-exhaustive-match.yml +2 -2
- package/rules/page-store-bare-usememo-tsx.yml +1 -1
- package/rules/page-store-bare-usememo.yml +1 -1
- package/rules/screen-file-styling.yml +3 -3
- package/rules/silent-default-return-tsx.yml +1 -1
- package/rules/store-async-method-tsx.yml +1 -1
- package/rules/store-async-method.yml +1 -1
- package/rules/store-context-provider-tsx.yml +3 -3
- package/rules/store-context-provider.yml +5 -5
- package/rules/store-delegation-getter-tsx.yml +2 -2
- package/rules/store-delegation-getter.yml +2 -2
- package/rules/store-no-runinaction-tsx.yml +2 -2
- package/rules/store-no-runinaction.yml +2 -2
- package/rules/store-no-setinterval-poll-tsx.yml +1 -1
- package/rules/store-no-setinterval-poll.yml +1 -1
- package/rules/ts-pattern-dangling-match-tsx.yml +4 -4
- package/rules/ts-pattern-dangling-match.yml +4 -4
- package/rules/ui-imports-app-store-ts.yml +2 -2
- package/rules/ui-imports-app-store.yml +1 -1
- package/rules/view-file-logic.yml +5 -5
- package/rules/view-imports-store.yml +4 -5
- package/rules/zod-optional-nullable-tsx.yml +2 -2
- package/rules/zod-optional-nullable.yml +2 -2
- package/structure/rules/component-decl.yml +1 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# `discriminator-ternary` is `language: tsx`, so it reads `.tsx` and never `.ts` — ast-grep's
|
|
4
4
|
# languages are disjoint. What it matches needs no JSX, so it can sit in a plain
|
|
5
|
-
# `.ts` file just as well.
|
|
5
|
+
# `.ts` file just as well. The `.ts` twin closes that gap.
|
|
6
6
|
#
|
|
7
7
|
# Keep this file's `severity`, `files`, `ignores`, `utils` and `rule:`
|
|
8
8
|
# blocks IDENTICAL to `discriminator-ternary.yml` (`.tsx` globs spelled `.ts`),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# PROMOTED to canon in wave 2 from
|
|
1
|
+
# PROMOTED to canon in wave 2 from the source app `r4-ternary-on-discriminator` (rule-triage).
|
|
2
2
|
#
|
|
3
|
-
# The only one of the 11
|
|
3
|
+
# The only one of the 11 source-app R-rules that was actually firing (18 hits in the
|
|
4
4
|
# audit), and the triage question was whether it duplicates something canon
|
|
5
|
-
# already has. Measured on
|
|
5
|
+
# already has. Measured on two consumer apps, it does not — the three
|
|
6
6
|
# rules partition the space cleanly:
|
|
7
7
|
#
|
|
8
8
|
# kind-if-without-match 27 hits `if` on a discriminator
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# `hardcoded-url-in-component` is `language: tsx`, so it reads `.tsx` and never `.ts` — ast-grep's
|
|
4
4
|
# languages are disjoint. What it matches needs no JSX, so it can sit in a plain
|
|
5
|
-
# `.ts` file just as well.
|
|
5
|
+
# `.ts` file just as well. The `.ts` twin closes that gap.
|
|
6
6
|
#
|
|
7
7
|
# Keep this file's `severity`, `files`, `ignores`, `utils` and `rule:`
|
|
8
8
|
# blocks IDENTICAL to `hardcoded-url-in-component.yml` (`.tsx` globs spelled `.ts`);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# PROMOTED to canon in wave 2 from
|
|
1
|
+
# PROMOTED to canon in wave 2 from the source app `r1a-hardcoded-url-in-component` (rule-triage).
|
|
2
2
|
#
|
|
3
3
|
# Promoted because it enforces a rule that is already house-wide rather than
|
|
4
|
-
#
|
|
4
|
+
# Source-app-local: the "No localhost" convention — every service URL comes from
|
|
5
5
|
# the dev CLI, never a literal, and the legacy proxy zone is retired for new
|
|
6
6
|
# code. A URL baked into a component is also the thing that
|
|
7
7
|
# makes a component un-reusable and un-testable, which is the same boundary
|
|
8
8
|
# `ui-imports-app-store` guards from the other side.
|
|
9
9
|
#
|
|
10
|
-
# Only 2 hits across
|
|
11
|
-
# rather than a cleanup campaign. The
|
|
12
|
-
# `apps
|
|
10
|
+
# Only 2 hits across two consumer apps — a clean ratchet on new code
|
|
11
|
+
# rather than a cleanup campaign. The source app original pointed at
|
|
12
|
+
# `apps/<app>/lib/constants/urls.ts`; the message below states the destination
|
|
13
13
|
# generically.
|
|
14
14
|
id: hardcoded-url-in-component
|
|
15
15
|
language: tsx
|
package/rules/inline-map-row.yml
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# ── G1, rule 2 of 3: per-row observer extraction ───────────────────────
|
|
2
2
|
#
|
|
3
|
-
# The MobX list rule
|
|
3
|
+
# The house MobX list rule: mapping an observable collection with the
|
|
4
4
|
# row body written inline makes the PARENT track every field every row reads, so
|
|
5
5
|
# one item's change invalidates the whole list. Extracting the row into its own
|
|
6
6
|
# `observer` component localises the invalidation.
|
|
7
7
|
#
|
|
8
8
|
# The report's audit found this rule already obeyed everywhere it looked (131
|
|
9
|
-
# `*Row.tsx` files in
|
|
9
|
+
# `*Row.tsx` files in one monorepo alone) — so it lands as a ratchet on new code, not
|
|
10
10
|
# as a cleanup campaign.
|
|
11
11
|
#
|
|
12
12
|
# Threshold: the mapped element must contain TWO OR MORE nested JSX elements
|
|
@@ -44,7 +44,7 @@ message: |
|
|
|
44
44
|
Extract the body into its own `observer` component and pass the item down:
|
|
45
45
|
{items.map(t => <TaskRow key={t.id} task={t} />)}
|
|
46
46
|
The parent then re-renders only on insert, remove and reorder; each row
|
|
47
|
-
re-renders on its own fields. See
|
|
47
|
+
re-renders on its own fields. See the house "MobX lists" convention and the
|
|
48
48
|
mobx-components skill.
|
|
49
49
|
Doesn't apply when the mapped children are pure data — constants or plain
|
|
50
50
|
props rather than observables.
|
|
@@ -74,11 +74,11 @@ rule:
|
|
|
74
74
|
# convenience — it is the rule's own rationale made into its scope: the
|
|
75
75
|
# defect is that the PARENT'S reactive scope tracks every field every row
|
|
76
76
|
# reads, and a component with no reactive scope has no such defect. It is
|
|
77
|
-
# also the only syntactically decidable form of
|
|
77
|
+
# also the only syntactically decidable form of the house carve-out
|
|
78
78
|
# ("when the rendered children are pure data … the rule doesn't apply").
|
|
79
79
|
#
|
|
80
80
|
# Measured, not assumed: without this clause the rule fired 50 times in
|
|
81
|
-
#
|
|
81
|
+
# a UI library and its examples/docs site, which
|
|
82
82
|
# contain no MobX whatsoever — where every hit was a false positive at
|
|
83
83
|
# `error` severity. With it, 0 there.
|
|
84
84
|
#
|
|
@@ -94,10 +94,10 @@ rule:
|
|
|
94
94
|
- inside:
|
|
95
95
|
stopBy: end
|
|
96
96
|
kind: jsx_expression
|
|
97
|
-
#
|
|
97
|
+
# The house convention's own carve-out: "When the rendered children are pure data
|
|
98
98
|
# (constants, plain props, not MobX observables), the rule doesn't
|
|
99
99
|
# apply." A literal array is the one case that is provably constant —
|
|
100
|
-
#
|
|
100
|
+
# a session-viewer app's SessionInfoSkeleton maps `[1, 2, 3, 4]` to draw four
|
|
101
101
|
# placeholder cards, which no amount of extraction improves.
|
|
102
102
|
- not:
|
|
103
103
|
has:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# ── rule body adopted from
|
|
2
|
-
# The two rules were duplicates; the
|
|
1
|
+
# ── rule body adopted from a consumer repo's `no-instanceof-map-set` (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
|
# the old patterns named only Map and Set; WeakMap and WeakSet have exactly the
|
|
5
5
|
# same cross-realm failure and were invisible.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# ── rule body adopted from
|
|
2
|
-
# The two rules were duplicates; the
|
|
1
|
+
# ── rule body adopted from a consumer repo's `no-instanceof-map-set` (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
|
# the old patterns named only Map and Set; WeakMap and WeakSet have exactly the
|
|
5
5
|
# same cross-realm failure and were invisible.
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
# way to say "both languages", so a twin id per language is the only option.
|
|
9
9
|
#
|
|
10
10
|
# Measured 2026-09-06 across the same five repos: 29 findings in `.tsx`
|
|
11
|
-
# (
|
|
11
|
+
# (per repo: 1, 2, 6, 2, 18).
|
|
12
12
|
# `if (x.kind === …)` branching lives in components at least as often as in
|
|
13
13
|
# plain modules, which is precisely where the union grows a variant unnoticed.
|
|
14
14
|
#
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
# way to say "both languages", so a twin id per language is the only option.
|
|
9
9
|
#
|
|
10
10
|
# Measured 2026-09-06 across the same five repos: 41 findings in `.tsx`
|
|
11
|
-
# (
|
|
11
|
+
# (per repo: 1, 7, 9, 6, 18).
|
|
12
12
|
# This twin restores intent rather than extending it: the `files:` globs below
|
|
13
13
|
# already list `**/components/**/*.tsx` and `**/screens/**/*.tsx`, and under
|
|
14
14
|
# `language: typescript` those three lines could never match anything. The rule
|
|
@@ -43,7 +43,7 @@ message: |
|
|
|
43
43
|
- a shared module as a typed constant + alias when it is purely lexical
|
|
44
44
|
(file kinds, palette names) with no state attached.
|
|
45
45
|
Component prop types then consume the shared type instead of restating it.
|
|
46
|
-
See the mobx-models skill
|
|
46
|
+
See the mobx-models skill.
|
|
47
47
|
Suppressing this one needs the id you see above — `ast-grep-ignore: literal-union-in-component-tsx`.
|
|
48
48
|
`literal-union-in-component` is a DIFFERENT rule (the .ts arm) and does not cover it.
|
|
49
49
|
rule:
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
# PROMOTED to canon in wave 2 from
|
|
1
|
+
# PROMOTED to canon in wave 2 from the source app `r14-literal-union-in-component` (rule-triage).
|
|
2
2
|
#
|
|
3
|
-
# Generic, not
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
# The
|
|
3
|
+
# Generic, not specific to the source app: the house store layout already states it:
|
|
4
|
+
# string-literal unions such as `type Tab = "tasks" | "habits"` may not live
|
|
5
|
+
# in component files of the `ui/` tier of the four-level model.
|
|
6
|
+
# The source app original hard-coded `apps/<app>/components/**` and `apps/<app>/app/**`;
|
|
7
7
|
# the globs below are the same intent stated for any repo.
|
|
8
8
|
#
|
|
9
|
-
# 23 hits across
|
|
9
|
+
# 23 hits across two consumer apps with the source app globs stripped, so it is
|
|
10
10
|
# a live rule elsewhere and not a local house style.
|
|
11
11
|
id: literal-union-in-component
|
|
12
12
|
language: typescript
|
|
@@ -35,7 +35,7 @@ message: |
|
|
|
35
35
|
- a shared module as a typed constant + alias when it is purely lexical
|
|
36
36
|
(file kinds, palette names) with no state attached.
|
|
37
37
|
Component prop types then consume the shared type instead of restating it.
|
|
38
|
-
See the mobx-models skill
|
|
38
|
+
See the mobx-models skill.
|
|
39
39
|
rule:
|
|
40
40
|
all:
|
|
41
41
|
- kind: type_alias_declaration
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# `match-bool-to-null` is `language: tsx`, so it reads `.tsx` and never `.ts` — ast-grep's
|
|
4
4
|
# languages are disjoint. What it matches needs no JSX, so it can sit in a plain
|
|
5
|
-
# `.ts` file just as well.
|
|
5
|
+
# `.ts` file just as well. The `.ts` twin closes that gap.
|
|
6
6
|
#
|
|
7
7
|
# Keep this file's `severity`, `files`, `ignores`, `utils` and `rule:`
|
|
8
8
|
# blocks IDENTICAL to `match-bool-to-null.yml` (`.tsx` globs spelled `.ts`);
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
#
|
|
27
27
|
# Known false-positive class, accepted at warning tier: a `use…Store` hook can
|
|
28
28
|
# return non-observable services next to the stores — `const { platform } =
|
|
29
|
-
# useStore()` in
|
|
29
|
+
# useStore()` in a gallery app's ShareButton pulls a platform adapter, and a
|
|
30
30
|
# component reading only that does not strictly need the wrap. Wrapping it is
|
|
31
31
|
# harmless; the rule does not distinguish.
|
|
32
32
|
id: missing-observer
|
|
@@ -55,7 +55,7 @@ utils:
|
|
|
55
55
|
# Every name a store hook can introduce, in the three spellings the park uses.
|
|
56
56
|
# Binding these is what lets the rule tell `ui.groupBy` (a plain `UIManifest`
|
|
57
57
|
# prop) apart from `uiStore.x` (the store) — without it the rule fires on any
|
|
58
|
-
# dotted value in the markup, which is how
|
|
58
|
+
# dotted value in the markup, which is how a session-viewer app's deliberately-plain
|
|
59
59
|
# `RichEntityListView` got flagged for rendering `groupBy={ui.groupBy}`.
|
|
60
60
|
store-binding:
|
|
61
61
|
any:
|
|
@@ -97,8 +97,8 @@ utils:
|
|
|
97
97
|
#
|
|
98
98
|
# Stated as an exclusion of the two deferred positions rather than as "appears
|
|
99
99
|
# inside JSX", because real components mostly do NOT dereference the store in
|
|
100
|
-
# the markup:
|
|
101
|
-
# themeStore.layout.type` and `match(galleryStore.detailState)`,
|
|
100
|
+
# the markup: a gallery app's GalleryView reads `const layoutType =
|
|
101
|
+
# themeStore.layout.type` and `match(galleryStore.detailState)`, a session-viewer app's
|
|
102
102
|
# SessionsTreeSection reads `data.sessions.filter(...)` — all render reads,
|
|
103
103
|
# none of them inside a JSX expression. An "inside JSX" test missed every one.
|
|
104
104
|
# The test is structural: a read sitting inside a NESTED function is deferred,
|
|
@@ -152,7 +152,7 @@ rule:
|
|
|
152
152
|
matches: jsx-node
|
|
153
153
|
# The component must RENDER a field off something the store gave it. Both
|
|
154
154
|
# halves matter: a component that pulls a store only to call an action from
|
|
155
|
-
# a handler needs no wrap (
|
|
155
|
+
# a handler needs no wrap (a session-viewer app writes two of those on purpose), and
|
|
156
156
|
# a dotted value in the markup means nothing unless the dotted thing came
|
|
157
157
|
# from a store. `$SLICE` ties the two clauses together.
|
|
158
158
|
- any:
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
# `Resource` must carry type parameters to match. Without that the rule hits
|
|
35
35
|
# `interface Resource { name; url; type; description }` in VolumePhotography — a
|
|
36
36
|
# page listing conference links, nothing to do with async state.
|
|
37
|
-
# CARVE-OUT 1 IS NOW A REPO DECLARATION, not only a glob
|
|
37
|
+
# CARVE-OUT 1 IS NOW A REPO DECLARATION, not only a glob.
|
|
38
38
|
# `@agentvibes/kit` exists since 2026-09 and lives in its own repo, where verify
|
|
39
39
|
# sees its files as `src/resource/resource.ts` — neither `**/packages/kit/**`
|
|
40
40
|
# nor `**/agentvibes-kit/**` matches that, and no path glob can tell that tree
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
# kit_source = "^src/"
|
|
45
45
|
#
|
|
46
46
|
# together with the `appliesTo: not-kit-source` marker below. Same mechanism
|
|
47
|
-
# `[verify] screens` uses
|
|
47
|
+
# `[verify] screens` uses: the repo states a fact about itself,
|
|
48
48
|
# the canon says which rules stand down for it. The globs stay for monorepos
|
|
49
49
|
# that vendor the kit under `packages/kit/`.
|
|
50
50
|
#
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
# `Resource` must carry type parameters to match. Without that the rule hits
|
|
24
24
|
# `interface Resource { name; url; type; description }` in VolumePhotography — a
|
|
25
25
|
# page listing conference links, nothing to do with async state.
|
|
26
|
-
# CARVE-OUT 1 IS NOW A REPO DECLARATION, not only a glob
|
|
26
|
+
# CARVE-OUT 1 IS NOW A REPO DECLARATION, not only a glob.
|
|
27
27
|
# `@agentvibes/kit` exists since 2026-09 and lives in its own repo, where verify
|
|
28
28
|
# sees its files as `src/resource/resource.ts` — neither `**/packages/kit/**`
|
|
29
29
|
# nor `**/agentvibes-kit/**` matches that, and no path glob can tell that tree
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
# kit_source = "^src/"
|
|
34
34
|
#
|
|
35
35
|
# together with the `appliesTo: not-kit-source` marker below. Same mechanism
|
|
36
|
-
# `[verify] screens` uses
|
|
36
|
+
# `[verify] screens` uses: the repo states a fact about itself,
|
|
37
37
|
# the canon says which rules stand down for it. The globs stay for monorepos
|
|
38
38
|
# that vendor the kit under `packages/kit/`.
|
|
39
39
|
#
|
|
@@ -7,13 +7,10 @@
|
|
|
7
7
|
# out once in `catch-empty-tsx.yml`; the short version is that ast-grep has no
|
|
8
8
|
# way to say "both languages", so a twin id per language is the only option.
|
|
9
9
|
#
|
|
10
|
-
# Measured 2026-09-06 across
|
|
11
|
-
# (
|
|
12
|
-
#
|
|
13
|
-
#
|
|
14
|
-
# doc-e4526f1a parks the question of banning `.otherwise()` outright, so the
|
|
15
|
-
# owner was asked whether to surface the .tsx half before D4 lands and answered
|
|
16
|
-
# «1» (add the twin now, severity warning) on 2026-09-06, is-8385d5dd.
|
|
10
|
+
# Measured 2026-09-06 across five repos that consume guardrails: 185
|
|
11
|
+
# `.otherwise()` chains in `.tsx` that the `.ts` arm never saw. The twin ships
|
|
12
|
+
# at severity warning; whether to ban `.otherwise()` outright is a separate,
|
|
13
|
+
# open question.
|
|
17
14
|
#
|
|
18
15
|
# Keep this file's `rule:` block IDENTICAL to `non-exhaustive-match.yml`.
|
|
19
16
|
#
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
# ── rule body adopted from
|
|
2
|
-
# The two rules were duplicates; the
|
|
1
|
+
# ── rule body adopted from a consumer repo's `ts-pattern-prefer-exhaustive` (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
|
# the old `pattern: $X.otherwise($$$)` fired on ANY `.otherwise()` method, not just
|
|
5
5
|
# a ts-pattern chain — a false-positive class. Anchoring to a `match()` chain
|
|
@@ -30,7 +30,7 @@ message: |
|
|
|
30
30
|
It ships in `@agentvibes/kit/react`. Pass dependencies to the constructor
|
|
31
31
|
explicitly so the store stays testable with `new GalleryPageStore(fake, "x")`
|
|
32
32
|
and no render at all.
|
|
33
|
-
See the simple-components skill (§store access)
|
|
33
|
+
See the simple-components skill (§store access).
|
|
34
34
|
rule:
|
|
35
35
|
all:
|
|
36
36
|
- kind: call_expression
|
|
@@ -26,7 +26,7 @@ message: |
|
|
|
26
26
|
It ships in `@agentvibes/kit/react`. Pass dependencies to the constructor
|
|
27
27
|
explicitly so the store stays testable with `new GalleryPageStore(fake, "x")`
|
|
28
28
|
and no render at all.
|
|
29
|
-
See the simple-components skill (§store access)
|
|
29
|
+
See the simple-components skill (§store access).
|
|
30
30
|
rule:
|
|
31
31
|
all:
|
|
32
32
|
- kind: call_expression
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ── simple-components, rule 4 of 4 ─────────────────────────────────────
|
|
2
2
|
#
|
|
3
|
-
# The logic half of the two-tier split
|
|
3
|
+
# The logic half of the two-tier split: a screen picks
|
|
4
4
|
# the models, matches the state and composes views. It carries no styling.
|
|
5
5
|
#
|
|
6
6
|
# Scoped to `**/*.screen.tsx` and nothing else, deliberately. The contract says
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
# one filename the convention makes explicit, so it is the one place the rule can
|
|
11
11
|
# be right without a manifest.
|
|
12
12
|
#
|
|
13
|
-
# WARNING TIER: same reason as `view-file-logic` —
|
|
13
|
+
# WARNING TIER: same reason as `view-file-logic` — the two-tier split is recommendation-tier.
|
|
14
14
|
id: screen-file-styling
|
|
15
15
|
language: tsx
|
|
16
16
|
severity: warning
|
|
@@ -22,7 +22,7 @@ message: |
|
|
|
22
22
|
on a second job and starts growing the layout it should have delegated.
|
|
23
23
|
Move the markup into a `*.view.tsx` (or a shared UI primitive) and let the
|
|
24
24
|
screen pass it data.
|
|
25
|
-
See the simple-components skill (§two-tier)
|
|
25
|
+
See the simple-components skill (§two-tier).
|
|
26
26
|
rule:
|
|
27
27
|
all:
|
|
28
28
|
- kind: jsx_attribute
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
# way to say "both languages", so a twin id per language is the only option.
|
|
9
9
|
#
|
|
10
10
|
# Measured 2026-09-06 across the same five repos: 24 findings in `.tsx`
|
|
11
|
-
# (
|
|
11
|
+
# (per repo: 3, 0, 9, 0, 12).
|
|
12
12
|
#
|
|
13
13
|
# Keep this file's `rule:` block IDENTICAL to `silent-default-return.yml`.
|
|
14
14
|
#
|
|
@@ -48,7 +48,7 @@ utils:
|
|
|
48
48
|
kind: identifier
|
|
49
49
|
regex: '^runInAction$'
|
|
50
50
|
# An observable MUTATION — which is the whole defect. Without this clause the
|
|
51
|
-
# rule fires on any async method, and in
|
|
51
|
+
# rule fires on any async method, and in a site-builder repo 10 of its 12 hits were
|
|
52
52
|
# private I/O helpers (`walkDir`, `collectAllFiles`, `uploadFile`) that await
|
|
53
53
|
# a filesystem and never touch a field. Those have no action coverage to lose,
|
|
54
54
|
# so at warning tier they were pure noise.
|
|
@@ -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
|
|
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 (
|
|
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.
|
|
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)
|
|
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 (
|
|
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
|
-
#
|
|
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
|
|
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.
|
|
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)
|
|
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
|
|
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.*
|
|
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
|
|
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.*
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
4
|
-
#
|
|
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
|
|
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
|
|
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
|
|
4
|
-
#
|
|
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
|
|
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.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
#
|
|
3
3
|
# `ui-imports-app-store` is `language: tsx`, so it reads `.tsx` and never `.ts` — ast-grep's
|
|
4
4
|
# languages are disjoint. What it matches needs no JSX, so it can sit in a plain
|
|
5
|
-
# `.ts` file just as well.
|
|
5
|
+
# `.ts` file just as well. The `.ts` twin closes that gap.
|
|
6
6
|
#
|
|
7
7
|
# Keep this file's `severity`, `files`, `ignores`, `utils` and `rule:`
|
|
8
8
|
# blocks IDENTICAL to `ui-imports-app-store.yml` (`.tsx` globs spelled `.ts`);
|
|
@@ -52,7 +52,7 @@ rule:
|
|
|
52
52
|
stopBy: end
|
|
53
53
|
kind: string_fragment
|
|
54
54
|
regex: '(^|/)stores?(/|$)'
|
|
55
|
-
#
|
|
55
|
+
# The view-model pattern this rule exists to protect tells a
|
|
56
56
|
# UI component to type itself against `IXxxModel` — which lives in the store
|
|
57
57
|
# module. Firing at `error` on that import made the rule contradict the
|
|
58
58
|
# pattern it enforces, so a compliant component could not be written without
|
|
@@ -40,7 +40,7 @@ rule:
|
|
|
40
40
|
stopBy: end
|
|
41
41
|
kind: string_fragment
|
|
42
42
|
regex: '(^|/)stores?(/|$)'
|
|
43
|
-
#
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
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)
|
|
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.
|