@shivaedev/quality 0.48.1 → 0.49.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 (108) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +58 -11
  3. package/biome/plugins/ambient-runtime.grit +67 -1
  4. package/biome/plugins/type-re-exports.grit +33 -4
  5. package/dist/adapters/biome/run.js +4 -4
  6. package/dist/adapters/biome/run.js.map +1 -1
  7. package/dist/adapters/fixJsxConditionals.d.ts.map +1 -1
  8. package/dist/adapters/fixJsxConditionals.js +2 -5
  9. package/dist/adapters/fixJsxConditionals.js.map +1 -1
  10. package/dist/adapters/knip/configuration.d.ts +5 -2
  11. package/dist/adapters/knip/configuration.d.ts.map +1 -1
  12. package/dist/adapters/knip/configuration.js +12 -5
  13. package/dist/adapters/knip/configuration.js.map +1 -1
  14. package/dist/adapters/knip/run.d.ts +2 -3
  15. package/dist/adapters/knip/run.d.ts.map +1 -1
  16. package/dist/adapters/knip/run.js +25 -7
  17. package/dist/adapters/knip/run.js.map +1 -1
  18. package/dist/adapters/knip/sourceConfig.d.ts.map +1 -1
  19. package/dist/adapters/knip/sourceConfig.js +3 -0
  20. package/dist/adapters/knip/sourceConfig.js.map +1 -1
  21. package/dist/baseline/looseStagedEntries.d.ts +4 -0
  22. package/dist/baseline/looseStagedEntries.d.ts.map +1 -0
  23. package/dist/baseline/looseStagedEntries.js +31 -0
  24. package/dist/baseline/looseStagedEntries.js.map +1 -0
  25. package/dist/baseline/update.d.ts +1 -1
  26. package/dist/baseline/update.d.ts.map +1 -1
  27. package/dist/baseline/update.js +3 -3
  28. package/dist/baseline/update.js.map +1 -1
  29. package/dist/cli/args.d.ts +1 -1
  30. package/dist/cli/args.d.ts.map +1 -1
  31. package/dist/cli/args.js +5 -5
  32. package/dist/cli/args.js.map +1 -1
  33. package/dist/cli/baseline.d.ts +1 -1
  34. package/dist/cli/baseline.d.ts.map +1 -1
  35. package/dist/cli/baseline.js +19 -2
  36. package/dist/cli/baseline.js.map +1 -1
  37. package/dist/cli/lint.d.ts +1 -1
  38. package/dist/cli/lint.d.ts.map +1 -1
  39. package/dist/cli/lint.js +11 -2
  40. package/dist/cli/lint.js.map +1 -1
  41. package/dist/cli/messages.d.ts +1 -1
  42. package/dist/cli/messages.d.ts.map +1 -1
  43. package/dist/cli/messages.js +3 -3
  44. package/dist/cli/program.d.ts.map +1 -1
  45. package/dist/cli/program.js +3 -2
  46. package/dist/cli/program.js.map +1 -1
  47. package/dist/hooks/preCommit.js +1 -1
  48. package/dist/hooks/preCommit.js.map +1 -1
  49. package/dist/inventory/collect.js +3 -3
  50. package/dist/inventory/collect.js.map +1 -1
  51. package/dist/inventory/shadcnFiles.d.ts +4 -0
  52. package/dist/inventory/shadcnFiles.d.ts.map +1 -0
  53. package/dist/inventory/shadcnFiles.js +83 -0
  54. package/dist/inventory/shadcnFiles.js.map +1 -0
  55. package/dist/report/render.d.ts.map +1 -1
  56. package/dist/report/render.js +3 -10
  57. package/dist/report/render.js.map +1 -1
  58. package/dist/report/staleSections.js +1 -1
  59. package/dist/report/staleSections.js.map +1 -1
  60. package/dist/rules/builtIn.d.ts +1 -1
  61. package/dist/rules/importOrigins.d.ts +4 -0
  62. package/dist/rules/importOrigins.d.ts.map +1 -0
  63. package/dist/rules/importOrigins.js +36 -0
  64. package/dist/rules/importOrigins.js.map +1 -0
  65. package/dist/rules/noBarrel.d.ts.map +1 -1
  66. package/dist/rules/noBarrel.js +19 -7
  67. package/dist/rules/noBarrel.js.map +1 -1
  68. package/dist/rules/react/jsxChildDecision.d.ts +5 -0
  69. package/dist/rules/react/jsxChildDecision.d.ts.map +1 -0
  70. package/dist/rules/react/jsxChildDecision.js +74 -0
  71. package/dist/rules/react/jsxChildDecision.js.map +1 -0
  72. package/dist/rules/react/jsxConditionals.d.ts.map +1 -1
  73. package/dist/rules/react/jsxConditionals.js +9 -33
  74. package/dist/rules/react/jsxConditionals.js.map +1 -1
  75. package/dist/rules/secondNames.d.ts +7 -0
  76. package/dist/rules/secondNames.d.ts.map +1 -0
  77. package/dist/rules/secondNames.js +98 -0
  78. package/dist/rules/secondNames.js.map +1 -0
  79. package/dist/rules/stories/importBindings.d.ts.map +1 -1
  80. package/dist/rules/stories/importBindings.js +3 -0
  81. package/dist/rules/stories/importBindings.js.map +1 -1
  82. package/dist/rules/unusedCode.d.ts +1 -1
  83. package/dist/rules/unusedCode.d.ts.map +1 -1
  84. package/docs/debt-and-hooks.md +5 -5
  85. package/package.json +4 -4
  86. package/src/adapters/biome/run.ts +4 -4
  87. package/src/adapters/fixJsxConditionals.ts +2 -8
  88. package/src/adapters/knip/configuration.ts +12 -5
  89. package/src/adapters/knip/run.ts +27 -7
  90. package/src/adapters/knip/sourceConfig.ts +3 -0
  91. package/src/baseline/looseStagedEntries.ts +32 -0
  92. package/src/baseline/update.ts +5 -2
  93. package/src/cli/args.ts +6 -7
  94. package/src/cli/baseline.ts +19 -1
  95. package/src/cli/lint.ts +11 -1
  96. package/src/cli/messages.ts +3 -3
  97. package/src/cli/program.ts +3 -2
  98. package/src/hooks/preCommit.ts +1 -1
  99. package/src/inventory/collect.ts +3 -3
  100. package/src/inventory/shadcnFiles.ts +87 -0
  101. package/src/report/render.ts +3 -10
  102. package/src/report/staleSections.ts +1 -1
  103. package/src/rules/importOrigins.ts +38 -0
  104. package/src/rules/noBarrel.ts +21 -8
  105. package/src/rules/react/jsxChildDecision.ts +84 -0
  106. package/src/rules/react/jsxConditionals.ts +9 -35
  107. package/src/rules/secondNames.ts +121 -0
  108. package/src/rules/stories/importBindings.ts +3 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.49.0 - 2026-10-31
4
+
5
+ ### Changed
6
+
7
+ - Generated starters import schedule definitions and the default queue client factory from their defining modules.
8
+
9
+ ### Fixed
10
+
11
+ - Report ambient runtime workarounds in core code: runners over Clock, Config and Random, unsafe clock reads, cryptographic randomness, performance time, process state and scheduling. Entry points, tool configs, adapters and test-support retain their boundary role for these checks.
12
+ - Surface knip's error output and exit code when analysis produces no valid report, and reject exits inconsistent with the report.
13
+ - Resolve analysis and tool configuration within the checked checkout, including git worktrees nested in another checkout.
14
+ - Count migration-folder modules, shadcn UI imports, CSS imports and custom Vitest configurations as entry points so plain apps retain their used dependencies and test support.
15
+ - Generated apps prune their copied baseline after formatting and before the initial commit, so repaired debt cannot block the strict commit gate.
16
+ - Generated app guidance shows file-scoped baseline writes and stages new files before recording their debt.
17
+ - Failing reports point moved files to baseline pruning instead of suggesting repo-wide debt recording.
18
+ - Report exported type aliases of imports, value aliases with `typeof` annotations or local const chains, object facades and unchanged forwarding functions, with repairs naming their defining modules. Keep wrappers that transform inputs, add steps, supply defaults or declare overloads.
19
+ - Limit shadcn exclusions to canonical registry filenames inside the configured UI folder, so hand-written neighbors receive source rules and Biome lint, formatting and fixes. Keep skipped components in the unused-code import graph so dependencies they import count as used.
20
+
21
+ ### Breaking
22
+
23
+ - Repositories upgrading Quality must repair the newly reported ambient access or record existing adoption debt with `quality baseline write --rule biome/plugin`, then lower it as repairs land.
24
+ - `createApp` reads secret bytes from Effect's Crypto service. Applications embedding this Effect must provide `Crypto.Crypto`, for example with `NodeServices.layer` or `NodeCrypto.layer` from `@effect/platform-node`. The create-app command already provides it.
25
+ - The pg-boss testing-expiration bridge moved from `@shivaedev/jobs/server/internal/testingExpirations.ts` to `@shivaedev/jobs/server/adapters/testingExpirations.ts`. Consumers importing that internal path must import the adapter path instead.
26
+ - Recording an existing baseline now requires `--rule <id> --file <path>`, and every selected file must be changed since `HEAD`. Replace repo-wide rule writes with explicit changed paths, repeating `--file` as needed; stage new files first. Direct callers pass selected paths as `writeBaseline`'s fourth argument. Initial adoption without a baseline still records existing debt once. For renames, use `quality baseline prune --against <base>` to carry existing counts.
27
+ - Pre-commit rejects staged baseline counts that allow more findings than remain in their files. Run `quality baseline tighten --staged` and stage the resulting baseline changes before committing a repair.
28
+ - Quality: the gate now rejects imported second names even when they use type aliases, value annotations, object facades or forwarding functions. Import from the defining module and remove the second name; existing facade debt can be recorded at adoption. Import `USAGE` from `cli/messages.ts` instead of `cli/args.ts`.
29
+ - Jobs: import `defaultClientFactory` from `@shivaedev/jobs/server/defaultClientFactory.ts` instead of `server/client.ts`. Import `defineSchedule` from `@shivaedev/jobs/server/defineSchedule.ts` instead of `server/definition.ts`. The removed `server/internal/nativeClient.ts` and `server/internal/scheduleDefinition.ts` exports migrate to those same modules as `defaultClientFactory` and `defineSchedule`. The default factory now exposes its native pg-boss return type; type custom factory mocks against `PgBossClient` or `PgBossClientFactory` from `server/client.ts`.
30
+ - React: import `resumeSignal`, `ResumeOptions`, `ResumeSource` and `ResumeWindow` from `@shivaedev/contract/resume.ts`; `@shivaedev/react/resumeSignal.ts` is removed.
31
+ - Work Board: import `Identity` from `path/Identity.ts`, view state helpers from `browser/views/state.ts`, `isMarkdown` from `path/isMarkdown.ts`, and `processes` from `server/processOwnership.ts`. The forwarding `server/views/state.ts` and `server/integration/processes.ts` modules are removed. Replace the removed `attention` facade with imports of `managedRequestReceipt` from `server/attention/managedRequestReceipt.ts`, `attentionProjection` from `server/attention/projection.ts`, and `RequestReceipt` from `attention/RequestReceipt.ts`. Replace the removed `publication` facade with direct imports from `server/responses/publicationDirectory.ts`. Import `Changes` from `server/files/changes.ts`, `MarkdownFile` from `server/files/list.ts`, `Snapshot` from `server/search/snapshot.ts`, metadata document/model/diagnostic/parsed types from `integration/metadata.ts`, `InboxProjection` from `browser/views/schema.ts` instead of `AttentionProjection`, `SourceFailure` from `diagnostics/source.ts`, and `WorkspaceOptions` from `server/workspace.ts` instead of the integration facades. Metadata types are also removed from `server/metadata/model.ts` and `server/metadata/parse.ts`; import them from `integration/metadata.ts`.
32
+ - Work Fleet: import `WAIT_EXIT`, `WaitState`, `WaitOutcome` and `settled` from `host/waitOutcome.ts` instead of `host/wait.ts`; import `fleetRecords` from `fleetRecords.ts` instead of `operations.ts`.
33
+
34
+ ## 0.48.2 - 2026-10-31
35
+
36
+ ### Fixed
37
+
38
+ - Limit `react/jsx-conditionals` and its mechanical fix to decisions in returned component JSX. Accept JSX built in a `const` before the return, library callbacks and ternaries between plain string or number literals. Document accepted decisions, attributes, extracted components and list separators.
39
+
3
40
  ## 0.48.1 - 2026-10-30
4
41
 
5
42
  ### Fixed
package/README.md CHANGED
@@ -21,7 +21,7 @@ Adopt Quality's policy as a whole. Quality owns the shared rules, their defaults
21
21
  A **rule** checks a repository and returns **findings**, each naming a file and what to change. Built-in and local rules always run at `error`. A finding normally counts once; a limit rule counts how far the file exceeds its limit. Use the defaults and keep checks strict. The config rejects warning levels, disabled rules, raised thresholds and inventory exclusions.
22
22
 
23
23
  Two records explain findings the repository deliberately keeps:
24
- - The **baseline** records existing debt by rule and file, as a maximum count. It makes strict checks usable before every file is cleaned up. `tighten` and `prune` lower the counts as debt disappears; explicitly writing a named rule again can raise them, and that diff needs review.
24
+ - The **baseline** records existing debt by rule and file, as a maximum count. It makes strict checks usable before every file is cleaned up. `tighten` and `prune` lower the counts as debt disappears; explicitly writing a named rule for a changed file can raise its count, and that diff needs review.
25
25
  - The config's **exceptions** list records permanent exceptions once, each with files, rules, a reason and optionally a Quality finding's `subject`. One declaration covers both Quality and Biome rules. A rule may refuse exceptions. An entry that no longer applies fails the gate instead of silently excusing future code.
26
26
 
27
27
  Exceptions apply first, then the baseline. With the default rule settings, remaining findings fail in one report grouped by rule. A baseline entry with fewer findings left is a note, so removing debt passes immediately. An entry for an unknown or disabled rule fails; debt records must still name a check that runs.
@@ -40,9 +40,11 @@ Interrupting a run stops its Biome and knip processes and removes their scoped t
40
40
 
41
41
  Only folders named `adapters/` or `test-support/`, at any depth, are exempt from this boundary rule. An `adapters/` folder bridges an outside library and hands the rest of the application Effect values. The name is fixed by convention, with no config or copied Biome plugin globs. Code that cannot be Effect belongs in that bridge or calls for a better Effect primitive. Adapter code still follows `effect/service-parameters` and the ambient time, randomness, console and environment bans.
42
42
 
43
+ The `ambient-runtime` Biome plugin also reports `Effect.run*` calls whose computation contains `Clock`, `Config` or `Random`, `currentTimeMillisUnsafe`, crypto UUIDs and bytes, `performance.now`, process arguments, working directory and exit state, `globalThis.process.env`, timeouts and microtasks. Yield service computations in the caller's Effect so its environment controls them. These additional checks apply to core TypeScript code. They accept `cli.ts`, `main.ts`, `*-cli.ts`, modules that call `runMain`, use `NodeRuntime.runMain` or guard execution with `fileURLToPath(import.meta.url) === process.argv[1]`, tool configs, tests, `adapters/` and `test-support/`. The existing `Date.now()`, `new Date()`, `Math.random()`, console and direct `process.env` bans still apply there.
44
+
43
45
  `effect/service-parameters` reports parameters carrying a service in exported functions and public methods, including returned factories. It follows service classes and tags, non-empty Contexts and service implementation shapes through aliases, interfaces, generic constraints, inferred parameters and destructuring. Read services from Effect's environment instead. An Effect or Stream requiring a service is a computation and is accepted. Methods implementing a service and functions constructing Layers may take services as parameters. Only `test-support/` folders are exempt from this rule; `adapters/` folders are checked.
44
46
 
45
- Both rules refuse config exceptions and inline suppressions. Record existing debt with `quality baseline write --rule effect/boundary` and `quality baseline write --rule effect/service-parameters`; the normal report and baseline burn-down apply.
47
+ Both rules refuse config exceptions and inline suppressions. Record existing debt with `quality baseline write --rule effect/boundary --file src/legacy.ts` and `quality baseline write --rule effect/service-parameters --file src/legacy.ts`; the normal report and baseline burn-down apply.
46
48
 
47
49
  ### 1. Once per repository: connect the shared policy
48
50
 
@@ -85,9 +87,9 @@ quality hooks install
85
87
 
86
88
  For an application setup script, use `quality setup`. It installs the same hook when the current folder has its own `.git` entry, including a linked worktree. An unversioned app or an app inside another repository leaves hooks alone.
87
89
 
88
- Installing the package does not install a hook. `hooks install` writes the repository's pre-commit hook. A hook Quality did not write is kept unless `--force` replaces it. For an existing repository, `quality baseline write` records error-level findings when there is no baseline; it refuses to regenerate an existing baseline without `--rule <id>`.
90
+ Installing the package does not install a hook. `hooks install` writes the repository's pre-commit hook. A hook Quality did not write is kept unless `--force` replaces it. For an existing repository, `quality baseline write` records error-level findings when there is no baseline; later writes require `--rule <id>` and `--file <path>`. Each selected path must be changed since `HEAD`; stage new files first. Initial adoption without a baseline may record the repository once.
89
91
 
90
- When upgrading Quality, the starter and apps generated by create-app provide `pnpm baseline write --rule <id>`. Record each new rule’s existing findings, review the baseline diff, and land the upgrade before burning down that debt. Checks remain strict for findings above the recorded counts. After repairs, run `pnpm baseline tighten` to lower the touched files’ debt.
92
+ When upgrading Quality, the starter and apps generated by create-app provide `pnpm baseline write --rule <id> --file <path>`. Record each new rule’s findings in the changed files, review the baseline diff, and land the upgrade before burning down that debt. Checks remain strict for findings above the recorded counts. After repairs, run `pnpm baseline tighten` to lower the touched files’ debt.
91
93
 
92
94
  Use `pnpm format --rule react/jsx-conditionals` (or `quality fix --rule react/jsx-conditionals`) for mechanical repairs. It extracts a conditional child into a variable before its return when the enclosing intrinsic elements or fragments have no attributes or other children. It preserves the conditional expression, including falsy values such as `0`, and leaves mapped children, component elements and evaluation-sensitive cases for manual repair. Remaining findings are printed and exit 1 even when the baseline covers them. The rule-specific command does not run Biome’s unsafe fixes.
93
95
 
@@ -103,7 +105,7 @@ export default defineConfig({ sources: ["src"] });
103
105
 
104
106
  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`.
105
107
 
106
- Quality discovers each app’s `components.json` and resolves `aliases.ui` through its TypeScript paths or package imports. That folder belongs to the shadcn CLI: source rules and Biome lint, formatting and fixes skip it by default. Neighbouring authored folders stay checked. This leaves TypeScript’s inputs unchanged, so type checking still covers the stock components.
108
+ 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.
107
109
 
108
110
  Module folders under `src/modules/<name>` use the same `client/` and `server/` import boundaries as the foundation, and their shared declarations remain independent of both runtimes.
109
111
 
@@ -221,10 +223,10 @@ quality baseline tighten
221
223
  When a Quality upgrade adds a check, or a reviewed change needs to record one rule's findings again:
222
224
 
223
225
  ```sh
224
- quality baseline write --rule tests/story-setup
226
+ quality baseline write --rule tests/story-setup --file src/orders.spec.ts
225
227
  ```
226
228
 
227
- Keep the default error level. The command replaces that rule's entries and leaves other rules' entries alone. Call out any new or raised count in the review and the pull request description. The [debt and hook guide](https://github.com/ShivaeDev/platform/blob/main/packages/quality/docs/debt-and-hooks.md) covers the baseline format, exception subjects, limit changes, renames and commit checks.
229
+ Keep the default error level. The command replaces that rule's entries only for the selected changed files. Repeat `--file` for additional paths; every other entry stays unchanged. Call out any new or raised count in the review and the pull request description. The [debt and hook guide](https://github.com/ShivaeDev/platform/blob/main/packages/quality/docs/debt-and-hooks.md) covers the baseline format, exception subjects, limit changes, renames and commit checks.
228
230
 
229
231
  ### Baseline merges
230
232
 
@@ -245,18 +247,18 @@ Git calls `quality baseline merge <ancestor> <current> <other>`. Entries are key
245
247
 
246
248
  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`.
247
249
 
248
- For adoption, run `quality baseline write --rule code/unused` 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.
250
+ 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.
249
251
 
250
252
  ### What the rules check
251
253
 
252
254
  `quality lint` prints each failing rule's guidance with its findings, so the finding is the reference for what to change. The built-in rules fall into these groups:
253
- - **Structure:** `structure/max-lines` allows 150 lines in a source file and 300 in test code, `nesting/max-depth` rejects lines indented eight tabs deep, and `structure/no-barrel` rejects `index` modules. The preset rejects every re-export, types included; when `noExportedImports` suggests `export … from`, import the name where it is used instead. A module does one job.
255
+ - **Structure:** `structure/max-lines` allows 150 lines in a source file and 300 in test code, `nesting/max-depth` rejects lines indented eight tabs deep, and `structure/no-barrel` rejects `index` modules, exported value aliases (including `typeof` annotations and local const chains), facades of imports and functions that only forward their parameters unchanged to an import. Overloaded adapters keep their own meaning. The preset rejects bare type aliases of named or default imports as well as explicit type re-exports; each repair names the defining module. When `noExportedImports` suggests `export … from`, import the name where it is used instead. A module does one job.
254
256
  - **Comments:** the `comments/*` rules reject JSDoc, TODOs, banners, line and pull request references, environment pragmas and more than two comments per file. A comment says why, never what the code already says or what it used to be. A tool pragma such as `@jsxImportSource` counts as a comment until both `comments/no-jsdoc` and `comments/max-per-file` list its tag in their `allow` option.
255
257
  - **Documentation:** `docs/references` checks every Markdown file in the sources except `CHANGELOG.md`, whose released history keeps the links of its release. Relative links, reference definitions and `href`/`src` attributes reach an existing file or folder inside the repository, and a heading anchor matches one GitHub forms from the target's headings. A link to the repository's own GitHub tree, named by the root `package.json` `repository` field, is checked like a relative one unless it is pinned to a commit or a release tag. A published workspace package's README is shown on npm without the repository around it, so its links that leave the package use absolute URLs. Imports in TypeScript and JavaScript code blocks, workspace module paths such as `@scope/lib/repository.ts` written as inline code, `` `name` from `module` `` phrases and a package README's API rows resolve through the owning package's `exports` to an exported module, and every named import exists in that module unless it re-exports another. A linked document such as `CLAUDE.md` beside `AGENTS.md` is checked once, through its target. `docs/unversioned-installs` rejects a version after a package name in install commands, in shell code blocks and inline code; the package's own version ranges decide what installs, and a written version goes stale with the next release. A dist-tag such as `latest` passes.
256
258
  - **Suppressions:** the `suppressions/*` rules reject inline lint and compiler directives, casts through `unknown`, `any` or `never`, Biome settings that weaken a check, recommended Biome rules the preset leaves below `error`, and `ignoreDeprecations`. None of them takes exceptions. A type test (`*.typecheck.test.ts`) may use `@ts-expect-error`; a test that must pass a rejected value at run time calls the API through `Reflect.apply`.
257
259
  - **Imports:** cycles, unresolvable imports, workspace imports missing from the manifest or an entry point, relative imports that leave their folder, production imports of test code, runtime folders and fences, as described above.
258
260
  - **Names and files:** the Biome preset's naming rules and plugins, and the `files/*` rules, which name a file after its main export with its folders as the prefix. `files/named-after-export` keeps the export’s full name while the file name omits words already supplied by any folder above it. In `spaces/client/`, a component exporting `CreateSpace` lives in `Create.tsx`: `spaces/` supplies “Space” even across the intervening `client/` folder. Keep the export named `CreateSpace`; `CreateSpace.tsx` would repeat a folder name. No naming rule renames anything; the author picks the name. A name an outside system owns, such as a query parameter or an environment variable, is written as a quoted key, which the naming rules skip. A `Schema.Struct` field stays camelCase even when quoted and maps to the outside name with `Schema.encodeKeys`. Biome's naming messages print only a pattern: spell acronyms as words (`HttpClient`, `userId`, `parseUrl`) rather than turning off `strictCase` as its hint suggests, give a type no `I` prefix, and name a type parameter `T`, `T` plus a PascalCase name (`TItem`), or Effect's `A`, `E` and `R`. No rule checks these, so review does: a boolean reads as a question (`isOpen`, `canRetry`) unless the DOM or React names it (`open`, `disabled`); a schema shares its name with its type (`type Item = typeof Item.Type`); an unused parameter is removed rather than renamed with the `_` prefix TypeScript accepts. The naming rules take repository facts: `toolOwned` lists `.gitignore` patterns whose names a tool fixes, and a configured list extends the rule's defaults, so list only repository-specific additions; `content` lists snake_case content folders and files; `tests/follow` and `tests/colocated` take `suites` for test folders with their own layout, such as a Playwright suite.
