@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentvibes/guardrails",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Verification toolkit that makes agents write simple code: ast-grep rule canon, diff ratchet, biome/tsconfig presets, one CLI.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -16,7 +16,10 @@
|
|
|
16
16
|
"./tsconfig": "./configs/tsconfig.base.json",
|
|
17
17
|
"./sgconfig": "./sgconfig.yml",
|
|
18
18
|
"./package.json": "./package.json",
|
|
19
|
-
"./plugin": "./dist/pluginApi.js"
|
|
19
|
+
"./plugin": "./dist/pluginApi.js",
|
|
20
|
+
"./overrides": "./dist/overrides.js",
|
|
21
|
+
"./wiring": "./dist/wiring.js",
|
|
22
|
+
"./record": "./dist/record/index.js"
|
|
20
23
|
},
|
|
21
24
|
"files": [
|
|
22
25
|
"dist",
|
|
@@ -35,11 +38,12 @@
|
|
|
35
38
|
"format": "biome check --write .",
|
|
36
39
|
"test:rules": "node dist/testRules.js",
|
|
37
40
|
"test:gate": "node dist/gateRed.js",
|
|
38
|
-
"check": "pnpm build && pnpm lint && pnpm test:rules && pnpm test:twins && pnpm test:repo-rules && pnpm test:preset && pnpm test:gate && pnpm test:sibling-clone && pnpm test:metrics && pnpm test:init && pnpm test:severity && pnpm test:screens && pnpm test:jsx-suppress && pnpm test:hooks && pnpm test:iterate && pnpm test:rename-diff && pnpm test:leaks && pnpm test:pipe && pnpm leaks",
|
|
41
|
+
"check": "pnpm build && pnpm lint && pnpm test:rules && pnpm test:twins && pnpm test:repo-rules && pnpm test:preset && pnpm test:overrides && pnpm test:wiring && pnpm test:record && pnpm test:snapshot && pnpm test:time && pnpm test:gate && pnpm test:sibling-clone && pnpm test:metrics && pnpm test:cli-args && pnpm test:init && pnpm test:severity && pnpm test:screens && pnpm test:jsx-suppress && pnpm test:hooks && pnpm test:iterate && pnpm test:rename-diff && pnpm test:leaks && pnpm test:pipe && pnpm test:file-sloc && pnpm leaks",
|
|
39
42
|
"test:metrics": "node dist/metricsCycle.js",
|
|
40
43
|
"leaks": "node dist/cli.js leaks .",
|
|
41
44
|
"test:leaks": "node dist/leaksRed.js",
|
|
42
45
|
"test:pipe": "node dist/pipeOutputTest.js",
|
|
46
|
+
"test:file-sloc": "node dist/fileSlocTest.js",
|
|
43
47
|
"test:init": "node dist/initTest.js",
|
|
44
48
|
"test:severity": "node dist/severityTest.js",
|
|
45
49
|
"test:hooks": "node dist/hookStopTest.js",
|
|
@@ -49,19 +53,27 @@
|
|
|
49
53
|
"test:twins": "node dist/twinCoverageTest.js",
|
|
50
54
|
"test:repo-rules": "node dist/repoRulesTest.js",
|
|
51
55
|
"test:preset": "node dist/presetDriftTest.js",
|
|
56
|
+
"test:overrides": "node dist/overridesTest.js",
|
|
57
|
+
"test:wiring": "node dist/wiringTest.js",
|
|
58
|
+
"test:record": "node dist/recordTest.js",
|
|
59
|
+
"test:snapshot": "node dist/snapshotTest.js",
|
|
60
|
+
"test:time": "node dist/timeTest.js",
|
|
52
61
|
"test:sibling-clone": "node dist/siblingCloneTest.js",
|
|
53
|
-
"test:jsx-suppress": "node dist/jsxSuppressTest.js"
|
|
62
|
+
"test:jsx-suppress": "node dist/jsxSuppressTest.js",
|
|
63
|
+
"test:cli-args": "node dist/cliArgsTest.js"
|
|
54
64
|
},
|
|
55
65
|
"dependencies": {
|
|
56
66
|
"oxc-parser": "0.153.0",
|
|
57
|
-
"
|
|
67
|
+
"smol-toml": "1.9.1",
|
|
68
|
+
"ts-pattern": "^5.6.2",
|
|
69
|
+
"zod": "4.6.7"
|
|
58
70
|
},
|
|
59
71
|
"devDependencies": {
|
|
60
72
|
"@types/node": "^22.13.0",
|
|
61
73
|
"typescript": "^5.7.3"
|
|
62
74
|
},
|
|
63
75
|
"engines": {
|
|
64
|
-
"node": ">=22"
|
|
76
|
+
"node": ">=22.13.0"
|
|
65
77
|
},
|
|
66
78
|
"packageManager": "pnpm@10.12.1",
|
|
67
79
|
"publishConfig": {
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// The annotated form, which the rule caught from the start.
|
|
7
7
|
export const DEFAULT_MODE: Mode = { kind: "demo" }
|
|
8
8
|
|
|
9
|
-
// The `as const` form
|
|
9
|
+
// The `as const` form. This is the spelling people reach for
|
|
10
10
|
// when the object carries no type annotation to hold the literal type, and it
|
|
11
11
|
// was silently missed — DataSpool's retired local `no-fake-defaults` caught it,
|
|
12
12
|
// so adopting the canon had been a coverage regression.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// The annotated form, which the rule caught from the start.
|
|
7
7
|
export const DEFAULT_MODE: Mode = { kind: "demo" }
|
|
8
8
|
|
|
9
|
-
// The `as const` form
|
|
9
|
+
// The `as const` form. This is the spelling people reach for
|
|
10
10
|
// when the object carries no type annotation to hold the literal type, and it
|
|
11
11
|
// was silently missed — DataSpool's retired local `no-fake-defaults` caught it,
|
|
12
12
|
// so adopting the canon had been a coverage regression.
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// type-switches on the implementation instead of receiving a model.
|
|
5
5
|
import { GalleryStore } from "../../stores/galleryStore"
|
|
6
6
|
|
|
7
|
-
// A slice-store singleton. `rootStore` at a screen is legal
|
|
7
|
+
// A slice-store singleton. `rootStore` at a screen is legal;
|
|
8
8
|
// reaching past it for one slice is not.
|
|
9
9
|
import { galleryStore } from "../../stores/galleryStore"
|
|
10
10
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// NOTHING in this file may be reported by `direct-store-import`.
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// The global rootStore imported at a screen is legal.
|
|
4
4
|
import { rootStore } from "../../stores/rootStore"
|
|
5
5
|
|
|
6
|
-
// Type-only imports are the view-model contract
|
|
6
|
+
// Type-only imports are the view-model contract, not a store dependency.
|
|
7
7
|
import type { IGalleryModel } from "../../stores/galleryStore"
|
|
8
8
|
import type { RootStore } from "../../stores/rootStore"
|
|
9
9
|
import type Photo from "../../stores/photo"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Every ternary here MUST be reported by `discriminator-ternary-ts`.
|
|
2
|
+
// Same cases as bad.tsx: none of them needs JSX, so a `.ts` file holds them too.
|
|
3
|
+
|
|
4
|
+
export const first = (m: Maybe<string[]>) => (m.kind === "some" ? m.value : [])
|
|
5
|
+
export const adapter = (s: S) => (s.adapter.kind === "some" ? s.adapter.value : "—")
|
|
6
|
+
export const label = (r: R) => (r.status === "error" ? "Bad" : "Ok")
|
|
7
|
+
export const port = (c: C) => (c.type === "tcp" ? c.port : 0)
|
|
8
|
+
export const key = (p: P) => (p.provider === "openai" ? p.apiKey : p.token)
|
|
9
|
+
export const tone = (n: N) => (n.mode !== "dark" ? "light" : "dark")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Every ternary here MUST be reported by `discriminator-ternary`.
|
|
2
2
|
|
|
3
|
-
// The terse option-unwrap the
|
|
3
|
+
// The terse option-unwrap the source app audit found 18 of.
|
|
4
4
|
export const first = (m: Maybe<string[]>) => (m.kind === "some" ? m.value : [])
|
|
5
5
|
export const adapter = (s: S) => (s.adapter.kind === "some" ? s.adapter.value : "—")
|
|
6
6
|
// Other discriminator names the rule covers.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// NOTHING in this file may be reported by `discriminator-ternary-ts`.
|
|
2
|
+
import { match } from "ts-pattern"
|
|
3
|
+
|
|
4
|
+
// The fix: match the value, so a new variant is a build error.
|
|
5
|
+
export const first = (m: Maybe<string[]>) =>
|
|
6
|
+
match(m)
|
|
7
|
+
.with({ kind: "some" }, ({ value }) => value)
|
|
8
|
+
.with({ kind: "none" }, () => [])
|
|
9
|
+
.exhaustive()
|
|
10
|
+
|
|
11
|
+
// Not a discriminator field.
|
|
12
|
+
export const n = (u: U) => (u.count === 0 ? "none" : "some")
|
|
13
|
+
export const s = (u: U) => (u.name === "root" ? 1 : 2)
|
|
14
|
+
|
|
15
|
+
// Not an equality test on a discriminator.
|
|
16
|
+
export const t = (u: U) => (u.ready ? "y" : "n")
|
|
17
|
+
export const v = (u: U) => (u.items.length > 3 ? "many" : "few")
|
|
@@ -10,7 +10,7 @@ export const first = (m: Maybe<string[]>) =>
|
|
|
10
10
|
|
|
11
11
|
// A ternary whose branches are JSX belongs to `jsx-ternary`, which owns that
|
|
12
12
|
// case with the same fix. This rule stands down so the two can never report the
|
|
13
|
-
// same line twice — measured overlap on
|
|
13
|
+
// same line twice — measured overlap on two consumer apps: 0.
|
|
14
14
|
export const View = (r: R) => (r.status === "error" ? <ErrorState /> : <Ready />)
|
|
15
15
|
export const View2 = (r: R) => (r.kind === "idle" ? null : <Spinner />)
|
|
16
16
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Every URL here MUST be reported by `hardcoded-url-in-component-ts`.
|
|
2
|
+
// A `.ts` file under components/ — a hook or helper next to the component.
|
|
3
|
+
const API = "https://api.example.com/v1"
|
|
4
|
+
|
|
5
|
+
export function useUpload(): string[] {
|
|
6
|
+
const upload = "http://uploads.example.com/put"
|
|
7
|
+
const cdn = "https://cdn.example.com/assets"
|
|
8
|
+
return [API, upload, cdn, "https://gallery.internal.example/g/abc"]
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// NOTHING in this file may be reported by `hardcoded-url-in-component-ts`.
|
|
2
|
+
|
|
3
|
+
// The fix: the URL comes from a constants module.
|
|
4
|
+
import { API_BASE, GALLERY_URL } from "../../lib/constants/urls"
|
|
5
|
+
|
|
6
|
+
export const links = [API_BASE, GALLERY_URL]
|
|
7
|
+
|
|
8
|
+
// Relative paths carry no environment.
|
|
9
|
+
export const local = "/g/abc"
|
|
10
|
+
|
|
11
|
+
// Schema/namespace URLs are identifiers, not endpoints — the honest exception.
|
|
12
|
+
export const SVG_NS = "http://www.w3.org/2000/svg"
|
|
13
|
+
export const SCHEMA = "https://json-schema.org/draft/2020-12/schema"
|
|
@@ -52,7 +52,7 @@ export const E = observer(() => (
|
|
|
52
52
|
))
|
|
53
53
|
|
|
54
54
|
// The real shape, with design-system tags rather than host elements:
|
|
55
|
-
//
|
|
55
|
+
// A session-viewer app's SessionsTreeSection with its extracted <StatusGroup/> inlined.
|
|
56
56
|
export const SessionsTreeSection = observer(() => {
|
|
57
57
|
const { data, ui } = useStore()
|
|
58
58
|
const byStatus = (s: SessionStatus) => data.sessions.filter((x) => x.status === s)
|
|
@@ -23,7 +23,7 @@ export const E = observer(() => <ul>{xs.map((x) => <li key={x.id}><a href={x.hre
|
|
|
23
23
|
// Mapping to non-JSX values is untouched.
|
|
24
24
|
export const F = observer(() => <ul>{xs.map((x) => x.title).join(", ")}</ul>)
|
|
25
25
|
|
|
26
|
-
// A literal array —
|
|
26
|
+
// A literal array — the house "pure data" carve-out. A skeleton drawing four
|
|
27
27
|
// placeholder cards has no observable to subscribe to and no row to extract.
|
|
28
28
|
export const G = observer(() => (
|
|
29
29
|
<div>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// Every match here MUST be reported by `match-bool-to-null-ts`.
|
|
2
|
+
import { match } from "ts-pattern"
|
|
3
|
+
|
|
4
|
+
export const badge = (on: boolean) =>
|
|
5
|
+
match(on)
|
|
6
|
+
.with(true, () => "new")
|
|
7
|
+
.with(false, () => null)
|
|
8
|
+
.exhaustive()
|
|
9
|
+
|
|
10
|
+
export const hint = (ready: boolean, text: string) =>
|
|
11
|
+
match(ready)
|
|
12
|
+
.with(true, () => text.toUpperCase())
|
|
13
|
+
.with(false, () => null)
|
|
14
|
+
.exhaustive()
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// NOTHING in this file may be reported by `match-bool-to-null-ts`.
|
|
2
|
+
import { match } from "ts-pattern"
|
|
3
|
+
|
|
4
|
+
// Both arms produce a value: match() is the right tool.
|
|
5
|
+
export const label = (on: boolean) =>
|
|
6
|
+
match(on)
|
|
7
|
+
.with(true, () => "on")
|
|
8
|
+
.with(false, () => "off")
|
|
9
|
+
.exhaustive()
|
|
10
|
+
|
|
11
|
+
// A plain conditional for "maybe this value".
|
|
12
|
+
export const badge = (on: boolean) => (on ? "new" : null)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// NOTHING in this file may be reported by `match-bool-to-null`.
|
|
2
|
+
import { match } from "ts-pattern"
|
|
3
|
+
|
|
4
|
+
// The fix: the purpose-built helper.
|
|
5
|
+
export const Badge = ({ on }: { on: boolean }) => <ShowWhen cond={on}>{() => <span>new</span>}</ShowWhen>
|
|
6
|
+
|
|
7
|
+
// Both arms render something: match() stays.
|
|
8
|
+
export const renderLabel = (on: boolean) =>
|
|
9
|
+
match(on)
|
|
10
|
+
.with(true, () => <span>on</span>)
|
|
11
|
+
.with(false, () => <span>off</span>)
|
|
12
|
+
.exhaustive()
|
|
@@ -47,7 +47,7 @@ export const TabBar = ({ store }: { store: IUiModel }) => {
|
|
|
47
47
|
|
|
48
48
|
// ── shapes taken from real components, not invented ────────────────────
|
|
49
49
|
// The store read happens at body level and never appears inside the JSX.
|
|
50
|
-
//
|
|
50
|
+
// A gallery app's GalleryView does exactly this; an earlier "deref must be inside
|
|
51
51
|
// a jsx_expression" version of this rule missed it completely.
|
|
52
52
|
export const GalleryView = function GalleryView() {
|
|
53
53
|
const { galleryStore, themeStore } = useStore()
|
|
@@ -58,7 +58,7 @@ export const GalleryView = function GalleryView() {
|
|
|
58
58
|
.exhaustive()
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
// Read straight into a local derivation —
|
|
61
|
+
// Read straight into a local derivation — a session-viewer app's SessionsTreeSection.
|
|
62
62
|
export const SessionsTreeSection = () => {
|
|
63
63
|
const { data, ui } = useStore()
|
|
64
64
|
const matched = data.sessions.filter((s) => sessionMatches(s, ui.searchQuery))
|
|
@@ -9,7 +9,7 @@ export const SessionsList = observer(() => {
|
|
|
9
9
|
return <div>{data.sessions.length} sessions, tab {ui.tab}</div>
|
|
10
10
|
})
|
|
11
11
|
|
|
12
|
-
// Wrapped named function expression — the shape
|
|
12
|
+
// Wrapped named function expression — the shape a gallery app uses.
|
|
13
13
|
export const GalleryEmptyStateView = observer(function GalleryEmptyStateView({
|
|
14
14
|
title,
|
|
15
15
|
}: {
|
|
@@ -54,7 +54,7 @@ export const ModelDebugLabel = ({ model }: { model: unknown }) => (
|
|
|
54
54
|
|
|
55
55
|
// Pulls the store ONLY to call a stable action from a handler. Nothing is read
|
|
56
56
|
// during render, so nothing needs subscribing and the parent observer owns the
|
|
57
|
-
// page.
|
|
57
|
+
// page. A session-viewer app writes two of these on purpose (`RichEntityListView`,
|
|
58
58
|
// `KanbanView`) with a comment saying exactly this.
|
|
59
59
|
export const OpenEntityButton = ({ id, label }: { id: string; label: string }) => {
|
|
60
60
|
const { ui } = useStore()
|
|
@@ -15,7 +15,7 @@ export class ObservableQuery<T> {
|
|
|
15
15
|
constructor(private readonly fetcher: () => Promise<T>) {}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// One consumer carries six byte-identical copies of these two inside one monorepo.
|
|
19
19
|
export function warnDegraded(context: string, detail: string): void {
|
|
20
20
|
console.warn(`[degraded] ${context}: ${detail}`)
|
|
21
21
|
}
|
|
@@ -24,7 +24,7 @@ export function warnNotImplemented(category: string, detail: string): void {
|
|
|
24
24
|
console.warn(`[not-implemented] ${category}: ${detail}`)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// The useMemo improvisation with no dispose that
|
|
27
|
+
// The useMemo improvisation with no dispose that the store-layout audit found everywhere.
|
|
28
28
|
export const usePageStore = <T>(factory: () => T, deps: unknown[]): T => {
|
|
29
29
|
return useMemo(factory, deps)
|
|
30
30
|
}
|
|
@@ -15,7 +15,7 @@ export class ObservableQuery<T> {
|
|
|
15
15
|
constructor(private readonly fetcher: () => Promise<T>) {}
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
//
|
|
18
|
+
// One consumer carries six byte-identical copies of these two inside one monorepo.
|
|
19
19
|
export function warnDegraded(context: string, detail: string): void {
|
|
20
20
|
console.warn(`[degraded] ${context}: ${detail}`)
|
|
21
21
|
}
|
|
@@ -24,7 +24,7 @@ export function warnNotImplemented(category: string, detail: string): void {
|
|
|
24
24
|
console.warn(`[not-implemented] ${category}: ${detail}`)
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// The useMemo improvisation with no dispose that
|
|
27
|
+
// The useMemo improvisation with no dispose that the store-layout audit found everywhere.
|
|
28
28
|
export const usePageStore = <T,>(factory: () => T, deps: unknown[]): T => {
|
|
29
29
|
return useMemo(factory, deps)
|
|
30
30
|
}
|
|
@@ -8,7 +8,7 @@ export type Resource<T> =
|
|
|
8
8
|
| { status: "error"; message: string }
|
|
9
9
|
|
|
10
10
|
// Independent axes done RIGHT — this is SWR, not boolean soup: "has data" and
|
|
11
|
-
// "a fetch is in flight" genuinely are orthogonal
|
|
11
|
+
// "a fetch is in flight" genuinely are orthogonal.
|
|
12
12
|
export type QueryState<T> =
|
|
13
13
|
| { status: "pending"; fetchActivity: "idle" | "fetching" }
|
|
14
14
|
| { status: "success"; data: T; fetchActivity: "idle" | "fetching" }
|
|
@@ -8,7 +8,7 @@ export type Resource<T> =
|
|
|
8
8
|
| { status: "error"; message: string }
|
|
9
9
|
|
|
10
10
|
// Independent axes done RIGHT — this is SWR, not boolean soup: "has data" and
|
|
11
|
-
// "a fetch is in flight" genuinely are orthogonal
|
|
11
|
+
// "a fetch is in flight" genuinely are orthogonal.
|
|
12
12
|
export type QueryState<T> =
|
|
13
13
|
| { status: "pending"; fetchActivity: "idle" | "fetching" }
|
|
14
14
|
| { status: "success"; data: T; fetchActivity: "idle" | "fetching" }
|
|
@@ -40,7 +40,7 @@ export class ApiClient {
|
|
|
40
40
|
// ── the false-positive class this rule was narrowed to exclude ─────────
|
|
41
41
|
// Private async helpers that do pure I/O and never touch an observable field.
|
|
42
42
|
// There is no action coverage to lose, so there is nothing to convert. Real:
|
|
43
|
-
//
|
|
43
|
+
// A site-builder repo's walkDir / collectAllFiles / uploadFile — 10 of the rule's 12
|
|
44
44
|
// hits in that repo before the mutation requirement was added.
|
|
45
45
|
export class ContentStore {
|
|
46
46
|
files: string[] = []
|
|
@@ -40,7 +40,7 @@ export class ApiClient {
|
|
|
40
40
|
// ── the false-positive class this rule was narrowed to exclude ─────────
|
|
41
41
|
// Private async helpers that do pure I/O and never touch an observable field.
|
|
42
42
|
// There is no action coverage to lose, so there is nothing to convert. Real:
|
|
43
|
-
//
|
|
43
|
+
// A site-builder repo's walkDir / collectAllFiles / uploadFile — 10 of the rule's 12
|
|
44
44
|
// hits in that repo before the mutation requirement was added.
|
|
45
45
|
export class ContentStore {
|
|
46
46
|
files: string[] = []
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// BAD: the whole context channel
|
|
1
|
+
// BAD: the whole context channel the house store layout removes — provider, hook, null-check.
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
|
|
4
4
|
type RootStore = { readonly ready: boolean };
|
|
@@ -18,7 +18,7 @@ export class AppStore {
|
|
|
18
18
|
return this.userStore.id
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// The real shape found in the park (2 sites
|
|
21
|
+
// The real shape found in the park (2 sites in a survey of two consumer repos).
|
|
22
22
|
get isConnected(): boolean {
|
|
23
23
|
return this.connectionStore.isConnected
|
|
24
24
|
}
|
|
@@ -18,7 +18,7 @@ export class AppStore {
|
|
|
18
18
|
return this.userStore.id
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
// The real shape found in the park (2 sites
|
|
21
|
+
// The real shape found in the park (2 sites in a survey of two consumer repos).
|
|
22
22
|
get isConnected(): boolean {
|
|
23
23
|
return this.connectionStore.isConnected
|
|
24
24
|
}
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { makeAutoObservable } from "mobx"
|
|
3
3
|
|
|
4
4
|
// ── The data-wrapper pattern: 89 of the 91 single-line `return this.X.y`
|
|
5
|
-
// getters measured across
|
|
5
|
+
// getters measured across four consumer repos look exactly
|
|
6
6
|
// like this. A model holding a plain record and republishing its fields as
|
|
7
|
-
// observable getters is the sanctioned shape (
|
|
8
|
-
//
|
|
7
|
+
// observable getters is the sanctioned shape (a shared model class in one
|
|
8
|
+
// consumer repo, domain stores in another).
|
|
9
9
|
export class Model {
|
|
10
10
|
readonly data: ModelRecordData
|
|
11
11
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import { makeAutoObservable } from "mobx"
|
|
3
3
|
|
|
4
4
|
// ── The data-wrapper pattern: 89 of the 91 single-line `return this.X.y`
|
|
5
|
-
// getters measured across
|
|
5
|
+
// getters measured across four consumer repos look exactly
|
|
6
6
|
// like this. A model holding a plain record and republishing its fields as
|
|
7
|
-
// observable getters is the sanctioned shape (
|
|
8
|
-
//
|
|
7
|
+
// observable getters is the sanctioned shape (a shared model class in one
|
|
8
|
+
// consumer repo, domain stores in another).
|
|
9
9
|
export class Model {
|
|
10
10
|
readonly data: ModelRecordData
|
|
11
11
|
|
|
@@ -32,7 +32,7 @@ export class GitStore {
|
|
|
32
32
|
|
|
33
33
|
// The generic-argument spelling of the annotation. A `pattern:
|
|
34
34
|
// makeAutoObservable($$$)` does not match a call carrying explicit type
|
|
35
|
-
// arguments, which is how
|
|
35
|
+
// arguments, which is how a site-builder repo's project.store.ts — 7 real call sites —
|
|
36
36
|
// went missing from the first version of this rule.
|
|
37
37
|
export class ProjectStore {
|
|
38
38
|
private _buildTimer: number | null = null
|
|
@@ -32,7 +32,7 @@ export class GitStore {
|
|
|
32
32
|
|
|
33
33
|
// The generic-argument spelling of the annotation. A `pattern:
|
|
34
34
|
// makeAutoObservable($$$)` does not match a call carrying explicit type
|
|
35
|
-
// arguments, which is how
|
|
35
|
+
// arguments, which is how a site-builder repo's project.store.ts — 7 real call sites —
|
|
36
36
|
// went missing from the first version of this rule.
|
|
37
37
|
export class ProjectStore {
|
|
38
38
|
private _buildTimer: number | null = null
|
|
@@ -34,6 +34,6 @@ export function describeBranch(branch: string): string {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// Importing the symbol is not calling it. The report's "66 runInAction in
|
|
37
|
-
//
|
|
37
|
+
// a site-builder repo" counted 7 import lines exactly like this one; the real call-site
|
|
38
38
|
// count is 59.
|
|
39
39
|
export { runInAction } from "mobx"
|
|
@@ -34,6 +34,6 @@ export function describeBranch(branch: string): string {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
// Importing the symbol is not calling it. The report's "66 runInAction in
|
|
37
|
-
//
|
|
37
|
+
// a site-builder repo" counted 7 import lines exactly like this one; the real call-site
|
|
38
38
|
// count is 59.
|
|
39
39
|
export { runInAction } from "mobx"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Every match chain here MUST be reported by `ts-pattern-dangling-match`.
|
|
2
2
|
import { match } from "ts-pattern"
|
|
3
3
|
|
|
4
|
-
// A real
|
|
4
|
+
// A real chain from a consumer app with its terminator deleted: evaluates to a builder
|
|
5
5
|
// object, which is truthy, so the caller keeps compiling and every arm is dead.
|
|
6
6
|
export function label(r: Resource<string>): string {
|
|
7
7
|
return match(r)
|
|
@@ -9,8 +9,8 @@ export function label(r: Resource<string>): string {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
// `.otherwise()` and `.run()` terminate a chain too. Whether `.exhaustive()`
|
|
12
|
-
// should be PREFERRED over `.otherwise()` is a separate question
|
|
13
|
-
//
|
|
12
|
+
// should be PREFERRED over `.otherwise()` is a separate, open question;
|
|
13
|
+
// this rule is only about a chain that ends nowhere.
|
|
14
14
|
export function label2(r: Resource<string>): string {
|
|
15
15
|
return match(r).with({ kind: "idle" }, () => "idle").otherwise(() => "?")
|
|
16
16
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Every import in this file MUST be reported by `ui-imports-app-store-ts`.
|
|
2
|
+
// A `.ts` file in a UI directory — a hook or view helper next to the components.
|
|
3
|
+
|
|
4
|
+
import { galleryStore } from "../../stores/galleryStore"
|
|
5
|
+
import { GalleryStore } from "../../stores/galleryStore"
|
|
6
|
+
import { rootStore } from "../../store/rootStore"
|
|
7
|
+
import { useStore } from "../../stores/StoreContext"
|
|
8
|
+
import photoStore from "../../stores/photoStore"
|
|
9
|
+
|
|
10
|
+
export const panelLabel = (label: string): string =>
|
|
11
|
+
`${label}${galleryStore.n}${GalleryStore.name}${rootStore.n}${useStore.name}${photoStore.n}`
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// NOTHING in this file may be reported by `ui-imports-app-store-ts`.
|
|
2
|
+
|
|
3
|
+
// Type-only imports erase at build time: the helper depends on a shape, not on
|
|
4
|
+
// an app store.
|
|
5
|
+
import type { IGalleryModel } from "../../stores/galleryStore"
|
|
6
|
+
import type { RootStore } from "../../store/rootStore"
|
|
7
|
+
import type Photo from "../../stores/photo"
|
|
8
|
+
import type * as StoreTypes from "../../stores/types"
|
|
9
|
+
import { type IUiModel, type ITabModel } from "../../stores/uiStore"
|
|
10
|
+
|
|
11
|
+
import { cn } from "../../lib/cn"
|
|
12
|
+
|
|
13
|
+
export const panelClass = (model: IGalleryModel, ui: IUiModel): string => cn("panel", model.title, ui.tab)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// NOTHING in this file may be reported by `ui-imports-app-store`.
|
|
2
2
|
|
|
3
|
-
//
|
|
3
|
+
// A reusable UI component typed against the view-model
|
|
4
4
|
// interface the store implements is exactly what the mobx-models view-model
|
|
5
5
|
// pattern prescribes. `import type` erases at build time — the component
|
|
6
6
|
// depends on a shape, not on an app store — so it must not trip the rule that
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// NOTHING in this file may be reported by `view-imports-store`.
|
|
2
2
|
|
|
3
|
-
// A view is typed against the model interface it renders
|
|
3
|
+
// A view is typed against the model interface it renders. The type
|
|
4
4
|
// vanishes at build time, so it is a contract, not a store dependency.
|
|
5
5
|
import type { IGalleryModel } from "../../stores/galleryStore"
|
|
6
6
|
import { type IUiModel } from "../../stores/uiStore"
|
|
@@ -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-as-any` (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
|
# surface `pattern:` is compared at ast-grep's default `smart` strictness, which
|
|
5
5
|
# also compares interleaved `comment` nodes — so `x as /* why */ any` slipped
|
package/rules/as-any-escape.yml
CHANGED
|
@@ -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-as-any` (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
|
# surface `pattern:` is compared at ast-grep's default `smart` strictness, which
|
|
5
5
|
# also compares interleaved `comment` nodes — so `x as /* why */ any` slipped
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# ── rule body adopted from
|
|
2
|
-
# The two rules were duplicates; the
|
|
1
|
+
# ── rule body adopted from a consumer repo's `no-empty-catch` (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 covered `catch {}` and `catch (e) {}` but NOT `catch (e:
|
|
5
5
|
# unknown) {}` / `catch (e: any) {}` — the type annotation is an extra named node.
|
|
6
|
-
# Measured on
|
|
6
|
+
# Measured on four consumer repos: 0 files lost, 1 gained,
|
|
7
7
|
# and the finding now anchors on the `catch` keyword rather than the `try`.
|
|
8
8
|
#
|
|
9
9
|
# The .tsx half of `catch-empty`.
|
package/rules/catch-empty.yml
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# ── rule body adopted from
|
|
2
|
-
# The two rules were duplicates; the
|
|
1
|
+
# ── rule body adopted from a consumer repo's `no-empty-catch` (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 covered `catch {}` and `catch (e) {}` but NOT `catch (e:
|
|
5
5
|
# unknown) {}` / `catch (e: any) {}` — the type annotation is an extra named node.
|
|
6
|
-
# Measured on
|
|
6
|
+
# Measured on four consumer repos: 0 files lost, 1 gained,
|
|
7
7
|
# and the finding now anchors on the `catch` keyword rather than the `try`.
|
|
8
8
|
#
|
|
9
9
|
id: catch-empty
|