From c587a643202faa4342e141f5c7a09ac06c7a6098 Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Wed, 1 Apr 2026 04:57:34 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=20knip=20=E5=86=97?= =?UTF-8?q?=E4=BD=99=E4=BB=A3=E7=A0=81=E6=A3=80=E6=9F=A5=E5=B7=A5=E5=85=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 配置 knip.json 检测未使用的文件、exports、依赖等。 新增 check:unused script,运行 knip-bun 扫描死代码。 Co-Authored-By: Claude Opus 4.6 --- TODO.md | 2 +- knip.json | 22 ++++++++++++++++++++++ package.json | 4 +++- 3 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 knip.json diff --git a/TODO.md b/TODO.md index e7bc280..c78697f 100644 --- a/TODO.md +++ b/TODO.md @@ -18,7 +18,7 @@ ## 工程化能力 - [x] 代码格式化与校验 -- [ ] 冗余代码检查 +- [x] 冗余代码检查 - [x] git hook 的配置 - [ ] 代码健康度检查 - [x] 单元测试基础设施搭建 (test runner 配置) diff --git a/knip.json b/knip.json new file mode 100644 index 0000000..bc66542 --- /dev/null +++ b/knip.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://unpkg.com/knip@6/schema.json", + "entry": ["src/entrypoints/cli.tsx"], + "project": ["src/**/*.{ts,tsx}"], + "ignore": ["src/types/**", "src/**/*.d.ts"], + "ignoreDependencies": [ + "@ant/*", + "react-compiler-runtime", + "@anthropic-ai/mcpb", + "@anthropic-ai/sandbox-runtime" + ], + "ignoreBinaries": ["bun"], + "workspaces": { + "packages/*": { + "entry": ["src/index.ts"], + "project": ["src/**/*.ts"] + }, + "packages/@ant/*": { + "ignore": ["**"] + } + } +} diff --git a/package.json b/package.json index a8da522..7e6789f 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,8 @@ "lint:fix": "biome check --fix src/", "format": "biome format --write src/", "prepare": "git config core.hooksPath .githooks", - "test": "bun test" + "test": "bun test", + "check:unused": "knip-bun" }, "dependencies": { "@alcalzone/ansi-tokenize": "^0.3.0", @@ -132,6 +133,7 @@ "@types/react-reconciler": "^0.33.0", "@types/sharp": "^0.32.0", "@types/turndown": "^5.0.6", + "knip": "^6.1.1", "typescript": "^6.0.2" } }