Skip to content

chore: integrate knip for dead-code detection - #158

Merged
antfu merged 2 commits into
mainfrom
quick-signs-draw
Aug 3, 2026
Merged

chore: integrate knip for dead-code detection#158
antfu merged 2 commits into
mainfrom
quick-signs-draw

Conversation

@antfubot

@antfubot antfubot commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

What

Adds knip — unused files, dependencies, and exports — to the toolchain: pnpm knip script, wired into the "Before PRs" checklist and CI's lint job.

Config

knip.jsonc carries per-workspace overrides for the handful of gaps knip's defaults can't infer on their own here, each documented inline:

  • Multi-entry package exports subpaths (packages/devframe, packages/hub, the built-in plugins, …) — knip's package.json→dist→src source mapping needs a workspace tsconfig.json outDir, but this repo's packages resolve each other's src/*.ts directly across workspaces via the paths aliases in tsconfig.base.json, and outDir breaks tsc's rootDir inference for every consumer that does. Entries are listed explicitly instead.
  • Next.js apps whose client root sits at src/client rather than the workspace root (PostCSS config discovery).
  • plugins/a11y's storybook-solidjs-vite framework, which doesn't match knip's Storybook plugin trigger (only @storybook/* scoped packages do).
  • packages/json-render-ui's standalone SPA, whose UnoCSS config is discovered by directory proximity rather than an import.
  • tsnapi's generated API-snapshot fixtures (compared byte-for-byte, never imported).
  • A handful of genuinely dynamic dependency references: runtime string-literal plugin loading (next-devframe-hub), markdown code samples (docs), a transitive type-only leak from @nuxt/kit's own dependency graph.

Cleanup

The baseline run also surfaced real findings, fixed directly:

  • ~30 needlessly exported internal-only symbols demoted to file-local.
  • A few fully dead files and code paths removed: plugins/git's unused ported shadcn UI components (card.tsx/separator.tsx/tabs.tsx, per this repo's own "port on demand" convention), an unused helper, two orphaned test constants.
  • 8 stale dependencies dropped (@antfu/ni, tsdown at root; birpc, pathe, ws, h3, a few Radix/CVA leftovers) — pnpm-workspace.yaml's cleanupUnusedCatalogs auto-pruned the now-unreferenced catalog entries.
  • 4 real missing/phantom dependencies added (pathe, @antfu/design at root; valibot in two examples; @vueuse/core, @standard-schema/spec).

Verified with pnpm lint && pnpm knip && pnpm test && pnpm typecheck && pnpm build — including the tsnapi API-snapshot suite, which would fail if any of the export demotions had touched real public API surface.


This PR was created with the help of an agent.

Adds knip (unused files/dependencies/exports) to the toolchain, wired
into `pnpm knip`, the "Before PRs" checklist, and CI's lint job.

knip.jsonc carries per-workspace overrides for gaps its defaults can't
infer on their own: multi-entry package `exports` subpaths (its
package.json→dist→src source mapping needs a workspace tsconfig
`outDir`, which conflicts with this repo's cross-workspace `src/*.ts`
imports), nested Next.js/PostCSS roots, `storybook-solidjs-vite` not
matching the Storybook plugin's trigger, UnoCSS config discovered by
directory proximity rather than import, tsnapi's generated snapshot
fixtures, and a handful of genuinely dynamic dependency references
(runtime string-literal plugin loading, markdown code samples,
transitive type-only leaks).

Also cleans up what the baseline run surfaced: ~30 needlessly exported
internal-only symbols demoted to file-local, a few fully dead files
and code paths removed (plugins/git's unused ported UI components, an
unused helper, two orphaned test constants), 8 stale dependencies
dropped, and 4 real missing/phantom dependencies added.

Co-authored-by: opencode <noreply@opencode.ai>
@netlify

netlify Bot commented Aug 3, 2026

Copy link
Copy Markdown

Deploy Preview for devfra ready!

Name Link
🔨 Latest commit c205907
🔍 Latest deploy log https://app.netlify.com/projects/devfra/deploys/6a7021113c7ebd0008d732b8
😎 Deploy Preview https://deploy-preview-158--devfra.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

A `pnpm install` run during the knip integration work rewrote
`pnpm-workspace.yaml`'s catalogs section and flattened the `*nuxt`/
`*storybook` anchor references (`refs:` block) into literal version
strings, defeating their point — keeping `@nuxt/kit`, the `@storybook/*`
family, and `storybook` itself in sync with one written version each.

Restores those two, and also wires up the `&unocss`/`&vueuse` anchors
(defined but never referenced) to `unocss`/`@unocss/*`/`@vueuse/core`
in the `frontend` catalog, so all four `refs:` entries are load-bearing.

No version values changed.

Co-authored-by: opencode <noreply@opencode.ai>
@antfu
antfu merged commit 7962b8d into main Aug 3, 2026
12 checks passed
@antfu
antfu deleted the quick-signs-draw branch August 3, 2026 05:10
antfubot added a commit that referenced this pull request Aug 3, 2026
Resolves conflicts from #158 (knip integration):
- packages/hub/package.json: keep our @standard-schema/spec addition,
  take main's removal of the (knip-flagged unused) birpc dependency
- pnpm-lock.yaml: regenerated via `pnpm install --lockfile-only`

Also fixes two knip findings the merge exposed in this branch's own
new surface (unchecked by knip before it landed on main):
- instance-registry.ts: DEVFRAME_INSTANCES_DIR_ENV /
  DEVFRAME_DISABLE_INSTANCE_REGISTRY_ENV / resolveInstancesDir /
  probeDevframeInstance drop `export` — module-internal per the
  barrel's existing "read/probe/prune helpers stay internal" comment,
  nothing outside the file used them
- packages/next: DevframeNextHostMcpOptions (the `mountMcp` options
  type) now re-exported from the package barrel, alongside its sibling
  option types — a real gap, not a knip false positive
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