ci: 引入 knip 死代码 dry-run(仅报告,不删除代码) - #207
Open
xingwangzhe wants to merge 1 commit into
Open
Conversation
|
@xingwangzhe is attempting to deploy a commit to the hikariming's projects Team on Vercel. A member of the Team first needs to authorize it. |
Add knip as a devDependency with a `knip` script and a knip.json configured to scan the app (Vitest test files as entries, and the standalone `packages/ghfind-js` SDK excluded from the root scan). The dry-run currently reports findings (unused deps/files, undeclared `server-only`, etc.) — intentionally no code is deleted here so the maintainer can decide. A non-blocking `continue-on-error` step is added to CI so the report is visible without blocking merges. Signed-off-by: 王兴家 <xingwangzhe@outlook.com>
xingwangzhe
force-pushed
the
codex/ci/knip-dry-run
branch
from
August 18, 2026 10:54
e0439ad to
2b40e11
Compare
xingwangzhe
marked this pull request as ready for review
August 18, 2026 10:55
xingwangzhe
requested review from
AsperforMias,
KurosawaGeeker and
hikariming
as code owners
August 18, 2026 10:55
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 issue
背景
引入 knip 死代码 / 未用依赖静态检测(纯 dry-run,只读,未删除任何代码),并把当前发现的冗余项列出来,交由管理员决策;同时建议把 knip dry-run 纳入 CI。完整发现清单见 #208。
改动
package.json:新增knip@^6.32.2devDependency 与"knip": "knip"script。knip.json(新增):基础配置,并处理两个 knip 默认行为:vitest.config.ts没有test段,导致插件默认不把测试文件当 entry、100+ 测试文件被误报为 unused;这里显式声明src/**/*.test.{ts,tsx}、packages/**/*.test.{ts,tsx}为 Vitest entry。packages/ghfind-js是独立发布的 SDK(不在 pnpm workspace 内),其入口文件/导出被误报,已ignore;后续可单独扫描。.github/workflows/ci.yml:在 lint 之后新增Knip (dead code dry-run)步骤,continue-on-error: true非阻塞——只展示报告、不挡合并;注释里说明等冗余清理完毕后去掉该开关即可强制。说明 / 局限
@radix-ui/react-separator(仅被无引用的separator.tsx使用)、@vercel/speed-insights(全仓库无引用)。server-only在 7 个文件被 import 但不在 package.json/lock(构建能过是 Next.js 对它有内置特判,建议补声明)。scripts/blog-aggregates.mts硬编码了他人机器绝对路径/Users/rqq/github-roast/...,本机/CI 无法运行,建议修复或删除。本地验证
pnpm install --frozen-lockfile✅(lockfile 与 package.json 一致)pnpm knip可运行,exit 1 表示存在发现项(dry-run 预期行为),报告与 chore: 引入 knip 死代码 dry-run,列出冗余项供决策 #208 一致🤖 Generated with Codex