Skip to content

chore(cleanup): dead-code spring cleanup — knip reports zero unused surface#41

Merged
DavidBabinec merged 4 commits into
mainfrom
chore/dead-code-spring-cleanup
Jun 12, 2026
Merged

chore(cleanup): dead-code spring cleanup — knip reports zero unused surface#41
DavidBabinec merged 4 commits into
mainfrom
chore/dead-code-spring-cleanup

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

Why

Item 7 of the pre-1.0 health check. The raw audit said 9 unused files / 247 unused exports / 778 unused types — but a verification pass showed a big share were tool blind spots, and the rest was real dead surface accumulated across sessions. This PR fixes both: the tool config so future audits are trustworthy, and the actual dead code.

What changed (one commit per concern)

1. knip.json learns the real entry points. server/healthcheck.ts (run by Dockerfile:53 HEALTHCHECK), the QuickJS bootstrap sources (bundled to committed artifacts via bootstrap:sync), the plugin admin-app surfaces (plugin-host-ui / plugin-host-hooks, loaded via dynamic import() in pluginRuntimeBootstrap.ts), the plugin SDK barrel + CLI, and server-side __tests__. This is what made fallow/knip claim @ui/components/Tabs was "100% dead" — it's re-exported by the plugin UI kit and very much alive.

2. Three orphan admin barrels deleted — zero importers; consumers deep-import by design (docs/editor.md even said so for layouts; doc updated).

3. The sweep — knip now reports 0 unused files / 0 exports / 0 types.

  • src/core/publisher/render.ts: deleted the backward-compat re-export shim ("kept importable so existing callers don't need to retarget") — nothing imported through it, and back-compat shims are banned by CLAUDE.md.
  • server/publish/publicRouter.ts: un-exported resolvePublicRoute / publicSlugFromPath / PublicRouteResolution (internal-only; the architecture gates read source text, not imports).
  • Deleted dead API functions with zero callers, plus their orphaned schemas/constants: exportCmsBundle / importCmsBundle, deleteUserPreference, updateCredential, listDrivers, readDefaultForScope / clearDefaultForScope, stopPublishScheduler, resetImageVariantWorkerPool, _resetFontCachesForTests, isSafeFontPath, and friends.
  • Un-exported ~180 exports / ~630 type aliases nothing imports (declaration kept where used in-file, deleted where fully dead). Constants surviving only to derive a union type are inlined as literal unions.
  • One knip false positive caught by tsc and restored: InsertionPresetNode (type-imported through the module-picker barrel).

Net: 397 files, +636 / −1,103.

Verification

  • bunx tsc -b (strict) — clean
  • bun test — 5,343 pass / 0 fail
  • bun run lint, bun run build, bun run doctor — pass
  • bunx knip0 unused files, 0 unused exports, 0 unused types

The pre-commit react-doctor notice on the sweep commit is the pre-existing warn-tier baseline (513+ repo-wide); bun run doctor (the error-tier gate) exits 0.

🤖 Generated with Claude Code

DavidBabinec and others added 4 commits June 11, 2026 23:42
server/healthcheck.ts (Docker HEALTHCHECK), the QuickJS bootstrap sources
(bundled via bootstrap:sync), the plugin admin-app surfaces
(plugin-host-ui / plugin-host-hooks, loaded via dynamic import in
pluginRuntimeBootstrap), the plugin SDK barrel + CLI, and server-side
__tests__ are real entry points knip could not see. False-positive
counts drop from 9/247/778 (files/exports/types) to 3/185/635 — the
remainder is trustworthy dead surface.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
src/admin/layouts/index.ts, src/admin/modals/Settings/index.ts, and
TypographyPanel/FontsSection/index.ts had zero importers — every consumer
deep-imports the concrete files (admin barrels are convention-only, and
these had drifted out of use entirely).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sweep of the verified dead surface flagged by the dead-code audit
(knip with the new entry-point config + per-symbol verification):

- src/core/publisher/render.ts: delete the backward-compat re-export shim
  ("kept importable so existing callers don't need to retarget" — nothing
  imported through it anymore; back-compat shims are banned in this repo).
- server/publish/publicRouter.ts: un-export resolvePublicRoute /
  publicSlugFromPath / PublicRouteResolution (internal-only callers).
- Delete dead API functions with zero callers: exportCmsBundle /
  importCmsBundle (persistence), deleteUserPreference, updateCredential,
  listDrivers, readDefaultForScope / clearDefaultForScope,
  stopPublishScheduler, resetImageVariantWorkerPool,
  _resetFontCachesForTests, isEditorWorkspaceId, countWireNodes,
  isSafeFontPath — plus their now-orphaned schemas, constants, and types.
- Un-export ~180 exports and ~630 type aliases that nothing imports
  (export keyword removed where the symbol is still used in-file; the
  declaration deleted where it is fully dead). Constants that survived
  only to derive a union type are inlined as literal unions
  (stepUpPolicy, siteExplorer section ids, hookBus core events).
- Restore one knip false positive found by tsc: InsertionPresetNode is
  type-imported through the module-picker barrel and stays exported.

Verified by the gates after every step: tsc strict, eslint, 5,343 tests,
vite build — all green. knip now reports 0 unused files / 0 exports /
0 types.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…g-cleanup

# Conflicts:
#	server/publish/templateSeeding.ts
#	server/repositories/data/index.ts
@DavidBabinec DavidBabinec merged commit 0a427e9 into main Jun 12, 2026
5 checks passed
@DavidBabinec DavidBabinec deleted the chore/dead-code-spring-cleanup branch June 13, 2026 09:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant