Skip to content

chore: add knip dead-code analysis and clean up unused deps#868

Draft
ugcodrr wants to merge 4 commits into
mainfrom
chore/knip-dead-code-analysis
Draft

chore: add knip dead-code analysis and clean up unused deps#868
ugcodrr wants to merge 4 commits into
mainfrom
chore/knip-dead-code-analysis

Conversation

@ugcodrr
Copy link
Copy Markdown
Member

@ugcodrr ugcodrr commented Jun 1, 2026

Summary

  • Adds knip to detect and eliminate unused dependencies, devDependencies, exports, and files across the monorepo
  • Removes 10 unused runtime deps, 5 unused devDeps, and fixes 3 unlisted transitive deps in apps/scripts
  • pnpm knip now exits 0 — clean baseline for ongoing checks

What was found and removed

Unused devDependencies (5):

  • apps/api: @nestjs/testing — no test files exist
  • apps/scripts: @types/inquirer — inquirer v10 ships bundled types
  • apps/support-bot: @types/luxon — luxon not imported directly in support-bot
  • packages/discord: @types/i18next-fs-backend — i18next-fs-backend v2 ships bundled types
  • root: @types/eslint__js@eslint/js 9.34.0 ships its own type declarations

Unused runtime dependencies (10):

  • apps/api: toad-scheduler — imported nowhere; likely a leftover from a removed scheduler
  • apps/discord-bot: @typegoose/typegoose, mongoose — only used transitively via @statsify/schemas; not imported directly
  • apps/scripts: skia-canvasrank-emojis.js uses canvas via @statsify/rendering, never directly
  • apps/support-bot: axios, luxon — neither imported directly in support-bot source
  • packages/assets: @statsify/logger, axios — neither imported in packages/assets/src
  • packages/rendering: @statsify/assets — not imported in packages/rendering/src
  • packages/schemas: @statsify/logger — not imported in packages/schemas/src

Unlisted (fixed)apps/scripts imported mongoose and luxon directly without declaring them, surviving only via hoisting from discord-bot. Added as explicit deps.

JSX runtimejsxs was a direct alias of jsx (same value, flagged as duplicate export). Changed to a thin wrapper; identical runtime behavior, no duplicate.

knip.json design notes

  • Library packages (packages/*) use src/**/*.ts as entries so knip follows the full source graph, not just the barrel index. This is necessary because export * from "./file.js" chains under NodeNext aren't traversed when only the index is declared.
  • Apps use explicit entry patterns covering NestJS modules/controllers/services, dynamically-loaded Discord commands/events/arguments, Next.js app-router pages, and standalone scripts.
  • Structural false positives suppressed at config level: @swc/helpers (SWC compile-time runtime), reflect-metadata (side-effect dep in discord-bot), @vitest/coverage-v8 (vitest loads implicitly via --coverage), skin-renderer NAPI platform binaries, and blur/wasm-pack local toolchain binaries.

CI snippet (non-blocking, add when ready)

- name: Dead code check (knip)
  run: pnpm knip --no-exit-code

Drop --no-exit-code to make it a hard gate once the report stays clean.

Test plan

  • pnpm knip exits 0 with no findings
  • tsc --noEmit passes for all modified packages: api, discord-bot, support-bot, @statsify/discord, @statsify/assets, @statsify/rendering, @statsify/schemas

ugcodrr added 4 commits May 31, 2026 17:51
- Install knip@6 as root devDependency
- Add knip.json with per-workspace entry points covering NestJS
  controllers/modules, dynamically-loaded Discord commands/events/
  arguments, Next.js app-router pages, and standalone scripts
- Suppress known structural false positives: @swc/helpers (SWC compile-
  time runtime), reflect-metadata (side-effect-only dep in discord-bot),
  @vitest/coverage-v8 (vitest loads implicitly), skin-renderer NAPI
  platform binaries, and tooling deps not imported in source
- Add "knip" script to root package.json
- apps/api: @nestjs/testing (no test files exist)
- apps/scripts: @types/inquirer (inquirer v10 ships bundled types)
- apps/support-bot: @types/luxon (luxon not imported directly)
- packages/discord: @types/i18next-fs-backend (i18next-fs-backend v2
  ships bundled types)
- root: @types/eslint__js (@eslint/js ships its own type declarations)
- apps/api: toad-scheduler (no imports; scheduler was removed without
  cleaning up the dep)
- apps/discord-bot: @typegoose/typegoose, mongoose (used only
  transitively via @statsify/schemas; not imported directly)
- apps/scripts: skia-canvas (rank-emojis.js renders via
  @statsify/rendering; never imports skia-canvas directly)
- apps/support-bot: axios, luxon (neither imported directly; both
  arrive transitively through workspace deps)
- packages/assets: @statsify/logger, axios (neither imported in
  packages/assets/src)
- packages/rendering: @statsify/assets (not imported in
  packages/rendering/src)
- packages/schemas: @statsify/logger (not imported in
  packages/schemas/src)
- Add mongoose@^8.18.0 and luxon@^3.7.1 to apps/scripts dependencies;
  both were imported directly in delete-sessions.js and timestamp.js
  but only accessible via hoisting from discord-bot
- Add ignoreBinaries for blur (local mjs script) and wasm-pack (Rust
  toolchain), neither of which are npm packages
- Make packages/rendering jsxs a thin wrapper over jsx instead of a
  direct alias so knip does not flag the duplicate export; the JSX
  transform requires both names but this runtime treats them identically

pnpm knip now exits 0 with no findings.
@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
statsify Ready Ready Preview, Comment Jun 1, 2026 12:09am

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant