@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.
- 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 +33 -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 +2 -20
- 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.ts +9 -0
- package/rules/__fixtures__/discriminator-ternary/bad.tsx +1 -1
- package/rules/__fixtures__/discriminator-ternary/good.ts +17 -0
- package/rules/__fixtures__/discriminator-ternary/good.tsx +1 -1
- package/rules/__fixtures__/hardcoded-url-in-component/components/bad.ts +9 -0
- package/rules/__fixtures__/hardcoded-url-in-component/components/good.ts +13 -0
- package/rules/__fixtures__/inline-map-row/bad.tsx +1 -1
- package/rules/__fixtures__/inline-map-row/good.tsx +1 -1
- package/rules/__fixtures__/match-bool-to-null/bad.ts +14 -0
- package/rules/__fixtures__/match-bool-to-null/bad.tsx +8 -0
- package/rules/__fixtures__/match-bool-to-null/good.ts +12 -0
- package/rules/__fixtures__/match-bool-to-null/good.tsx +12 -0
- 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/bad.ts +11 -0
- package/rules/__fixtures__/ui-imports-app-store/src/ui/good.ts +13 -0
- 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 +46 -0
- package/rules/discriminator-ternary.yml +3 -3
- package/rules/hardcoded-url-in-component-ts.yml +40 -0
- package/rules/hardcoded-url-in-component.yml +5 -8
- 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 +27 -0
- 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 +61 -0
- 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
|
@@ -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.
|
|
@@ -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
|
-
#
|
|
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.
|
|
@@ -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
|
|
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:
|
|
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,
|
|
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
|
|
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
|
|
2
|
-
# The two rules were duplicates; the
|
|
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
|
|
2
|
-
# The two rules were duplicates; the
|
|
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 (
|
|
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.
|