fix: support knip.config.{ts,js,mjs,cjs} in dead-code analysis - #1585
Open
skoshx wants to merge 2 commits into
Open
fix: support knip.config.{ts,js,mjs,cjs} in dead-code analysis#1585skoshx wants to merge 2 commits into
skoshx wants to merge 2 commits into
Conversation
- 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>
commit: |
Contributor
Interactive terminal E2ERecorded from the built CLI at |
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.

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.jsonandpackage.json#knipwhen collectingentryandignorepatterns.In a workspace with
client/knip.config.ts, React Doctor resolvesclientas a scan root and reports generated files that the existing Knip config already ignores. To suppress the false positives, users must duplicate those paths inclient/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:knip.config.{ts,mts,cts,js,mjs,cjs}knip.jsonpackage.json#knipThis eliminates the need to duplicate ignore patterns solely for React Doctor.
Testing
.ts,.js,.mjs)Scope
The fix is narrowly scoped:
load-config.ts