Skip to content

fix: support knip.config.{ts,js,mjs,cjs} in dead-code analysis - #1585

Open
skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1583-1403
Open

fix: support knip.config.{ts,js,mjs,cjs} in dead-code analysis#1585
skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1583-1403

Conversation

@skoshx

@skoshx skoshx commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Problem

React Doctor 0.9.5 uses deslop-js for dead-code diagnostics but does not consume the standard TypeScript Knip config file. It only reads knip.json and package.json#knip when collecting entry and ignore patterns.

In a workspace with client/knip.config.ts, React Doctor resolves client as a scan root and reports generated files that the existing Knip config already ignores. To suppress the false positives, users must duplicate those paths in client/package.json.

Closes #1583

Solution

React Doctor now loads TypeScript and JavaScript Knip config files using jiti (already used for doctor.config.ts). Config files are resolved in this order:

  1. knip.config.{ts,mts,cts,js,mjs,cjs}
  2. knip.json
  3. package.json#knip

This eliminates the need to duplicate ignore patterns solely for React Doctor.

Testing

  • Added unit tests for each config format (.ts, .js, .mjs)
  • Verified config precedence (TS config takes priority over JSON)
  • Verified workspace pattern handling
  • All existing tests pass
  • Typecheck and lint pass

Scope

The fix is narrowly scoped:

  • Only adds config file loading, doesn't change diagnostic logic
  • Uses the same jiti pattern as load-config.ts
  • Fully backward compatible
  • No breaking changes
Open in Web Open in Cursor 

cursoragent and others added 2 commits August 5, 2026 08:48
- Add support for loading TypeScript/JavaScript Knip config files using jiti
- Maintain backward compatibility with knip.json and package.json#knip
- Follow standard config resolution order: knip.config.* → knip.json → package.json
- Add comprehensive unit tests for each config format

Fixes #1583

Co-authored-by: Skosh <skoshx@users.noreply.github.com>
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Aug 5, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@1585
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@1585
npm i https://pkg.pr.new/react-doctor@1585

commit: 36d57fa

@github-actions

github-actions Bot commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Interactive terminal E2E

React Doctor interactive terminal recording

Recorded from the built CLI at 36d57fa in a real terminal. The fixture holds Git busy for three seconds, so Scanning... must appear immediately after project selection, then exercises the compact interactive report.

Download the GIF and MP4 artifact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dead-code analysis ignores knip.config.ts

2 participants