@shivaedev/quality 0.62.1 → 0.65.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (125) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +20 -4
  3. package/biome/plugins/ambient-runtime.grit +3 -3
  4. package/dist/adapters/biome/run.d.ts.map +1 -1
  5. package/dist/adapters/biome/run.js +6 -2
  6. package/dist/adapters/biome/run.js.map +1 -1
  7. package/dist/adapters/databaseUrlFindings.d.ts +11 -0
  8. package/dist/adapters/databaseUrlFindings.d.ts.map +1 -0
  9. package/dist/adapters/databaseUrlFindings.js +20 -0
  10. package/dist/adapters/databaseUrlFindings.js.map +1 -0
  11. package/dist/adapters/databaseUrlReads.d.ts +3 -0
  12. package/dist/adapters/databaseUrlReads.d.ts.map +1 -0
  13. package/dist/adapters/databaseUrlReads.js +107 -0
  14. package/dist/adapters/databaseUrlReads.js.map +1 -0
  15. package/dist/adapters/imports/resolve.js +1 -1
  16. package/dist/adapters/imports/resolve.js.map +1 -1
  17. package/dist/adapters/knip/report.d.ts +3 -0
  18. package/dist/adapters/knip/report.d.ts.map +1 -0
  19. package/dist/adapters/knip/report.js +22 -0
  20. package/dist/adapters/knip/report.js.map +1 -0
  21. package/dist/adapters/knip/run.d.ts +1 -1
  22. package/dist/adapters/knip/run.d.ts.map +1 -1
  23. package/dist/adapters/knip/run.js +3 -5
  24. package/dist/adapters/knip/run.js.map +1 -1
  25. package/dist/adapters/outsideImportFindings.d.ts.map +1 -1
  26. package/dist/adapters/outsideImportFindings.js +15 -31
  27. package/dist/adapters/outsideImportFindings.js.map +1 -1
  28. package/dist/adapters/units/runtime.d.ts +6 -0
  29. package/dist/adapters/units/runtime.d.ts.map +1 -0
  30. package/dist/adapters/units/runtime.js +46 -0
  31. package/dist/adapters/units/runtime.js.map +1 -0
  32. package/dist/adapters/units/runtimeImports.d.ts +10 -0
  33. package/dist/adapters/units/runtimeImports.d.ts.map +1 -0
  34. package/dist/adapters/units/runtimeImports.js +51 -0
  35. package/dist/adapters/units/runtimeImports.js.map +1 -0
  36. package/dist/adapters/units/runtimeOrigins.d.ts +4 -0
  37. package/dist/adapters/units/runtimeOrigins.d.ts.map +1 -0
  38. package/dist/adapters/units/runtimeOrigins.js +85 -0
  39. package/dist/adapters/units/runtimeOrigins.js.map +1 -0
  40. package/dist/adapters/units/runtimeUse.d.ts +8 -0
  41. package/dist/adapters/units/runtimeUse.d.ts.map +1 -0
  42. package/dist/adapters/units/runtimeUse.js +60 -0
  43. package/dist/adapters/units/runtimeUse.js.map +1 -0
  44. package/dist/cli/lint.js +1 -1
  45. package/dist/cli/lint.js.map +1 -1
  46. package/dist/imports/extract.d.ts.map +1 -1
  47. package/dist/imports/extract.js +13 -2
  48. package/dist/imports/extract.js.map +1 -1
  49. package/dist/inventory/collect.d.ts.map +1 -1
  50. package/dist/inventory/collect.js +3 -0
  51. package/dist/inventory/collect.js.map +1 -1
  52. package/dist/inventory/skillCopies.d.ts +7 -0
  53. package/dist/inventory/skillCopies.d.ts.map +1 -0
  54. package/dist/inventory/skillCopies.js +25 -0
  55. package/dist/inventory/skillCopies.js.map +1 -0
  56. package/dist/manifests/sorted.d.ts +1 -1
  57. package/dist/manifests/sorted.d.ts.map +1 -1
  58. package/dist/manifests/sorted.js +7 -4
  59. package/dist/manifests/sorted.js.map +1 -1
  60. package/dist/rules/builtIn.d.ts +2 -2
  61. package/dist/rules/builtIn.d.ts.map +1 -1
  62. package/dist/rules/builtIn.js +4 -0
  63. package/dist/rules/builtIn.js.map +1 -1
  64. package/dist/rules/effect/adapterImports.js +1 -1
  65. package/dist/rules/effect/adapterImports.js.map +1 -1
  66. package/dist/rules/files/folderNames.d.ts.map +1 -1
  67. package/dist/rules/files/folderNames.js +4 -1
  68. package/dist/rules/files/folderNames.js.map +1 -1
  69. package/dist/rules/manifestsNoTestKits.d.ts +2 -0
  70. package/dist/rules/manifestsNoTestKits.d.ts.map +1 -0
  71. package/dist/rules/manifestsNoTestKits.js +59 -0
  72. package/dist/rules/manifestsNoTestKits.js.map +1 -0
  73. package/dist/rules/stories/adapters/failureDeadline.d.ts +5 -0
  74. package/dist/rules/stories/adapters/failureDeadline.d.ts.map +1 -0
  75. package/dist/rules/stories/adapters/failureDeadline.js +66 -0
  76. package/dist/rules/stories/adapters/failureDeadline.js.map +1 -0
  77. package/dist/rules/stories/adapters/realTime.d.ts +4 -0
  78. package/dist/rules/stories/adapters/realTime.d.ts.map +1 -0
  79. package/dist/rules/stories/adapters/realTime.js +65 -0
  80. package/dist/rules/stories/adapters/realTime.js.map +1 -0
  81. package/dist/rules/stories/databaseUrl.d.ts +2 -0
  82. package/dist/rules/stories/databaseUrl.d.ts.map +1 -0
  83. package/dist/rules/stories/databaseUrl.js +8 -0
  84. package/dist/rules/stories/databaseUrl.js.map +1 -0
  85. package/dist/rules/stories/engineOf.d.ts.map +1 -1
  86. package/dist/rules/stories/engineOf.js +1 -0
  87. package/dist/rules/stories/engineOf.js.map +1 -1
  88. package/dist/rules/stories/specs.d.ts.map +1 -1
  89. package/dist/rules/stories/specs.js +2 -1
  90. package/dist/rules/stories/specs.js.map +1 -1
  91. package/dist/rules/stories/unitTests.d.ts +2 -2
  92. package/dist/rules/stories/unitTests.d.ts.map +1 -1
  93. package/dist/rules/stories/unitTests.js +6 -2
  94. package/dist/rules/stories/unitTests.js.map +1 -1
  95. package/dist/rules/stories/waitOnEvents.d.ts.map +1 -1
  96. package/dist/rules/stories/waitOnEvents.js +13 -70
  97. package/dist/rules/stories/waitOnEvents.js.map +1 -1
  98. package/package.json +15 -15
  99. package/src/adapters/biome/run.ts +6 -2
  100. package/src/adapters/databaseUrlFindings.ts +23 -0
  101. package/src/adapters/databaseUrlReads.ts +119 -0
  102. package/src/adapters/imports/resolve.ts +1 -1
  103. package/src/adapters/knip/report.ts +22 -0
  104. package/src/adapters/knip/run.ts +3 -7
  105. package/src/adapters/outsideImportFindings.ts +15 -34
  106. package/src/adapters/units/runtime.ts +53 -0
  107. package/src/adapters/units/runtimeImports.ts +60 -0
  108. package/src/adapters/units/runtimeOrigins.ts +96 -0
  109. package/src/adapters/units/runtimeUse.ts +72 -0
  110. package/src/cli/lint.ts +1 -1
  111. package/src/imports/extract.ts +16 -2
  112. package/src/inventory/collect.ts +3 -0
  113. package/src/inventory/skillCopies.ts +30 -0
  114. package/src/manifests/sorted.ts +9 -8
  115. package/src/rules/builtIn.ts +4 -0
  116. package/src/rules/effect/adapterImports.ts +1 -1
  117. package/src/rules/files/folderNames.ts +4 -1
  118. package/src/rules/manifestsNoTestKits.ts +73 -0
  119. package/src/rules/stories/adapters/failureDeadline.ts +78 -0
  120. package/src/rules/stories/adapters/realTime.ts +76 -0
  121. package/src/rules/stories/databaseUrl.ts +8 -0
  122. package/src/rules/stories/engineOf.ts +1 -0
  123. package/src/rules/stories/specs.ts +2 -1
  124. package/src/rules/stories/unitTests.ts +10 -2
  125. package/src/rules/stories/waitOnEvents.ts +12 -82
package/CHANGELOG.md CHANGED
@@ -1,5 +1,39 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.65.0 - 2026-11-05
4
+
5
+ ### Breaking
6
+
7
+ - Require Effect 4.1.0 and its matching companion packages. Move `effect`, `@effect/platform-node`, `@effect/platform-node-shared`, `@effect/sql-pg`, `@effect/sql-sqlite-node`, `@effect/atom-react` and `@effect/vitest` to exactly 4.1.0 together. The `ambient-runtime` lint rule now points at `SecureRandom` from `effect/crypto`.
8
+
9
+ ## 0.64.0 - 2026-11-05
10
+
11
+ ### Fixed
12
+
13
+ - Accept supported UI, routing and styling libraries directly in client code while keeping I/O and external-state integrations in adapters.
14
+
15
+ ### Breaking
16
+
17
+ - `tests/wait-on-events` also reports wall-clock reads and real timer APIs in stories and reachable kits, and accepts no config exceptions. Replace real waits with controlled clock verbs and engine signals; deadlines that only fail an unfinished wait remain allowed.
18
+ - The `files/folder-names` rule rejects folders named `internal`, including module, package, content, tool-owned and route folders. Move their files into the parent folder or a folder named after their job.
19
+
20
+ ## 0.63.0 - 2026-11-05
21
+
22
+ ### Added
23
+
24
+ - Flag direct `Config` and `process.env` reads of `*DATABASE_URL` variables in test-support with `tests/database-url`; use test-sql's `postgresTestUrl` so missing URLs fail in CI.
25
+ - Reject runtime packages that publish testing modules or declare test packages as shipped dependencies or peers. Findings name the package and direct helpers into `@shivaedev/test-kits`.
26
+
27
+ ### Fixed
28
+
29
+ - Report incomplete Knip analysis, including throwing tool configs, as one `code/unused` finding with the tool output while the other rules finish.
30
+ - Leave skills-tool managed copies, their Claude links and ownership manifests out of lint, formatting and fixes while continuing to check local skills.
31
+ - Resolve Vite asset imports through package exports, accepting the query suffixes declared by `vite/client` while reporting missing assets, private package paths and unsupported suffixes.
32
+
33
+ ### Breaking
34
+
35
+ - Unit tests now reject Effect runners, Clock and TestClock through runtime import chains, including production helpers and shared `it.effect` adapters. Use plain Vitest `it` and existing pure APIs for pure logic; move Effect behaviour to the package's story kit. Findings name the helper chain and terminal source location.
36
+
3
37
  ## 0.62.1 - 2026-11-04
4
38
 
5
39
  ### Fixed
package/README.md CHANGED
@@ -70,6 +70,8 @@ For an existing kit, compose the lower-level helpers through its local test-supp
70
70
 
71
71
  ### Dependency pins and repository hygiene
72
72
 
73
+ `manifests/no-test-kits` rejects runtime packages that expose a `testing` module or declare `@shivaedev/test`, `@shivaedev/test-story`, `@shivaedev/test-sql`, `@shivaedev/test-kits` or `vitest` in dependencies, optional dependencies or peers. It checks explicit export names and targets, including conditions and fallback arrays, and inventoried testing modules exposed through wildcards. Blocked exports and development dependencies pass. Private applications and the test-tooling packages quality, vitest-rerun, test, test-story, test-sql and test-kits are exempt. Move reusable runtime-package helpers into test-kits and keep test dependencies in development dependencies.
74
+
73
75
  `manifests/dependency-pins` checks dependencies, development dependencies, optional dependencies and peers in every inventoried package manifest. External dependencies use exact versions, including npm aliases. Workspace, file and link dependencies stay local. Quality finds the nearest `pnpm-workspace.yaml` at or above its config folder. When that workspace declares a default or named catalog, external dependencies use `catalog:` or `catalog:<name>`, and the referenced catalog must contain that dependency. Catalog entries themselves use exact versions. Write catalogs as indented block mappings; inline mappings and YAML aliases receive findings instead of escaping the check.
74
76
 
75
77
  `files/ascii` is opt-in by file selection. It checks the bytes of selected text files, including a UTF-8 BOM, and reports each line containing non-ASCII bytes. Other files are left alone. Supply repository-relative glob patterns:
@@ -138,7 +140,7 @@ The rule reports hidden configurations and method records, configuration and ope
138
140
 
139
141
  `effect/adapter-imports` reports value imports of non-Effect dependencies, peers and optional dependencies, and Node builtins, at the import site. It includes side-effect imports, value re-exports, literal dynamic imports and `require` calls. Each package is checked against its own manifest; dev-only tools and workspace modules are accepted. Type-only imports and re-exports are accepted, including inline `type` specifiers when every binding is a type.
140
142
 
141
- Move the integration into an `adapters/` folder and expose Effect values to the rest of the application. Use `import type` when only a type is needed. Folders named `adapters/` and `test-support/`, Effect packages (`effect` and `@effect/*`, including `@effect/platform-node`), native `@shivaedev/*` framework packages, and React (`react` and `react-dom`) in `client/` folders are exempt. Other outside libraries in client folders still need adapters; test filenames and entry points do not exempt imports.
143
+ Move the integration into an `adapters/` folder and expose Effect values to the rest of the application. Use `import type` when only a type is needed. Folders named `adapters/` and `test-support/`, Effect packages (`effect` and `@effect/*`, including `@effect/platform-node`), native `@shivaedev/*` framework packages, plain Vitest imports in `.unit` tests, and rendering libraries in `client/` folders are accepted. The client rendering libraries are `react`, `react-dom`, `lucide-react`, `@base-ui/react`, `@tanstack/react-router`, `@tanstack/react-table`, `class-variance-authority`, `cn`, `clsx` and `tailwind-merge`, including their subpath imports. Import UI components, routing and styling helpers directly in client code. Libraries that perform I/O or manage external state, such as `axios`, `better-auth/react`, `@tanstack/react-query` and `zustand`, still need adapters there. Other outside libraries and non-client rendering imports still need adapters; entry points do not exempt imports.
142
144
 
143
145
  The rule refuses config exceptions and inline suppressions. For existing debt, run `quality baseline write --first-adoption --rule effect/adapter-imports`; baseline shards keep one entry per file with its finding count. Run `quality baseline tighten` after moving integrations.
144
146
 
@@ -221,6 +223,8 @@ export default defineConfig({ sources: ["src"] });
221
223
 
222
224
  When a config exists, its folder is the root for paths and hook scripts. Without one, the current directory is the root. `sources` chooses the files the source rules read; a missing source stops the run. Directory discovery skips untracked files ignored by git through `.gitignore`, `info/exclude` or `core.excludesFile`, and the `.git`, `.worktrees` and `node_modules` directories. Tracked files remain checked even when an ignore pattern matches them; a folder named `generated/` does not exempt authored code. Some repository rules, such as manifest sorting, inspect the whole repository even when `sources` names only `src`.
223
225
 
226
+ Quality reads the skills tool’s `.shivaedev-skills.json` ownership manifest in each repository’s `.agents/skills` folder. It skips the recorded folders, their `.claude/skills` links and the manifest itself in source checks, Biome lint and formatting, manifest sorting and fixes, including rule-specific fixes. Local skills beside those copies remain checked. Change a shared skill at its source and run `shivaedev-skills sync` to refresh the copies.
227
+
224
228
  Quality discovers each app’s `components.json` and resolves `aliases.ui` through its TypeScript paths or package imports. Inside that folder, source rules and Biome lint, formatting and fixes skip only canonical shadcn registry filenames such as `button.tsx` and `dialog.tsx`, including their `.ts`, `.js` and `.jsx` variants. Hand-written components with other names stay checked, as do matching names outside the configured UI folder. Knip still follows imports from skipped components, so their dependencies count as used. Ownership follows filenames: a hand-written file that reuses a registry name inside the UI folder is also skipped.
225
229
 
226
230
  Quality reads each app's `tsr.config.json` and literal `tanstackRouter` / `TanStackRouterVite` options imported from `@tanstack/router-plugin/vite` or `@tanstack/router-vite-plugin` in `vite.config.*`. `routesDirectory` is relative to that app's config folder and defaults to `src/routes`; Vite options override the JSON options. Declare the folder once in the router configuration: `files/named-after-export` accepts route filenames, and `files/folder-names` accepts their route groups and pathless layout folders, including routes added later. Other source rules still check routes. Ordinary files outside that folder, other apps and helper files excluded by `routeFileIgnorePrefix` (default `-`), `routeFileIgnorePattern` or `routeFilePrefix` keep their normal naming checks. A folder named `routes` alone establishes no ownership. Ignore patterns use Unicode regular expressions. Quality reads configuration without executing Vite: computed or spread router options must move into `tsr.config.json` or become literal options. Malformed JSON or invalid route-folder settings stop the gate. Exception declarations still name explicit files; route discovery adds no exception globs.
@@ -277,7 +281,11 @@ export default [uiBoundary];
277
281
 
278
282
  This is `packages/<ui>/quality.fences.config.ts`; paths remain relative to the repository root. Fences supplied through `rules["imports/fences"].options.fences` join the same policy. This adds a fact about the repository's architecture to the shared import check. It does not select a different set of Quality rules. Every file named in either chain must exist in the checked tree; a deleted file stops the run. Use `external()` for external targets. The chains demonstrate hypothetical imports between those files; they need not be actual imports. The illegal chain must cross this fence alone; the legal chain must cross none. `mayNotImport` checks direct imports; `mayNotReach` also follows repository imports transitively; `mayImportOnly(...subjects).of(unit)` permits only named modules or folders of a unit. A source exception such as `.from(folders("packages/ui/src").except(files("packages/ui/src/testClient.ts")))` admits that one file while its siblings remain fenced. Fences count type imports but never hold test files or files under `test-support/`. The default `imports/no-test-code` rule rejects production imports of either, including type imports and re-exports. Move shared code into a production module that tests can import.
279
283
 
280
- The import rules resolve every literal specifier with the nearest `tsconfig.json`, or the project it references that includes the file. They preserve the compiler's resolution settings, inherited path aliases and package export conditions, including NodeNext's import and require branches. `imports/resolvable` reports config syntax errors, invalid options and unreadable extended or referenced configs as findings on the config file; repair those before relying on import findings. Without a tsconfig, Quality uses bundler resolution with the `@shivaedev/source` condition. The run stops when the sources hold no module at all. A relative or `#` import of a file that a generator writes before the tests run resolves only inside a folder that `imports/resolvable` lists as `generated`; the folder, or every file an import names in it, must be ignored by git:
284
+ The import rules resolve every literal specifier with the nearest `tsconfig.json`, or the project it references that includes the file. They preserve the compiler's resolution settings, inherited path aliases and package export conditions, including NodeNext's import and require branches. `imports/resolvable` reports config syntax errors, invalid options and unreadable extended or referenced configs as findings on the config file; repair those before relying on import findings. Without a tsconfig, Quality uses bundler resolution with the `@shivaedev/source` condition. The run stops when the sources hold no module at all.
285
+
286
+ Vite asset queries resolve the path before the query, including package assets through their declared exports. Supported suffixes match `vite/client`: `?url`, `?raw`, `?worker`, `?worker&inline`, `?worker&url`, `?sharedworker`, `?sharedworker&inline`, `?sharedworker&url`, `?inline`, `?no-inline`, `?url&inline`, `?url&no-inline` and `.wasm?init`. For example, `import url from 'zxing-wasm/reader/zxing_reader.wasm?url'` resolves the exported wasm file without an application module declaration. Missing files, private package paths and unsupported query suffixes still produce findings.
287
+
288
+ A relative or `#` import of a file that a generator writes before the tests run resolves only inside a folder that `imports/resolvable` lists as `generated`; the folder, or every file an import names in it, must be ignored by git:
281
289
 
282
290
  ```ts
283
291
  import { defineConfig } from "@shivaedev/quality/config.ts";
@@ -299,7 +307,11 @@ Quality's `tests/story-engine` rule reports spec bodies that read raw service ha
299
307
 
300
308
  `tests/global-retries` reports a `retry` option on a test, suite or kit story registration, including `retry: 0`. Remove the option: retries are global only and recorded by vitest-rerun so flakes stay visible. The rule follows registrar imports, aliases and modifiers, and options declared as literals, shared variables or spreads. Runner configuration and Effect retry schedules are accepted. It checks registrations throughout the inventory, including unit tests and test-support files, with no story prerequisite exemptions.
301
309
 
302
- There is one other honest form. A pure function with no engine behind it gets a plain test in a **unit test** file, declared by the `unit` modifier: `parse.unit.test.ts` beside `parse.ts`, or `<behaviour>.unit.spec.ts`. A unit test exercises one unit and reaches nothing bigger, so `tests/story-specs` rejects a `.unit` file that reaches an engine, directly or through what it imports, following runtime imports through the shared import graph; type-only imports do not count. The engines are Node's file, network, process and worker modules, database clients, HTTP and socket libraries, DOM libraries and the story runners. A test-support fixture the unit file imports must pass the same check. The rule also rejects mocking (`vi.mock`, `vi.spyOn`, `vi.fn`, env and global stubs, fake timers), providing services (`Effect.provide*`, `Layer`, `ManagedRuntime`, `it.layer`) and DOM use in the unit file and its test-support fixtures. Running an Effect that needs nothing, such as with `Effect.runSync` or `it.effect`, is fine. When the module under test reaches an engine, the finding names the import chain and asks you to split the module: move the pure code into a module that reaches no engine and test that one. The static check reads imports and syntax. The runtime guard in `testProjects` catches I/O hidden inside an external package or a global such as `fetch` when a unit test runs.
310
+ There is one other honest form. A pure function with no engine behind it gets a plain test in a **unit test** file, declared by the `unit` modifier: `parse.unit.test.ts` beside `parse.ts`, or `<behaviour>.unit.spec.ts`. A unit test exercises one unit and reaches nothing bigger, so `tests/story-specs` rejects a `.unit` file that reaches an engine, directly or through what it imports, following runtime imports through the shared import graph; type-only imports do not count. The engines are Node's file, network, process and worker modules, database clients, HTTP and socket libraries, DOM libraries and the story runners. A test-support fixture the unit file imports must pass the same check. The rule also rejects mocking (`vi.mock`, `vi.spyOn`, `vi.fn`, env and global stubs, fake timers), providing services (`Effect.provide*`, `Layer`, `ManagedRuntime`, `it.layer`) and DOM use in the unit file and its test-support fixtures.
311
+
312
+ A unit file also reaches no `Clock`, `TestClock` or `Effect.run*` runner, including aliases, subpath imports and re-exports, through any runtime import chain, including production modules and shared `it.effect` helpers. Each such finding points to the first relevant import or call in the unit file and names the helper chain to the terminal file and line. A requirement-free Effect type does not prove purity. Keep pure logic in plain Vitest `it` tests using synchronous APIs or `Schema.decodeUnknownResult` / `Schema.encodeResult`; exercise behaviour that needs the Effect runtime through the package story kit. Type-only imports, comments, strings and unrelated local objects named `Clock` do not count.
313
+
314
+ When the module under test reaches an engine, the finding names the import chain and asks you to split the module: move the pure code into a module that reaches no engine and test that one. The static check reads imports and syntax. The runtime guard in `testProjects` catches I/O hidden inside an external package or a global such as `fetch` when a unit test runs.
303
315
 
304
316
  Every finding names both repairs: drive the engine through the package's story kit, or, when the code under test is pure, move the test to a `.unit` file. Never wrap a pure function in a story that ignores its kit.
305
317
 
@@ -311,7 +323,7 @@ Specs keep expectations visible. `tests/spec-helpers` moves all module-level hel
311
323
 
312
324
  Three more rules keep a spec readable as a story, as the [story-testing skill](https://github.com/ShivaeDev/platform/blob/main/packages/skills/skills/story-testing/SKILL.md) describes. Together with `tests/spec-helpers`, `tests/named-values` and `tests/no-limit-imports`, they read files whose test declarations trace to a story kit, whatever their suffix: a `.test` or `.spec` file outside `test-support` that is not a type or unit test, such as `orders.spec.ts`, `pane.dom.test.ts` or `orders.slow.test.ts`. The suffix says where a test sits under `tests/follow`, not whether it is a story, and `tests/story-specs` already holds every such file to the story kit. They exempt the same test-story prerequisites as `tests/story-specs`. `tests/domain-outcomes` reports each use of Effect's `Exit`, `Cause` or `Result` module, each `_tag` read or destructuring, and each object literal tagged `"Success"` or `"Failure"`: the kit's verb or readout returns the outcome in the domain's words, such as `"unauthorized"`, and a trait builds any failing input. A domain's own tagged value, such as `{ _tag: "Resync" }`, passes. `tests/grouped-outcomes` reports each run of two or more consecutive `expect(yield* …)` statements once, at its first statement: write the outcomes as rows of one `outcomes` call.
313
325
 
314
- `tests/wait-on-events` checks those story specs and the `test-support/` modules reachable through their runtime imports, including aliases, re-exports and literal dynamic imports. It reports `Effect.sleep`, `setTimeout` and `setInterval`, calls to an imported `eventually`, Vitest's fake timers and `vi.waitFor`, including polling loops and quiet windows built from these calls. Product modules keep their timers. `TestClock.adjust` and `TestClock.setTime` are reported in specs and accepted in support: when time passing is the behaviour, advance the controlled clock in a kit verb named for it.
326
+ `tests/wait-on-events` checks those story specs and the `test-support/` modules reachable through their runtime imports, including aliases, re-exports and literal dynamic imports. It reports `Effect.sleep`, real timers (including browser and Node timer imports), wall-clock reads such as `Date.now()` and `performance.now()`, calls to an imported `eventually`, Vitest's fake timers and `vi.waitFor`, including polling loops and quiet windows built from these calls. It accepts no config exceptions. Product modules keep their timers. `TestClock.adjust` and `TestClock.setTime` are reported in specs and accepted in support: when time passing is the behaviour, advance the controlled clock in a kit verb named for it.
315
327
 
316
328
  Settle on the engine's own signal through a kit verb. A deadline bounds a failure but does not prove completion; reaching it must fail the story. The rule accepts failing Effect timeouts, a sleep piped directly into `Effect.andThen(Effect.fail(...))` or `Effect.andThen(Effect.die(...))`, and timeout callbacks that end by calling their enclosing Promise executor's rejection parameter. A resolving timeout or a sleep that ends successfully still guesses when the work is done.
317
329
 
@@ -389,6 +401,8 @@ Git calls `quality baseline merge <ancestor> <current> <other>`. Entries are key
389
401
 
390
402
  Package `exports` are public API, including wildcard targets and source conditions. Package `bin` and scripts, test and story globs, tool configs and `src/test-support` provide the other entry points. Imports reachable from those entries count as used. Source-conditioned package import aliases resolve to their sources before a build. Compiler mappings from `tsconfig.json` and `tsconfig.build.json` keep imports on their source files when build output exists. An internal module can be used while one of its exports remains unused. An application’s declared dependency entry points satisfy provided imports under the same policy as `imports/manifest`.
391
403
 
404
+ When Knip cannot produce a valid report, including when a tool config such as `prisma.config.ts` throws because `DATABASE_URL` is missing, `code/unused` reports one finding on the root `package.json` with the tool’s output and repair guidance. The other rules still run. This finding means unused-code analysis did not complete; repair the failure and rerun the gate.
405
+
392
406
  For adoption, run `quality baseline write --rule code/unused --file src/legacy.ts` and review the recorded debt. Burn it down by deleting unused code, removing unused dependency declarations, declaring missing dependencies, or connecting code to a real entry point. Run `quality baseline tighten` after repairs, or `quality baseline prune` across the repository. Do not add an entry point just to hide dead code.
393
407
 
394
408
  ### What the rules check
@@ -655,6 +669,8 @@ export default defineConfig({
655
669
 
656
670
  A skipped test proves nothing. `noSkippedTests` reports unconditional skips as errors, and its automatic fix is disabled: repair the test or remove a claim it cannot prove. Slow tests belong in the slow project.
657
671
 
672
+ `tests/database-url` reports direct `Config` string, redacted and URL reads and `process.env` reads of names ending in `DATABASE_URL` inside `test-support/`. It follows imports and static const aliases, including bracket access and environment destructuring. Use `postgresTestUrl` instead. Environment writes, child-app source strings and forwarding the environment to a generated app are accepted.
673
+
658
674
  The **PostgreSQL URL gate** is the only permitted skip convention: a test that needs real PostgreSQL registers conditionally on its `PLATFORM_*_TEST_DATABASE_URL`. Use `postgresTestUrl(name)` from `@shivaedev/test-sql/server/adapters/postgresTestUrl.ts` at collection time. It returns `{ url, configured }`, treats absent and empty URLs as missing, and throws when a URL is missing and `CI` is nonempty. With a URL, execute the body against PostgreSQL and let connection or setup failures fail the test. Nothing else may skip. Keep the condition next to the database setup, either in the test file or its shared `test-support` module:
659
675
 
660
676
  ```ts
@@ -7,7 +7,7 @@ or {
7
7
  `new Date()` as $match
8
8
  } where { register_diagnostic(span=$match, message="Ambient time is banned. Read time through Effect's Clock service.") },
9
9
  `Math.random()` as $match where {
10
- register_diagnostic(span=$match, message="Ambient randomness is banned. Use Effect's Crypto service for secure values and Random for non-secure values.")
10
+ register_diagnostic(span=$match, message="Ambient randomness is banned. Use Effect's SecureRandom service from effect/crypto for secure values and Random for non-secure values.")
11
11
  },
12
12
  or {
13
13
  `console.$method($...)` as $match,
@@ -44,7 +44,7 @@ or {
44
44
  `globalThis.crypto.randomBytes($...)` as $match,
45
45
  `randomUUID($...)` as $match,
46
46
  `randomBytes($...)` as $match
47
- } where { $message = "Ambient cryptographic randomness is banned. Read secure values through Effect's Crypto service." },
47
+ } where { $message = "Ambient cryptographic randomness is banned. Read secure values through Effect's SecureRandom service from effect/crypto." },
48
48
  `crypto.randomBytes($...)` as $match where {
49
49
  $program <: contains or {
50
50
  `import * as crypto from "node:crypto"`,
@@ -52,7 +52,7 @@ or {
52
52
  `import crypto from "node:crypto"`,
53
53
  `import crypto from "crypto"`
54
54
  },
55
- $message = "Ambient cryptographic randomness is banned. Read secure values through Effect's Crypto service."
55
+ $message = "Ambient cryptographic randomness is banned. Read secure values through Effect's SecureRandom service from effect/crypto."
56
56
  },
57
57
  `performance.now()` as $match where { $message = "Ambient performance time is banned. Read time through Effect's Clock service." },
58
58
  or {
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/adapters/biome/run.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAMxC,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAID,eAAO,MAAM,QAAQ;;;;;;;;;kOAiCnB,CAAC"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/adapters/biome/run.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAU,MAAM,QAAQ,CAAC;AAQxC,MAAM,WAAW,QAAQ;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAID,eAAO,MAAM,QAAQ;;;;;;;;;kOAkCnB,CAAC"}
@@ -1,16 +1,20 @@
1
1
  import { createRequire } from "node:module";
2
+ import { relative } from "node:path";
2
3
  import process from "node:process";
3
4
  import { Effect, Stream } from "effect";
4
5
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
5
6
  import { withExceptionConfig } from "#adapters/biome/withExceptionConfig.ts";
7
+ import { posix } from "#inventory/ignoreScope.ts";
6
8
  import { shadcnFiles } from "#inventory/shadcnFiles.ts";
9
+ import { skillCopies } from "#inventory/skillCopies.ts";
7
10
  const BIN = createRequire(import.meta.url).resolve("@biomejs/biome/bin/biome");
8
11
  export const runBiome = Effect.fn("Biome.runBiome")(function* (root, args, exceptions = [], nonEffectFolders = []) {
9
12
  const files = yield* shadcnFiles(root);
13
+ const copies = (yield* skillCopies(root)).paths.map((file) => posix(relative(root, file)));
10
14
  const toolOwned = [
11
15
  {
12
- files: ["**", "!**/pnpm-lock.yaml", ...files.map((file) => `!${file}`)],
13
- reason: "pnpm writes its lockfiles; canonical shadcn component filenames in the configured UI folder belong to its CLI.",
16
+ files: ["**", "!**/pnpm-lock.yaml", ...[...files, ...copies].map((file) => `!${file}`)],
17
+ reason: "pnpm, shadcn and the skills tool own their generated files and copies.",
14
18
  rules: ["biome/files/includes"],
15
19
  },
16
20
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/adapters/biome/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACxC,OAAO,E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E,QAAQ,EAAE,CAAC,CAClH,CAAC;QACF,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC,MAAM,CAAC,GAAG,CAC/C,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,EACpH,EAAE,WAAW,EAAE,WAAW,EAAE,CAC5B,CAAC;QACF,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC/C,CAAC,CAAC,EACH,gBAAgB,CAChB,CACD,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { Effect } from "effect";
2
+ import type { RuleInputs } from "#rule.ts";
3
+ export declare const databaseUrlFindings: (inputs: RuleInputs) => Effect.Effect<{
4
+ count?: number | undefined;
5
+ line?: number | undefined;
6
+ message: string;
7
+ subject?: string | undefined;
8
+ threshold?: number | undefined;
9
+ file: string;
10
+ }[], import("./ImportAnalysisFailure.ts").ImportAnalysisFailure, never>;
11
+ //# sourceMappingURL=databaseUrlFindings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databaseUrlFindings.d.ts","sourceRoot":"","sources":["../../src/adapters/databaseUrlFindings.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAQ3C,eAAO,MAAM,mBAAmB;;;;;;;uEAU9B,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { join } from "node:path";
2
+ import { Effect } from "effect";
3
+ import { importGraph } from "#imports/graph.ts";
4
+ import { isTestSupport } from "#naming/testName.ts";
5
+ import { findingAt } from "#rules/stories/syntax.ts";
6
+ import { databaseUrlReads } from "./databaseUrlReads.js";
7
+ import { storyProgram } from "./storyProgram.js";
8
+ const MESSAGE = "Reads a *DATABASE_URL variable directly in test-support. Use postgresTestUrl(name) from @shivaedev/test-sql/server/adapters/postgresTestUrl.ts so missing PostgreSQL URLs fail in CI instead of silently skipping tests.";
9
+ export const databaseUrlFindings = Effect.fn("Stories.databaseUrlFindings")(function* (inputs) {
10
+ const graph = yield* importGraph(inputs);
11
+ const program = storyProgram(inputs, graph);
12
+ const checker = program.getTypeChecker();
13
+ return inputs.sources
14
+ .filter((file) => isTestSupport(file.path))
15
+ .flatMap((file) => {
16
+ const source = program.getSourceFile(join(inputs.root, file.path));
17
+ return source === undefined ? [] : databaseUrlReads(source, checker).map((node) => ({ ...findingAt(source, node, MESSAGE), file: file.path }));
18
+ });
19
+ });
20
+ //# sourceMappingURL=databaseUrlFindings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databaseUrlFindings.js","sourceRoot":"","sources":["../../src/adapters/databaseUrlFindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,OAAO,GACZ,0NAA0N,CAAC;AAE5N,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,EAAE,CAAC,6BAA6B,CAAC,CAAC,QAAQ,CAAC,EAAE,MAAkB;IACxG,MAAM,KAAK,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IACzC,MAAM,OAAO,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC5C,MAAM,OAAO,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IACzC,OAAO,MAAM,CAAC,OAAO;SACnB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;SAC1C,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACjB,MAAM,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QACnE,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,gBAAgB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IAChJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import ts from "typescript";
2
+ export declare function databaseUrlReads(source: ts.SourceFile, checker: ts.TypeChecker): readonly ts.Node[];
3
+ //# sourceMappingURL=databaseUrlReads.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databaseUrlReads.d.ts","sourceRoot":"","sources":["../../src/adapters/databaseUrlReads.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,YAAY,CAAC;AAyB5B,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,EAAE,CAAC,WAAW,GAAG,SAAS,EAAE,CAAC,IAAI,EAAE,CAqFnG"}
@@ -0,0 +1,107 @@
1
+ import ts from "typescript";
2
+ import { importFrom } from "#rules/stories/importOrigin.ts";
3
+ import { memberName, nodesWhere, unwrapped } from "#rules/stories/syntax.ts";
4
+ const READERS = new Set(["String", "NonEmptyString", "Redacted", "URL", "string", "nonEmptyString", "redacted", "url"]);
5
+ function importedReference(node) {
6
+ const from = importFrom(node);
7
+ if (from === undefined) {
8
+ return undefined;
9
+ }
10
+ if (ts.isImportSpecifier(node)) {
11
+ return [from, (node.propertyName ?? node.name).text];
12
+ }
13
+ if (ts.isNamespaceImport(node) || (ts.isImportClause(node) && (from === "node:process" || from === "process"))) {
14
+ return [from];
15
+ }
16
+ return undefined;
17
+ }
18
+ function bindingName(node) {
19
+ const name = node.propertyName ?? node.name;
20
+ return ts.isIdentifier(name) || ts.isStringLiteralLike(name) ? name.text : undefined;
21
+ }
22
+ export function databaseUrlReads(source, checker) {
23
+ const visiting = new Set();
24
+ function declaration(node) {
25
+ if (ts.isVariableDeclaration(node) && node.initializer !== undefined && (node.parent.flags & ts.NodeFlags.Const) !== 0) {
26
+ return value(node.initializer);
27
+ }
28
+ if (ts.isBindingElement(node) && ts.isObjectBindingPattern(node.parent) && ts.isVariableDeclaration(node.parent.parent)) {
29
+ const base = declaration(node.parent.parent);
30
+ const name = bindingName(node);
31
+ return base !== undefined && name !== undefined ? [...base, name] : undefined;
32
+ }
33
+ return importedReference(node);
34
+ }
35
+ function value(expression) {
36
+ const node = unwrapped(expression);
37
+ if (visiting.has(node)) {
38
+ return undefined;
39
+ }
40
+ visiting.add(node);
41
+ const result = reference(node);
42
+ visiting.delete(node);
43
+ return result;
44
+ }
45
+ function reference(node) {
46
+ if (ts.isStringLiteralLike(node)) {
47
+ return [node.text];
48
+ }
49
+ if (ts.isIdentifier(node)) {
50
+ const symbol = checker.getSymbolAtLocation(node);
51
+ return (symbol?.declarations?.map(declaration).find((item) => item !== undefined)
52
+ ?? (symbol === undefined && node.text === "process" ? ["process"] : undefined));
53
+ }
54
+ if (ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node)) {
55
+ return access(node);
56
+ }
57
+ return undefined;
58
+ }
59
+ function access(node) {
60
+ const base = value(node.expression);
61
+ const name = memberName(node) ?? (ts.isElementAccessExpression(node) ? value(node.argumentExpression)?.[0] : undefined);
62
+ return base !== undefined && name !== undefined ? [...base, name] : undefined;
63
+ }
64
+ function environment(path) {
65
+ return path?.length === 2 && (path[0] === "process" || path[0] === "node:process") && path[1] === "env";
66
+ }
67
+ function databaseName(path) {
68
+ return path?.length === 1 && path[0]?.endsWith("DATABASE_URL") === true;
69
+ }
70
+ function environmentBinding(node) {
71
+ if (node.dotDotDotToken !== undefined || !ts.isObjectBindingPattern(node.parent)) {
72
+ return false;
73
+ }
74
+ const parent = node.parent.parent;
75
+ return (ts.isVariableDeclaration(parent)
76
+ && parent.initializer !== undefined
77
+ && environment(value(parent.initializer))
78
+ && bindingName(node)?.endsWith("DATABASE_URL") === true);
79
+ }
80
+ function read(node) {
81
+ if (ts.isCallExpression(node)) {
82
+ const path = value(node.expression);
83
+ const method = path?.at(-1) ?? "";
84
+ const argument = node.arguments[method === "schema" ? 1 : 0];
85
+ return (path !== undefined
86
+ && (READERS.has(method) || method === "schema")
87
+ && path.slice(0, -1).join("/") === "effect/Config"
88
+ && argument !== undefined
89
+ && databaseName(value(argument)));
90
+ }
91
+ if (ts.isBindingElement(node)) {
92
+ return environmentBinding(node);
93
+ }
94
+ if (!(ts.isPropertyAccessExpression(node) || ts.isElementAccessExpression(node))) {
95
+ return false;
96
+ }
97
+ const path = value(node);
98
+ return environment(path?.slice(0, -1)) && databaseName(path?.slice(-1)) && !write(node);
99
+ }
100
+ return nodesWhere(source, read);
101
+ }
102
+ function write(node) {
103
+ const parent = node.parent;
104
+ return (ts.isDeleteExpression(parent)
105
+ || (ts.isBinaryExpression(parent) && parent.left === node && parent.operatorToken.kind === ts.SyntaxKind.EqualsToken));
106
+ }
107
+ //# sourceMappingURL=databaseUrlReads.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"databaseUrlReads.js","sourceRo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M,CAAC,IAAI,KAAK,IAAI,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,KAAK,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,CACrH,CAAC;AACH,CAAC"}
@@ -6,7 +6,7 @@ import { posix } from "#inventory/ignoreScope.ts";
6
6
  const NODE_MODULES = "/node_modules/";
7
7
  const ASSET_DECLARATION = /\.d(?<extension>\.[^./]+)\.ts$/u;
8
8
  const DECLARATION = /\.d\.[cm]?ts$/u;
9
- const QUERY = /\?.*$/u;
9
+ const QUERY = /(?<=\.wasm)\?init$|\?(?:(?:shared)?worker(?:&(?:inline|url))?|raw|url(?:&(?:no-)?inline)?|(?:no-)?inline)$/u;
10
10
  const PACKAGE_IMPORT = "#";
11
11
  const PACKAGE_JSON = "package.json";
12
12
  const presumingHost = {
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.js","sourceRoot":"","sources":["../../../src/adapters/imports/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,MAAM,YAAY,CAAC;AAI5B,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7E,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAGlD,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAEtC,MAAM,iBAAiB,GAAG,iCAAiC,CAAC;AAE5D,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC,MAAM,KAAK,GAAG,QAAQ,CAAC;AAEvB,MAAM,cAAc,GAAG,GAAG,CAAC;AAE3B,MAAM,YAAY,GAAG,cAAc,CAAC;AAEpC,MAAM,aAAa,GAA4B;IAC9C,GAAG,EAAE,CAAC,GAAG;IACT,eAAe,EAAE,GAAG,EAAE,CAAC,IAAI;IAC3B,UAAU,EAAE,CAAC,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EAAE,CAAC;IACtG,CAAC;IACD,MAAM,MAAM,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC;IAC3C,OAAO,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AACvI,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,IAAY,EAAE,OAAgB,EAAE,OAAsB,EAAE,IAAY,EAAE,OAAgB;IACnH,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC/C,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC3B,OAAO,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;IACnE,CAAC;IACD,MAAM,IAAI,GAAG,YAAY,CAAC,OAAO,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAClD,IAAI,IAAI,KAAK,SAAS,EAAE,CAAC;QACxB,OAAO,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,OAAO,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,CAAC,KAAK,CAAC;QAC/C,CAAC,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE;QAC/F,CAAC,CAAC,SAAS,CAAC;AACd,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { Findings } from "#rule.ts";
2
+ export declare function knipReport(stdout: string, stderr: string, code: number): Findings;
3
+ //# sourceMappingURL=report.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/report.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAGzC,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CAkBjF"}
@@ -0,0 +1,22 @@
1
+ import { knipFindings } from "./findings.js";
2
+ export function knipReport(stdout, stderr, code) {
3
+ let report;
4
+ let failure;
5
+ try {
6
+ report = knipFindings(stdout);
7
+ if (code === (report.length > 0 ? 1 : 0)) {
8
+ return report;
9
+ }
10
+ failure = `knip exited ${code} inconsistently with its report:\n${stderr || stdout}`;
11
+ }
12
+ catch {
13
+ failure = `knip exited ${code} without a valid report:\n${stderr || stdout || "No output."}`;
14
+ }
15
+ return [
16
+ {
17
+ file: "package.json",
18
+ message: `Unused-code analysis did not complete. Repair the tool configuration or command failure and rerun quality lint. ${failure}`,
19
+ },
20
+ ];
21
+ }
22
+ //# sourceMappingURL=report.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"report.js","sourceRoot":"","sources":["../../../src/adapters/knip/report.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,MAAM,UAAU,UAAU,CAAC,MAAc,EAAE,MAAc,EAAE,IAAY;IACtE,IAAI,MAAgB,CAAC;IACrB,IAAI,OAAe,CAAC;IACpB,IAAI,CAAC;QACJ,MAAM,GAAG,YAAY,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC1C,OAAO,MAAM,CAAC;QACf,CAAC;QACD,OAAO,GAAG,eAAe,IAAI,qCAAqC,MAAM,IAAI,MAAM,EAAE,CAAC;IACtF,CAAC;IAAC,MAAM,CAAC;QACR,OAAO,GAAG,eAAe,IAAI,6BAA6B,MAAM,IAAI,MAAM,IAAI,YAAY,EAAE,CAAC;IAC9F,CAAC;IACD,OAAO;QACN;YACC,IAAI,EAAE,cAAc;YACpB,OAAO,EAAE,mHAAmH,OAAO,EAAE;SACrI;KACD,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
1
  import { Effect } from "effect";
2
2
  import type { RuleInputs } from "#rule.ts";
3
- export declare const runKnip: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").Finding[], Error | import("effect/PlatformError").PlatformError, import("#rule.ts").RuleServices>;
3
+ export declare const runKnip: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").Finding[], import("../../inventory/filesystem.ts").FilesystemFailure | import("../ImportAnalysisFailure.ts").ImportAnalysisFailure | import("effect/PlatformError").PlatformError | import("../../failure.ts").SetupFailure, import("#rule.ts").RuleServices>;
4
4
  //# sourceMappingURL=run.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/run.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAsB,MAAM,QAAQ,CAAC;AAIpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAc3C,eAAO,MAAM,OAAO,4JAuDlB,CAAC"}
1
+ {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/run.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAsB,MAAM,QAAQ,CAAC;AAIpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAe3C,eAAO,MAAM,OAAO,wTAkDlB,CAAC"}
@@ -8,7 +8,8 @@ import { readPackageManifest } from "#adapters/manifestInventory.ts";
8
8
  import { shadcnFolders } from "#inventory/shadcnFolders.ts";
9
9
  import { knipConfiguration } from "./configuration.js";
10
10
  import { entryPointFindings } from "./entryPointFindings.js";
11
- import { KNIP_ISSUES, knipFindings } from "./findings.js";
11
+ import { KNIP_ISSUES } from "./findings.js";
12
+ import { knipReport } from "./report.js";
12
13
  import { sourceConfig } from "./sourceConfig.js";
13
14
  const API = createRequire(import.meta.url).resolve("knip");
14
15
  const BIN = join(dirname(API), "..", "bin", "knip.js");
@@ -53,10 +54,7 @@ export const runKnip = Effect.fn("Knip.runKnip")(function* (inputs) {
53
54
  "--no-progress",
54
55
  ], { cwd, env: { "JITI_TRY_NATIVE": "true" }, extendEnv: true, stdin: "ignore" }));
55
56
  const [stdout, stderr, code] = yield* Effect.all([Stream.mkString(Stream.decodeText(child.stdout)), Stream.mkString(Stream.decodeText(child.stderr)), child.exitCode], { concurrency: "unbounded" });
56
- const report = yield* Effect.try(() => knipFindings(stdout)).pipe(Effect.mapError(() => new Error(`knip exited ${code} without a valid report:\n${stderr || stdout || "No output."}`)));
57
- if (Number(code) !== (report.length > 0 ? 1 : 0)) {
58
- return yield* Effect.fail(new Error(`knip exited ${code} inconsistently with its report:\n${stderr || stdout}`));
59
- }
57
+ const report = knipReport(stdout, stderr, Number(code));
60
58
  return report.filter((finding) => checked.has(finding.file));
61
59
  }));
62
60
  return yield* entryPointFindings(inputs, findings);
@@ -1 +1 @@
1
- {"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/adapters/knip/run.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,OAAO,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EA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,CAAC,EAAE,KAAK,CAAC,QAAQ,CAAC,EACpH,EAAE,WAAW,EAAE,WAAW,EAAE,CAC5B,CAAC;QACF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;IAC9D,CAAC,CAAC,CACF,CAAC;IACF,OAAO,KAAK,CAAC,CAAC,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACpD,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"outsideImportFindings.d.ts","sourceRoot":"","sources":["../../src/adapters/outsideImportFindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAKhF,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AA2CpD,eAAO,MAAM,qBAAqB,yFA+ChC,CAAC"}
1
+ {"version":3,"file":"outsideImportFindings.d.ts","sourceRoot":"","sources":["../../src/adapters/outsideImportFindings.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAMhF,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AA0BpD,eAAO,MAAM,qBAAqB,yFA6ChC,CAAC"}
@@ -1,42 +1,28 @@
1
1
  import { Effect } from "effect";
2
- import ts from "typescript";
3
2
  import { readPackageManifest } from "#adapters/manifestInventory.ts";
4
3
  import { importGraph } from "#imports/graph.ts";
5
4
  import { packageNameOf } from "#imports/packageName.ts";
6
5
  import { packageOf } from "#imports/workspace.ts";
7
- import { parse } from "#rules/parse.ts";
8
- function onlyInlineTypes(statement) {
9
- if (ts.isImportDeclaration(statement)) {
10
- const clause = statement.importClause;
11
- const bindings = clause?.namedBindings;
12
- return (clause?.name === undefined
13
- && bindings !== undefined
14
- && ts.isNamedImports(bindings)
15
- && bindings.elements.length > 0
16
- && bindings.elements.every((item) => item.isTypeOnly));
17
- }
18
- const exports = ts.isExportDeclaration(statement) ? statement.exportClause : undefined;
19
- return exports !== undefined && ts.isNamedExports(exports) && exports.elements.length > 0 && exports.elements.every((item) => item.isTypeOnly);
20
- }
21
- function inlineTypes(inputs) {
22
- const sites = new Set();
23
- for (const file of inputs.sources) {
24
- const source = parse(file);
25
- if (source === undefined) {
26
- continue;
27
- }
28
- for (const statement of source.statements.filter(onlyInlineTypes)) {
29
- sites.add(`${file.path}:${source.getLineAndCharacterOfPosition(statement.getStart(source)).line + 1}`);
30
- }
31
- }
32
- return sites;
33
- }
6
+ import { testName } from "#naming/testName.ts";
7
+ const CLIENT_RENDERING_LIBRARIES = new Set([
8
+ "react",
9
+ "react-dom",
10
+ "lucide-react",
11
+ "@base-ui/react",
12
+ "@tanstack/react-router",
13
+ "@tanstack/react-table",
14
+ "class-variance-authority",
15
+ "cn",
16
+ "clsx",
17
+ "tailwind-merge",
18
+ ]);
34
19
  function exempt(path, name) {
35
20
  return (/(?:^|\/)(?:adapters|test-support)\//u.test(path)
21
+ || (name === "vitest" && testName(path)?.modifiers.includes("unit") === true)
36
22
  || name === "effect"
37
23
  || name.startsWith("@effect/")
38
24
  || name.startsWith("@shivaedev/")
39
- || ((name === "react" || name === "react-dom") && /(?:^|\/)client\//u.test(path)));
25
+ || (CLIENT_RENDERING_LIBRARIES.has(name) && /(?:^|\/)client\//u.test(path)));
40
26
  }
41
27
  export const outsideImportFindings = Effect.fn("Imports.outsideImportFindings")(function* (inputs) {
42
28
  const graph = yield* importGraph(inputs);
@@ -48,7 +34,6 @@ export const outsideImportFindings = Effect.fn("Imports.outsideImportFindings")(
48
34
  new Set(Object.keys({ ...manifest?.dependencies, ...manifest?.peerDependencies, ...manifest?.optionalDependencies })),
49
35
  ];
50
36
  }), { concurrency: "unbounded" }));
51
- const types = inlineTypes(inputs);
52
37
  const workspace = new Set(graph.packages.map((owner) => owner.name));
53
38
  const sites = [
54
39
  ...graph.edges.flatMap((edge) => (edge.to.kind === "external" ? [{ ...edge, name: edge.to.package }] : [])),
@@ -61,7 +46,6 @@ export const outsideImportFindings = Effect.fn("Imports.outsideImportFindings")(
61
46
  if (workspace.has(site.name)
62
47
  || site.type
63
48
  || site.kind !== "import"
64
- || types.has(`${site.from}:${site.line}`)
65
49
  || exempt(site.from, site.name)
66
50
  || !(site.name.startsWith("node:") || runtime.get(directory)?.has(site.name))) {
67
51
  return [];