259
- - **React:** `react/jsx-conditionals` reports `&&` and ternaries in JSX children, including nested decisions. Decide before the JSX or extract a component that receives the data and returns `null` when it has nothing to show. Inside `.map`, extract an item component that makes its own decision. Conditional attributes such as `className` are accepted. This rule owns the check, so the shared Biome preset leaves `noLeakedRender` off.
261
+ - **React:** `react/jsx-conditionals` reports `&&` and ternaries in the JSX children a component returns, including nested decisions and returned `.map` items. Decisions in a `const` above the return, JSX built inside library callbacks and conditional attributes are accepted. A ternary with two plain string or number literal branches, such as `{on ? "On" : "Off"}`, is accepted; branches that select JSX, components or computed values still need a decision before the JSX. This rule owns the check, so the shared Biome preset leaves `noLeakedRender` off.
260
262
  - **Tests:** `tests/follow` and `tests/colocated` keep a test beside the code it covers, named `<file>[.<modifier>].test.ts` or `<behaviour>[.<modifier>].spec.ts` with at most one modifier of `dom`, `slow`, `typecheck` and `unit`; a unit test runs without the DOM, so `.unit.dom` is rejected. `tests/colocated` always treats `__tests__/` as a test folder. It treats `test/`, `tests/` and `spec/` as test folders only when their directly contained checked files are all tests or test support; a product folder with source beside its specs is an ordinary source folder. Declared `suites` keep their own layout. Shared test support belongs in `test-support/`, the sanctioned test-only folder. A test covering a whole module may sit at its root or directly beside its folder. The story rules above keep setup in the kit.
261
263
  - **Manifests:** `manifests/valid` decodes every repository `package.json` through one shared Schema before dependent rules run and reports each invalid manifest once with its file path. Read failures other than `NotFound` fail the scan. `manifests/sorted` keeps every `package.json` in sort-package-json order, and `manifests/source-first` puts the `source` condition first in `exports` and `imports`. `manifests/exports-shape` checks the package root and workspace members with exports. They use one file-preserving TypeScript wildcard: for example, `./*.ts` maps to `./src/*.ts`, `./dist/*.d.ts` and `./dist/*.js` under `source`, `types` and `default`. A subtree pattern such as `./server/*.ts` keeps that same subtree in its targets. An optional root entry and exact-path non-code assets such as JSON presets and `./package.json` are allowed. Every module remains importable; `null` export entries fail with a request to remove the block. A package without modules, such as a dependency shell, exports only exact assets and needs no wildcard. Import each module at its path under `src/`; named aliases, flattened paths, per-file module lists and additional wildcards fail. `manifests/application` keeps an application on its entry points, as described above.
262
264
  - **Biome:** the `biome` rule reports Biome's error findings as `biome/<category>`. A Biome run that fails without an error finding, such as one whose config leaves no file to check, fails lint and fix with Biome's message. The preset leaves out the `.worktrees` folder at the root, so a checkout does not lint its linked worktrees, while a worktree inside it lints all of its own files. The preset's plugins ban ambient time, randomness, `console` and `process.env` in favour of Effect's services.
@@ -285,6 +287,31 @@ function Panel({ ready }) {
285
287
  }
286
288
  ```
287
289
 
290
+ JSX built in a `const` above the return is also accepted:
291
+
292
+ ```tsx
293
+ function Panel({ ready }) {
294
+ const content = <section>{ready && <Content />}</section>;
295
+ return <main>{content}</main>;
296
+ }
297
+ ```
298
+
299
+ Conditional attributes are accepted:
300
+
301
+ ```tsx
302
+ function Panel({ ready }) {
303
+ return <section className={ready ? "active" : "idle"} />;
304
+ }
305
+ ```
306
+
307
+ Library callbacks make their own rendering decisions. A chart formatter is accepted:
308
+
309
+ ```tsx
310
+ function Chart() {
311
+ return <Library formatter={(value) => <span>{value ? <Content /> : null}</span>} />;
312
+ }
313
+ ```
314
+
288
315
  Replace `<ul>{items.map(item => item.visible ? <li key={item.id}>{item.name}</li> : null)}</ul>` with an item component that receives the data and returns `null`:
289
316
 
290
317
  ```tsx
@@ -304,6 +331,26 @@ function List({ items }) {
304
331
  }
