Skip to content

chore: add an unused-dependency CI check (knip) (closes #42)#56

Merged
tonytino merged 3 commits into
mainfrom
chore/42-unused-deps
Jun 25, 2026
Merged

chore: add an unused-dependency CI check (knip) (closes #42)#56
tonytino merged 3 commits into
mainfrom
chore/42-unused-deps

Conversation

@tonytino

@tonytino tonytino commented Jun 25, 2026

Copy link
Copy Markdown
Owner

Closes #42. Draft for your review (safe:human). Adds the unused-dependency guardrail, and — per our discussion — reworks the example-route and testing-example stories so the check stays honest without dropping anything useful.

1. Unused-dependency check (the core of #42)

  • knip via pnpm knip + a CI step, configured in knip.json so false positives are zero (vinxi/TanStack Start entry points; tailwindcss allowlisted because it's used via the CSS @import + @tailwindcss/vite; drizzle plugin disabled so knip needn't execute drizzle.config.ts).
  • Documented in docs/agents/dependencies.md.

2. @testing-library/user-event — kept and demonstrated

knip originally flagged user-event as unused. Rather than drop it, this demonstrates it so it's genuinely used:

  • Added an interactive Counter example component + Counter.test.tsx that simulates a real click with user-event (render → click → assert).
  • Switched tests/setup.ts to the Vitest-specific jest-dom entry: @testing-library/jest-dom/vitest.

3. Useful, removable example routes

Instead of scaffold deleting the example route and orphaning @hono/zod-validator:

  • Added GET /api/health (app/server/routes/health.ts) — a dependency-free liveness route, kept in scaffolded projects.
  • Kept the request-validation example mounted by default, so @hono/zod-validator stays a used dependency. Its tests moved to example.test.ts.
  • Added scripts/remove-example.mjs — opt-out that deletes the example route + test, unmounts it, and drops @hono/zod-validator. Documented in docs/agents/api.md.
  • Scaffold no longer strips the server example or drops the dependency.

Verification (end-to-end)

  • Template: pnpm preflight green (44 tests incl. the Counter click test), pnpm knip exit 0.
  • Default scaffolded instance: example + health + Counter kept, @hono/zod-validator and user-event present, knip exit 0, preflight pass.
  • After node scripts/remove-example.mjs in that instance: only health remains, @hono/zod-validator dropped, index.ts cleanly mounts health (not example), knip still exit 0, preflight pass.

🤖 Generated with Claude Code

claude added 3 commits June 25, 2026 02:21
Nothing caught dependencies declared but imported nowhere (this let
@tanstack/react-query sit unused until #49). Add knip as a CI guardrail.

- knip + knip.json, configured for the vinxi/TanStack Start entrypoints so
  there are zero false positives; tailwindcss allowlisted (used via the CSS
  @import + @tailwindcss/vite, which knip can't trace); drizzle plugin off so
  knip needn't execute drizzle.config.ts
- `pnpm knip` script + an "Unused dependency check" CI step in ci.yml
- Removed @testing-library/user-event — knip flagged it as genuinely unused
- Scaffold now drops @hono/zod-validator (only the removed example route used
  it) so the propagated check passes out-of-box in a fresh instance
- Documented in docs/agents/dependencies.md

Verified: knip clean in the template and in a scaffolded instance; preflight
green; instance preflight green.

Closes #42.
…mple

Reworks the example-route story so the unused-dependency check stays honest
without scaffold quietly dropping a dependency.

- Add `GET /api/health` (app/server/routes/health.ts), a dependency-free
  liveness route kept in scaffolded projects
- Keep the request-validation example mounted by default (so @hono/zod-validator
  stays a *used* dependency); split its tests into example.test.ts
- Add `scripts/remove-example.mjs` — opt-out that deletes the example route +
  test, unmounts it, and drops @hono/zod-validator (documented in api.md)
- Scaffold no longer strips the server example or drops the dependency

Verified end-to-end: template preflight + knip green; a scaffolded instance is
knip-green with the example kept; running remove-example.mjs leaves a
knip-green, preflight-green instance with only the health route.
Instead of dropping @testing-library/user-event for being unused, demonstrate
it so it's a genuinely-used dependency.

- Add an interactive `Counter` example component + `Counter.test.tsx` that
  simulates a real click with @testing-library/user-event
- Switch tests/setup.ts to the Vitest-specific jest-dom entry
  (`@testing-library/jest-dom/vitest`)
- Restores @testing-library/user-event to devDependencies

Verified: knip green (user-event now used), preflight green (44 tests incl. the
Counter click test); scaffolded instance keeps Counter + user-event, knip green.
@tonytino tonytino marked this pull request as ready for review June 25, 2026 03:43
@tonytino tonytino merged commit 7f62304 into main Jun 25, 2026
5 checks passed
@tonytino tonytino deleted the chore/42-unused-deps branch June 25, 2026 03:43
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.

[Task]: Add an unused-dependency check to CI

2 participants