Skip to content

Commit a362d1b

Browse files
Brian M Huntclaude
authored andcommitted
Add knip config for dead code detection
Configure knip with workspace awareness for the TKO monorepo. Add `bun run knip` script. Remove unused fs-extra devDependency. Findings (config only, no code changes): - 3 unused files, 8 unused deps, 10 unlisted deps - 10 unused exports, 19 unused exported types, 2 duplicate exports These will be addressed in Phase 6 (separate PRs per category). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 51964be commit a362d1b

5 files changed

Lines changed: 74 additions & 49 deletions

File tree

AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ bun run lint # Run Biome lint only
4343
bun run lint:fix # Run Biome lint with auto-fix
4444
bun run format # Check Biome formatting
4545
bun run format:fix # Fix Biome formatting
46+
bun run knip # Detect unused files, deps, and exports
4647
bun run tsc # TypeScript type-check (no emit)
4748
bun run dts # Generate TypeScript declaration files
4849
bun run clean # Clean dist/ and coverage/ dirs

bun.lock

Lines changed: 3 additions & 48 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

knip.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"$schema": "https://unpkg.com/knip@5/schema.json",
3+
"workspaces": {
4+
".": {
5+
"entry": ["vitest.config.ts", "tools/build.ts"],
6+
"project": ["*.ts", "tools/**/*.ts"]
7+
},
8+
"packages/*": {
9+
"entry": ["index.ts", "src/index.ts"],
10+
"project": ["src/**/*.ts"]
11+
},
12+
"builds/*": {
13+
"entry": ["index.ts", "src/index.ts"],
14+
"project": ["src/**/*.ts"]
15+
}
16+
},
17+
"ignoreDependencies": [
18+
"tslib",
19+
"@vitest/browser",
20+
"@vitest/browser-playwright",
21+
"esbuild",
22+
"playwright"
23+
]
24+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"lint": "bunx @biomejs/biome lint .",
1818
"lint:fix": "bunx @biomejs/biome check --fix .",
1919
"check": "bunx @biomejs/biome check .",
20+
"knip": "bunx knip",
2021
"verify:esm": "bun tools/verify-esm-extensions.ts",
2122
"verify": "bunx @biomejs/biome check . && bunx tsc && bun run build && bun run verify:esm && bunx vitest run",
2223
"clean": "rm -rf packages/*/dist builds/*/dist coverage"
@@ -37,7 +38,6 @@
3738
"@vitest/browser-playwright": "^4.1.4",
3839
"chai": "^6.2.2",
3940
"esbuild": "^0.28.0",
40-
"fs-extra": "^11.3.2",
4141
"jquery": "^4.0.0",
4242
"playwright": "^1.59.1",
4343
"sinon": "^21.0.3",

plans/knip.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Plan: Add knip for dead code detection
2+
3+
## Context
4+
5+
knip detects unused files, dependencies, exports, and types in the codebase.
6+
A previous attempt (PR #234) was reverted because it mixed the linter setup
7+
with code changes (verbatimModuleSyntax, type refactoring, export cleanup)
8+
in a single 56-file PR.
9+
10+
This time: Phase 5 adds the linter config + CI only. Phase 6 fixes findings
11+
in separate, focused PRs.
12+
13+
## Findings (with config)
14+
15+
| Category | Count | Notes |
16+
|---|---|---|
17+
| Unused files | 3 | `builds/*/src/common.ts`, `tools/template/index.ts` |
18+
| Unused dependencies | 8 | `@tko/*` packages not imported, declared in package.json |
19+
| Unused devDependencies | 1 | `fs-extra` (leftover from old tooling) |
20+
| Unlisted dependencies | 10 | `@tko/*` imports missing from package.json |
21+
| Unused exports | 10 | Functions/classes exported but never imported |
22+
| Unused exported types | 19 | Type-only exports never imported |
23+
| Duplicate exports | 2 | Same symbol exported under two names |
24+
25+
## What this PR does
26+
27+
1. Add `knip.json` config with workspace awareness
28+
2. Add `bun run knip` script to package.json
29+
3. Add knip to CI (warn-only, non-blocking initially)
30+
4. Remove `fs-extra` from devDependencies (genuinely unused)
31+
5. Update AGENTS.md and plans/
32+
33+
## What this PR does NOT do
34+
35+
- No source code changes (no removing exports, deps, or files)
36+
- No `verbatimModuleSyntax`
37+
- No type refactoring
38+
- Those come in Phase 6, one category per PR
39+
40+
## Verification
41+
42+
1. `bunx knip` runs cleanly with known findings
43+
2. `bun run build` still works
44+
3. `bunx vitest run` still passes
45+
4. CI workflow runs and reports findings

0 commit comments

Comments
 (0)