Skip to content

chore: check import cycles and the ui barrel with knip - #10

Merged
morinokami merged 2 commits into
mainfrom
claude/fallow-knip-replacement-investigation-5484pq
Sep 24, 2026
Merged

morinokami merged 2 commits into
mainfrom
claude/fallow-knip-replacement-investigation-5484pq

Conversation

@morinokami

@morinokami morinokami commented Sep 24, 2026 •

Copy link
Copy Markdown
Owner

Two checks that knip ships but leaves off by default:

  • Circular imports. The issue type is opt-in and reported only as a warning, so rules.cycles makes it an error and knip now runs a second, cycles-only pass (knip && knip --cycles). Listing cycles in include would do it in one pass, but include replaces knip's default issue types, so a type added by a later knip would silently go unchecked. The second pass takes about two seconds.
  • Unused exports of @astro-devtools/ui's entry files. The package is private and bundled into astro-devtools, its only consumer, so a component that src/index.ts re-exports but no panel imports is dead code; includeEntryExports for packages/ui now reports it.

The two-pass command moves from the knip script in package.json to a knip task in the root vite.config.ts, where a comment beside it records why it runs twice (package.json cannot hold one; a task and a script may not share a name). vp run knip is unchanged, so CI and vp run ready run both passes as before. knip needs no ignoreDependencies entry for the task-only invocation, since it always treats its own package as used.

Why these two

They came out of evaluating fallow as a replacement for, or addition to, knip. Regressions injected into a copy of the repository showed what fallow catches beyond knip here: import cycles, unconsumed ui re-exports, and unused class members (there is one production class, the overlay's custom element). knip covers the first two with configuration alone, so a second analyzer with its own config and dependency is not worth it.

Verification

  • The CI lint job passes locally: vp run -r build, vp run playground#sync, vp check, vp run knip, vp run publint.
  • vp run knip (the task) fails on an injected import cycle and on an unused re-export in packages/ui/src/index.ts, and passes again once both are reverted.
  • The 37 regressions injected during the evaluation, re-run with this configuration and both passes: exactly four results change. Three cycle cases (plain imports and export * re-exports) now fail the --cycles pass, and an unused re-export in packages/ui/src/index.ts fails the first pass. Every other case gives the same result as before, and the unmodified tree passes.
  • Unit and e2e tests were not run locally; the change touches only knip.jsonc, the root vite.config.ts, and package.json's scripts.

🤖 Generated with Claude Code

https://claude.ai/code/session_01UqHXUSZPwCjuSarsmo14em

Two checks that knip ships but leaves off by default:

- Circular imports. The issue type is opt-in and reported only as a
  warning, so `rules.cycles` makes it an error and the `knip` script
  runs a second, cycles-only pass (`knip --cycles`). Listing `cycles` in
  `include` would do it in one pass, but `include` replaces knip's
  default issue types, so a type added by a later knip would silently
  go unchecked. The second pass takes about two seconds.
- Unused exports of @astro-devtools/ui's entry files. The package is
  private and bundled into astro-devtools, its only consumer, so a
  component that src/index.ts re-exports but no panel imports is dead
  code; `includeEntryExports` for that workspace now reports it.

Both came out of evaluating fallow as a replacement for, or addition
to, knip: of the findings fallow adds, these are the ones that matter
in this repository, and knip covers them with configuration alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UqHXUSZPwCjuSarsmo14em
@pkg-pr-new

pkg-pr-new Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/morinokami/astro-devtools@10

commit: fbf0f87

package.json cannot carry a comment, and `knip && knip --cycles` does
not explain itself: the second pass exists because naming `cycles` in
knip.jsonc's `include` would replace knip's default issue types. Define
the command as a `knip` task in the root vite.config.ts instead, with
that reason beside it, and drop the script (a task and a script may not
share a name). `vp run knip`, and with it CI and `vp run ready`, runs
the same two passes. knip needs no `ignoreDependencies` entry for the
task-only invocation, since it always treats its own package as used.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UqHXUSZPwCjuSarsmo14em
@morinokami
morinokami merged commit b6b168f into main Sep 24, 2026
4 checks passed
@morinokami
morinokami deleted the claude/fallow-knip-replacement-investigation-5484pq branch September 24, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants