feat(core): orphan and reachability-based unused file detection#3
Conversation
ca63e53 to
b8af59f
Compare
There was a problem hiding this comment.
Pull request overview
This PR implements reachability-based file detection to improve unused file detection by building a file dependency graph and checking reachability from entry points. When entry points are detected (via package.json exports or conventions), files are marked as unused only if they're unreachable from those entry points; otherwise, the system falls back to orphan detection for files with no incoming references.
Key Changes:
- Enhanced entry point detection to parse package.json
exportsfield (including conditional exports and arrays) - Implemented file dependency graph construction that tracks both import and re-export relationships
- Added reachability analysis using graph traversal from entry points
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integrate/barrel.test.ts | Adds test verifying re-exported files aren't flagged as unused |
| tests/entrypoints/entrypoint-export.test.ts | New test suite for package.json exports field parsing (string, conditional object, array formats) |
| src/core/usage/buildUsageGraph.ts | Implements file dependency graph, reachability analysis, and module resolution logic for unused file detection |
| src/core/fileSystem/normalizePath.ts | Refactors variable names for clarity (normalizeCache → normalizedFileCache, abs → absolutePath) |
| src/core/entrypoints/detectEntryPoints.ts | Extends entry point detection to handle exports field, refactors mapping logic into separate functions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
4dc811f to
4b402cb
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
f414b50 to
f4423ad
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Changes: