[PR #8888] [MERGED] chore(knip): fix CI blind spots and remove dead code #16527

Closed
opened 2026-04-13 10:33:36 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/8888
Author: @gustavovalverde
Created: 4/1/2026
Status: Merged
Merged: 4/2/2026
Merged by: @gustavovalverde

Base: mainHead: chore/knip-dead-code-cleanup


📝 Commits (1)

  • d5c37cd chore(knip): fix CI blind spots and remove dead code

📊 Changes

25 files changed (+65 additions, -325 deletions)

View changed files

📝 .cspell/third-party.txt (+1 -0)
📝 knip.jsonc (+26 -134)
📝 lefthook.yml (+2 -0)
📝 package.json (+1 -1)
📝 packages/better-auth/package.json (+0 -5)
📝 packages/cli/package.json (+0 -4)
📝 packages/cli/src/commands/init/index.ts (+1 -1)
📝 packages/cli/src/commands/init/utility/database.ts (+1 -1)
📝 packages/cli/src/commands/secret.ts (+2 -6)
📝 packages/cli/src/commands/upgrade.ts (+1 -1)
📝 packages/cli/src/utils/check-package-managers.ts (+2 -4)
📝 packages/cli/src/utils/helper.ts (+0 -10)
📝 packages/cli/test/__snapshots__/schema-mongodb.prisma (+2 -1)
📝 packages/cli/test/__snapshots__/schema-mysql-custom.prisma (+2 -1)
📝 packages/cli/test/__snapshots__/schema-mysql.prisma (+2 -1)
📝 packages/cli/test/__snapshots__/schema-numberid.prisma (+2 -1)
📝 packages/cli/test/__snapshots__/schema-prisma-use-plural.prisma (+2 -1)
📝 packages/cli/test/__snapshots__/schema-uuid.prisma (+2 -1)
📝 packages/cli/test/__snapshots__/schema.prisma (+2 -1)
📝 packages/oauth-provider/src/utils/index.ts (+2 -2)

...and 5 more files

📄 Description

Summary

lint:dependencies ran knip --strict, which in this knip version means production-only analysis. Three compounding issues made the check a silent no-op:

  1. Production mode skipped all devDependencies. 8 dead devDeps across better-auth, prisma-adapter, test/, and cli were invisible.
  2. CLI and electron project patterns lacked the ! production suffix. Knip negates unsuffixed patterns in --production mode, so all 47 CLI source files were excluded from the dependency graph. Every CLI dependency appeared unused.
  3. ~40 stale ignoreDependencies entries masked the remaining findings. Many became stale after recent build optimization work but went unnoticed because the check was already blind.

The fix runs both knip (full analysis) and knip --production (shipped-code analysis) in a single lint:dependencies invocation, following the official recommendation that both modes coexist.

Dead dependencies removed (8)

  • better-auth: deepmerge, tarn, tedious, better-sqlite3, @types/better-sqlite3
  • cli: @prisma/client, @types/pg, drizzle-orm, pg (scaffold-only string references, not runtime deps)
  • prisma-adapter: prisma
  • test/: msw (duplicate of the one in better-auth)

Dead exports fixed (10)

  • 7 exports narrowed to module-private (used only within their file)
  • generateSecretHash duplicate removed from secret.ts (identical function exists in helper.ts)
  • enterAlternateScreen and exitAlternateScreen deleted (unused terminal escape helpers)

Config overhaul

  • Removed ~40 stale ignoreDependencies across cli, better-auth, expo, electron, sso, test-utils, stripe, prisma-adapter, drizzle-adapter, kysely-adapter, mongo-adapter
  • Added ! production suffix to entry/project patterns so --production traces dependency chains through source files
  • Updated $schema to the official unpkg URL
  • Removed undocumented vitest.project field
  • Removed stale @lintignore tag, unused @tailwindcss/vite catalog entry
  • Added verified false-positive suppressions with comments explaining each

Restored docs/.gitignore

PR #8195 deleted docs/.gitignore, which contained the .source entry for fumadocs-mdx auto-generated files. Without it, pnpm install causes these files to appear in git status.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/8888 **Author:** [@gustavovalverde](https://github.com/gustavovalverde) **Created:** 4/1/2026 **Status:** ✅ Merged **Merged:** 4/2/2026 **Merged by:** [@gustavovalverde](https://github.com/gustavovalverde) **Base:** `main` ← **Head:** `chore/knip-dead-code-cleanup` --- ### 📝 Commits (1) - [`d5c37cd`](https://github.com/better-auth/better-auth/commit/d5c37cd14948ac6a75769d1b1175f84615cf3855) chore(knip): fix CI blind spots and remove dead code ### 📊 Changes **25 files changed** (+65 additions, -325 deletions) <details> <summary>View changed files</summary> 📝 `.cspell/third-party.txt` (+1 -0) 📝 `knip.jsonc` (+26 -134) 📝 `lefthook.yml` (+2 -0) 📝 `package.json` (+1 -1) 📝 `packages/better-auth/package.json` (+0 -5) 📝 `packages/cli/package.json` (+0 -4) 📝 `packages/cli/src/commands/init/index.ts` (+1 -1) 📝 `packages/cli/src/commands/init/utility/database.ts` (+1 -1) 📝 `packages/cli/src/commands/secret.ts` (+2 -6) 📝 `packages/cli/src/commands/upgrade.ts` (+1 -1) 📝 `packages/cli/src/utils/check-package-managers.ts` (+2 -4) 📝 `packages/cli/src/utils/helper.ts` (+0 -10) 📝 `packages/cli/test/__snapshots__/schema-mongodb.prisma` (+2 -1) 📝 `packages/cli/test/__snapshots__/schema-mysql-custom.prisma` (+2 -1) 📝 `packages/cli/test/__snapshots__/schema-mysql.prisma` (+2 -1) 📝 `packages/cli/test/__snapshots__/schema-numberid.prisma` (+2 -1) 📝 `packages/cli/test/__snapshots__/schema-prisma-use-plural.prisma` (+2 -1) 📝 `packages/cli/test/__snapshots__/schema-uuid.prisma` (+2 -1) 📝 `packages/cli/test/__snapshots__/schema.prisma` (+2 -1) 📝 `packages/oauth-provider/src/utils/index.ts` (+2 -2) _...and 5 more files_ </details> ### 📄 Description ## Summary `lint:dependencies` ran `knip --strict`, which in this knip version means production-only analysis. Three compounding issues made the check a silent no-op: 1. **Production mode skipped all devDependencies.** 8 dead devDeps across `better-auth`, `prisma-adapter`, `test/`, and `cli` were invisible. 2. **CLI and electron project patterns lacked the `!` production suffix.** Knip negates unsuffixed patterns in `--production` mode, so all 47 CLI source files were excluded from the dependency graph. Every CLI dependency appeared unused. 3. **~40 stale `ignoreDependencies` entries masked the remaining findings.** Many became stale after recent build optimization work but went unnoticed because the check was already blind. The fix runs both `knip` (full analysis) and `knip --production` (shipped-code analysis) in a single `lint:dependencies` invocation, following the official recommendation that both modes coexist. ### Dead dependencies removed (8) - `better-auth`: deepmerge, tarn, tedious, better-sqlite3, @types/better-sqlite3 - `cli`: @prisma/client, @types/pg, drizzle-orm, pg (scaffold-only string references, not runtime deps) - `prisma-adapter`: prisma - `test/`: msw (duplicate of the one in `better-auth`) ### Dead exports fixed (10) - 7 exports narrowed to module-private (used only within their file) - `generateSecretHash` duplicate removed from `secret.ts` (identical function exists in `helper.ts`) - `enterAlternateScreen` and `exitAlternateScreen` deleted (unused terminal escape helpers) ### Config overhaul - Removed ~40 stale `ignoreDependencies` across cli, better-auth, expo, electron, sso, test-utils, stripe, prisma-adapter, drizzle-adapter, kysely-adapter, mongo-adapter - Added `!` production suffix to `entry`/`project` patterns so `--production` traces dependency chains through source files - Updated `$schema` to the official unpkg URL - Removed undocumented `vitest.project` field - Removed stale `@lintignore` tag, unused `@tailwindcss/vite` catalog entry - Added verified false-positive suppressions with comments explaining each ### Restored docs/.gitignore PR #8195 deleted `docs/.gitignore`, which contained the `.source` entry for fumadocs-mdx auto-generated files. Without it, `pnpm install` causes these files to appear in `git status`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 10:33:36 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#16527