305
332
  ```
306
333
 
334
+ To join rendered items with a separator, decide the separator in a `const` before the item return:
335
+
336
+ ```tsx
337
+ function List({ items }) {
338
+ return (
339
+ <>
340
+ {items.map((item, index) => {
341
+ const separator = index > 0 && ", ";
342
+ return (
343
+ <span key={item.id}>
344
+ {separator}
345
+ {item.name}
346
+ </span>
347
+ );
348
+ })}
349
+ </>
350
+ );
351
+ }
352
+ ```
353
+
307
354
  ### API
308
355
 
309
356
  Import names from their defining module; there is no root entry. The package's `./*.ts` export pattern also exposes the gate's implementation modules; the following table lists the config, tool and extension entry points:
@@ -359,7 +406,7 @@ quality fix [--config <file>]
359
406
  quality exceptions migrate [--config <file>] [--from <registry>]
360
407
  quality baseline merge <ancestor> <current> <other>
361
408
  quality baseline install-driver
362
- quality baseline write [--config <file>] [--rule <id>]...
409
+ quality baseline write [--config <file>] [--rule <id>]... [--file <path>]...
363
410
  quality baseline prune [--config <file>] [--against <ref>]
364
411
  quality baseline tighten [--config <file>] [--staged]
365
412
  quality baseline migrate [--config <file>] [--from <file>]
@@ -16,5 +16,71 @@ or {
16
16
  or {
17
17
  JsStaticMemberExpression() as $match where { $match <: `process.env` },
18
18
  JsComputedMemberExpression() as $match where { $match <: `process["env"]` }
19
- } where { register_diagnostic(span=$match, message="process.env is banned. Read configuration through Effect's Config service.") }
19
+ } where { register_diagnostic(span=$match, message="process.env is banned. Read configuration through Effect's Config service.") },
20
+ or {
21
+ or {
22
+ `Clock.$member.pipe($...)` as $match,
23
+ `Config.$member($...).pipe($...)` as $match,
24
+ `Random.$member.pipe($...)` as $match
25
+ } where {
26
+ $match <: contains `Effect.$runner` where { $runner <: r"run.*" },
27
+ $message = "Running Clock, Config or Random outside the current runtime is banned. Yield the computation in the caller's Effect so its services are preserved."
28
+ },
29
+ `Effect.$method($value, $...)` as $match where {
30
+ $method <: r"run.*",
31
+ $value <: contains or {
32
+ `Clock.$member`,
33
+ `Config.$member`,
34
+ `Random.$member`
35
+ },
36
+ $message = "Running Clock, Config or Random outside the current runtime is banned. Yield the computation in the caller's Effect so its services are preserved."
37
+ },
38
+ `$clock.currentTimeMillisUnsafe` as $match where {
39
+ $message = "Unsafe clock reads are banned. Yield Clock.currentTimeMillis in the caller's Effect; bridge a synchronous callback in adapters/."
40
+ },
41
+ or {
42
+ `crypto.randomUUID($...)` as $match,
43
+ `globalThis.crypto.randomUUID($...)` as $match,
44
+ `globalThis.crypto.randomBytes($...)` as $match,
45
+ `randomUUID($...)` as $match,
46
+ `randomBytes($...)` as $match
47
+ } where { $message = "Ambient cryptographic randomness is banned. Read secure values through Effect's Crypto service." },
48
+ `crypto.randomBytes($...)` as $match where {
49
+ $program <: contains or {
50
+ `import * as crypto from "node:crypto"`,
51
+ `import * as crypto from "crypto"`,
52
+ `import crypto from "node:crypto"`,
53
+ `import crypto from "crypto"`
54
+ },
55
+ $message = "Ambient cryptographic randomness is banned. Read secure values through Effect's Crypto service."
56
+ },
57
+ `performance.now()` as $match where { $message = "Ambient performance time is banned. Read time through Effect's Clock service." },
58
+ or {
59
+ `process.$member` as $match,
60
+ `globalThis.process.$member` as $match,
61
+ `process.$member = $value` as $match,
62
+ `globalThis.process.$member = $value` as $match
63
+ } where {
64
+ $member <: r"argv|cwd|exit|exitCode",
65
+ ! $match <: within JsYieldExpression(argument=JsYieldArgument(expression=`process.exitCode`)),
66
+ $message = "Ambient process state is banned. Read arguments and the working directory at the entry point and use the runtime to exit; bridge process APIs in adapters/."
67
+ },
68
+ `globalThis.process.env` as $match where { $message = "Global process.env is banned. Read configuration through Effect's Config service." },
69
+ or {
70
+ `setTimeout($...)` as $match,
71
+ `queueMicrotask($...)` as $match,
72
+ `globalThis.setTimeout($...)` as $match,
73
+ `globalThis.queueMicrotask($...)` as $match
74
+ } where {
75
+ $message = "Ambient scheduling is banned. Use Effect's sleep, scheduling and fibers in the current runtime; bridge callback APIs in adapters/."
76
+ }
77
+ } where {
78
+ ! $filename <: r"(?:^|.*[/\\])(?:adapters|test-support)[/\\].*|(?:^|.*[/\\])(?:cli|main|.*-cli)\.[cm]?[jt]sx?$|.*\.(?:config|test|spec)\.[cm]?[jt]sx?$",
79
+ ! $program <: contains or {
80
+ `NodeRuntime.runMain`,
81
+ `runMain($...)`,
82
+ `fileURLToPath(import.meta.url) === process.argv[1]`
83
+ },
84
+ register_diagnostic(span=$match, message=$message)
85
+ }
20
86
  }
@@ -2,7 +2,36 @@ engine biome(1.0)
2
2
  language js(typescript, jsx)
3
3
 
4
4
  or {
5
- `export type { $names } from $source` as $match,
6
- `export type * from $source` as $match,
7
- `export type * as $namespace from $source` as $match
8
- } where { register_diagnostic(span=$match, message="A module never re-exports, types included. Import the type from the module that defines it.") }
5
+ or {
6
+ `export type { $names } from $source` as $match,
7
+ `export type * from $source` as $match,
8
+ `export type * as $namespace from $source` as $match
9
+ },
10
+ `export type $alias = $original` as $match where {
11
+ $original <: r"[A-Za-z_$][A-Za-z0-9_$]*",
12
+ $match <: within {
13
+ contains or {
14
+ `import type { $imports } from $source`,
15
+ `import { $imports } from $source`
16
+ } where {
17
+ $imports <: contains or {
18
+ `$original`,
19
+ `$imported as $original`,
20
+ `type $original`,
21
+ `type $imported as $original`
22
+ }
23
+ }
24
+ }
25
+ },
26
+ `export type $alias = $original` as $match where {
27
+ $match <: within {
28
+ contains or {
29
+ `import type $original from $source`,
30
+ `import $original from $source`
31
+ }
32
+ }
33
+ }
34
+ } where {
35
+ register_diagnostic(span=$match, message=`A module never re-exports, types included.
36
+ Help: Import the type from $source, the module that defines it, and remove the second name.`)
37
+ }
@@ -3,14 +3,14 @@ import process from "node:process";
3
3
  import { Effect, Stream } from "effect";
4
4
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
5
5
  import { withExceptionConfig } from "#biome/exceptionConfig.ts";
6
- import { shadcnFolders } from "#inventory/shadcnFolders.ts";
6
+ import { shadcnFiles } from "#inventory/shadcnFiles.ts";
7
7
  const BIN = createRequire(import.meta.url).resolve("@biomejs/biome/bin/biome");
8
8
  export const runBiome = Effect.fn("Biome.runBiome")(function* (root, args, exceptions = []) {
9
- const folders = yield* shadcnFolders(root);
9
+ const files = yield* shadcnFiles(root);
10
10
  const toolOwned = [
11
11
  {
12
- files: ["**", "!**/pnpm-lock.yaml", ...folders.map((folder) => `!${folder}`)],
13
- reason: "pnpm writes its lockfiles; components.json assigns UI folders to the shadcn CLI.",
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.",
14
14
  rules: ["biome/files/includes"],
15
15
  },
16
16
  ];
@@ -1 +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C,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,CACF,CACD,CAAC;AACH,CAAC,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"fixJsxConditionals.d.ts","sourceRoot":"","sources":["../../src/adapters/fixJsxConditionals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAsE3C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CA4C3D"}
1
+ {"version":3,"file":"fixJsxConditionals.d.ts","sourceRoot":"","sources":["../../src/adapters/fixJsxConditionals.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAgE3C,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CA4C3D"}
@@ -1,5 +1,6 @@
1
1
  import ts from "typescript";
2
2
  import { parse } from "#rules/parse.ts";
3
+ import { jsxChildDecision } from "#rules/react/jsxChildDecision.ts";
3
4
  function unwrap(node) {
4
5
  return ts.isParenthesizedExpression(node) ? unwrap(node.expression) : node;
5
6
  }
@@ -26,11 +27,7 @@ function conditionalChild(node) {
26
27
  return undefined;
27
28
  }
28
29
  const expression = unwrap(child.expression);
29
- return isConditional(expression) ? child.expression : undefined;
30
- }
31
- function isConditional(expression) {
32
- return (ts.isConditionalExpression(expression)
33
- || (ts.isBinaryExpression(expression) && expression.operatorToken.kind === ts.SyntaxKind.AmpersandAmpersandToken));
30
+ return jsxChildDecision(expression) === undefined ? undefined : child.expression;
34
31
  }
35
32
  function returnedExpression(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AK,QAAQ,IAAI;aACjE,CAAC,CAAC;YACH,OAAO;QACR,CAAC;QACD,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,KAAK,CAAC,MAAM,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACrB,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,QAAQ,CAAC,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9E,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import type { RuleInputs } from "#rule.ts";
2
- export declare function knipConfiguration(inputs: RuleInputs): Promise<{
2
+ export declare function knipConfiguration(inputs: RuleInputs, toolOwned?: readonly string[]): Promise<{
3
3
  exclude: never[];
4
4
  ignore: never[];
5
5
  ignoreBinaries: never[];
@@ -22,7 +22,10 @@ export declare function knipConfiguration(inputs: RuleInputs): Promise<{
22
22
  readonly paths: {
23
23
  [k: string]: string[];
24
24
  };
25
- readonly project: string[];
25
+ readonly project: readonly string[];
26
+ readonly vitest: {
27
+ readonly config: readonly ["vitest*.config.{ts,mts,cts,js,mjs,cjs}", "vitest.{workspace,projects}.{ts,mts,cts,js,mjs,cjs,json}"];
28
+ };
26
29
  };
27
30
  };
28
31
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/configuration.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAe3C,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;GAmDzD"}
1
+ {"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/configuration.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAe3C,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,GAAE,SAAS,MAAM,EAAO;;;;;;;;;;;;;;;;;;;;;;;;;yBAqC/E,MAAM;;;;GAqBnB"}
@@ -2,7 +2,7 @@ import { posix } from "node:path";
2
2
  import { readPackageManifest } from "#adapters/manifestInventory.ts";
3
3
  import { exportedModule, exportTargets } from "#imports/packageExports.ts";
4
4
  import { packageOf, workspacePackages } from "#imports/workspace.ts";
5
- import { isMigrationFile } from "#naming/migrationFile.ts";
5
+ import { SHADCN_FILE_GLOB } from "#inventory/shadcnFiles.ts";
6
6
  import { KNIP_ISSUES } from "./findings.js";
7
7
  const ENTRIES = ["**/*.{test,spec,stories,story}.{ts,tsx,mts,cts,js,jsx,mjs,cjs}", "src/test-support/**", "*.config.{ts,mts,cts,js,mjs,cjs}"];
8
8
  function importPaths(imports) {
@@ -12,7 +12,7 @@ function importPaths(imports) {
12
12
  return paths.length === 0 ? [] : [[name, paths]];
13
13
  }));
14
14
  }
15
- export async function knipConfiguration(inputs) {
15
+ export async function knipConfiguration(inputs, toolOwned = []) {
16
16
  const packages = await workspacePackages(inputs);
17
17
  const manifests = await Promise.all([".", ...packages.map(({ directory }) => directory)].map(async (directory) => {
18
18
  const manifest = (await readPackageManifest(inputs.readText, posix.join(directory, "package.json"))) ?? {};
@@ -28,13 +28,20 @@ export async function knipConfiguration(inputs) {
28
28
  const binaries = sources.filter((path) => bins.includes(path) || bins.includes(path.replace(/^src\//u, "dist/").replace(/\.(?<mode>[cm]?)tsx?$/u, ".$<mode>js")));
29
29
  const publicFiles = sources.filter((path) => exportedModule(manifest.exports, path));
30
30
  // Migration runners load these files from their directory, so no import reaches them.
31
- const migrations = sources.filter((path) => isMigrationFile(posix.join(directory, path)));
31
+ const migrations = sources.filter((path) => /(?:^|\/)server\/migrations\//u.test(path));
32
+ const ui = toolOwned
33
+ .filter((folder) => (packageOf(packages, `${folder}/component.ts`)?.directory ?? ".") === directory)
34
+ .map((folder) => `${posix.relative(directory, folder)}/**/${SHADCN_FILE_GLOB}`);
35
+ const styles = inputs.files
36
+ .filter((path) => path.endsWith(".css") && (packageOf(packages, path)?.directory ?? ".") === directory)
37
+ .map((path) => posix.relative(directory, path));
32
38
  return [
33
39
  directory,
34
40
  {
35
- entry: [...ENTRIES, ...publicFiles, ...migrations, ...bins, ...binaries, ...scriptEntries],
41
+ entry: [...ENTRIES, ...publicFiles, ...migrations, ...bins, ...binaries, ...scriptEntries, ...ui, ...styles],
36
42
  paths: importPaths(manifest.imports ?? {}),
37
- project: sources,
43
+ project: [...sources, ...ui, ...styles],
44
+ vitest: { config: ["vitest*.config.{ts,mts,cts,js,mjs,cjs}", "vitest.{workspace,projects}.{ts,mts,cts,js,mjs,cjs,json}"] },
38
45
  },
39
46
  ];
40
47
  });
@@ -1 +1 @@
1
- {"version":3,"file":"configuration.js","sourceRoot":"","sources":["../../../src/adapters/knip/configuration.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3E,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,MAAM,OAAO,GAAG,CAAC,gEAAgE,EAAE,qBAAqB,EAAE,kCAAkC,CAAC,CAAC;AAE9I,SAAS,WAAW,CAAC,OAA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C1B,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QACrE,IAAI,EAAE,EAAE;QACR,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,UAAU,CAAC;KAC1C,CAAC;AACH,CAAC"}
@@ -1,5 +1,4 @@
1
- import { Effect, FileSystem } from "effect";
2
- import { ChildProcessSpawner } from "effect/process";
1
+ import { Effect } from "effect";
3
2
  import type { RuleInputs } from "#rule.ts";
4
- export declare const runKnip: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").Findings, Error | import("effect/PlatformError").PlatformError, ChildProcessSpawner.ChildProcessSpawner | FileSystem.FileSystem>;
3
+ export declare const runKnip: (inputs: RuleInputs) => Effect.Effect<import("#rule.ts").Findings, Error | import("effect/PlatformError").PlatformError, import("#rule.ts").RuleServices>;
5
4
  //# sourceMappingURL=run.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/adapters/knip/run.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAU,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAgB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAEnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAO3C,eAAO,MAAM,OAAO,2LA4ClB,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;AAc3C,eAAO,MAAM,OAAO,2JAuDlB,CAAC"}
@@ -1,19 +1,29 @@
1
1
  import { createRequire } from "node:module";
2
2
  import { basename, dirname, join, posix } from "node:path";
3
3
  import process from "node:process";
4
+ import { pathToFileURL } from "node:url";
4
5
  import { Effect, FileSystem, Stream } from "effect";
5
6
  import { ChildProcess, ChildProcessSpawner } from "effect/process";
6
7
  import { readPackageManifest } from "#adapters/manifestInventory.ts";
8
+ import { shadcnFolders } from "#inventory/shadcnFolders.ts";
7
9
  import { knipConfiguration } from "./configuration.js";
8
10
  import { entryPointFindings } from "./entryPointFindings.js";
9
11
  import { KNIP_ISSUES, knipFindings } from "./findings.js";
10
12
  import { sourceConfig } from "./sourceConfig.js";
11
- const BIN = join(dirname(createRequire(import.meta.url).resolve("knip")), "..", "bin", "knip.js");
13
+ const API = createRequire(import.meta.url).resolve("knip");
14
+ const BIN = join(dirname(API), "..", "bin", "knip.js");
15
+ // Initialize the loader in isolation, then evaluate application configs from their checkout.
16
+ const LAUNCH = `
17
+ const [api, entry, root] = process.argv.splice(1, 3);
18
+ import(api).then(() => { process.chdir(root); return import(entry); })
19
+ .catch(error => { console.error(error); process.exitCode = 1; });
20
+ `;
12
21
  export const runKnip = Effect.fn("Knip.runKnip")(function* (inputs) {
13
22
  if ((yield* Effect.promise(() => readPackageManifest(inputs.readText, "package.json"))) === undefined) {
14
23
  return [];
15
24
  }
16
- const configuration = yield* Effect.promise(() => knipConfiguration(inputs));
25
+ const folders = yield* shadcnFolders(inputs.root);
26
+ const configuration = yield* Effect.promise(() => knipConfiguration(inputs, folders));
17
27
  const checked = new Set([...inputs.files, ...Object.keys(configuration.workspaces).map((directory) => posix.join(directory, "package.json"))]);
18
28
  const findings = yield* Effect.scoped(Effect.gen(function* () {
19
29
  const fs = yield* FileSystem.FileSystem;
@@ -21,10 +31,17 @@ export const runKnip = Effect.fn("Knip.runKnip")(function* (inputs) {
21
31
  const config = join(temporary, "knip.json");
22
32
  yield* fs.writeFileString(config, JSON.stringify(configuration));
23
33
  const tsconfig = yield* sourceConfig(inputs, Object.keys(configuration.workspaces), basename(temporary));
34
+ const cwd = join(inputs.root, posix.dirname(tsconfig), "run");
24
35
  const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
25
36
  const child = yield* spawner.spawn(ChildProcess.make(process.execPath, [
26
37
  "--conditions=source",
27
- BIN,
38
+ "--eval",
39
+ LAUNCH,
40
+ pathToFileURL(API).href,
41
+ pathToFileURL(BIN).href,
42
+ inputs.root,
43
+ "--directory",
44
+ inputs.root,
28
45
  "--config",
29
46
  config,
30
47
  "--tsConfig",
@@ -34,12 +51,13 @@ export const runKnip = Effect.fn("Knip.runKnip")(function* (inputs) {
34
51
  "--include",
35
52
  KNIP_ISSUES.join(","),
36
53
  "--no-progress",
37
- ], { cwd: inputs.root, env: { "JITI_TRY_NATIVE": "true" }, extendEnv: true, stdin: "ignore" }));
54
+ ], { cwd, env: { "JITI_TRY_NATIVE": "true" }, extendEnv: true, stdin: "ignore" }));
38
55
  const [stdout, stderr, code] = yield* Effect.all([Stream.mkString(Stream.decodeText(child.stdout)), Stream.mkString(Stream.decodeText(child.stderr)), child.exitCode], { concurrency: "unbounded" });
39
- if (Number(code) > 1) {
40
- return yield* Effect.fail(new Error(`knip failed: ${stderr || `exit code ${code}`}`));
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}`));
41
59
  }
42
- return knipFindings(stdout).filter((finding) => checked.has(finding.file));
60
+ return report.filter((finding) => checked.has(finding.file));
43
61
  }));
44
62
  return yield* Effect.promise(() => entryPointFindings(inputs, findings));
45
63
  });