ci: add dead code detection with knip, ts-prune, and ts-unused-exports#13801
Draft
ci: add dead code detection with knip, ts-prune, and ts-unused-exports#13801
Conversation
- Add knip config with proper entry points and ignore patterns for false positives (ambient .d.ts files, dynamic imports, peer deps) - Use pnpm dlx for ts-prune and ts-unused-exports (no devDependency) - Add parallel deadcode-check job to CI, triggered on code changes - Remove knip, ts-prune, ts-unused-exports from devDependencies Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: suyao <sy20010504@gmail.com>
Collaborator
|
Note This comment was translated by Claude. In #13531, I previously used knip and found some false positives. However, I didn't examine the configuration closely but rather had cc verify them individually. For automation, the configuration needs to be confirmed again. Original Content#13531 之前用 knip 发现会有一些误报,不过我没仔细看配置,而是让cc去逐个验证了。要自动化的话,需要再确认下配置 |
4 tasks
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.
What this PR does
Before this PR:
No automated dead code detection in CI. Unused files, exports, and dependencies accumulate silently.
After this PR:
Three dead code detection tools run as a parallel CI job on code changes:
pnpm dlx) — detects unused TypeScript exportspnpm dlx) — detects unused exports across tsconfig projectsAll three tools run in strict/error mode — CI fails if any dead code is detected.
Why we need it and why it was done in this way
The following tradeoffs were made:
ts-pruneandts-unused-exportsusepnpm dlxto avoid adding devDependencies;knipis installed because it needs a typed config fileignoreDependenciesfor false positives: dynamic imports (@cherrystudio/embedjs-loader-*), build plugins (@swc/plugin-styled-components,@electron/notarize), peer deps (TipTap collaboration,tailwindcss, etc.)deadcode-checkCI job runs in parallel with existing jobs, gated by the samechangesfilter (main/renderer/shared)The following alternatives were considered:
Breaking changes
None
Special notes for your reviewer
.d.tsfiles, test fixtures, scripts, and dynamically-imported peer dependencies to reduce false positivesChecklist
Release note