fix(linter): sort paths by length instead of alphabetically for depth heuristic#18084
Merged
graphite-app[bot] merged 1 commit intomainfrom Jan 16, 2026
Merged
fix(linter): sort paths by length instead of alphabetically for depth heuristic#18084graphite-app[bot] merged 1 commit intomainfrom
graphite-app[bot] merged 1 commit intomainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug in the linter's path sorting logic where paths were being sorted in reverse alphabetical order instead of by depth. The fix changes the sorting to use path length descending as a heuristic for depth, allowing leaf modules to be processed earlier and released from memory sooner.
Changes:
- Replace reverse alphabetical path sorting with length-based descending sort
- Add clarifying comments explaining the O(1) comparison approach
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
CodSpeed Performance ReportMerging this PR will not alter performanceComparing Summary
Footnotes
|
camc314
approved these changes
Jan 16, 2026
Contributor
Merge activity
|
… heuristic (#18084) ## Summary Fixes the path sorting bug identified in #15924 where the linter's path sorting was intended to process "deeper" paths first (so leaf modules can be processed and released from memory earlier), but was actually sorting in reverse alphabetical order. **Example of the bug:** - `src/a/b/c/d.js` (4 levels deep) vs `src/z.js` (1 level) - Alphabetically: `src/a/...` < `src/z.js` (because 'a' < 'z') - With reverse sort: `src/z.js` came BEFORE the deeper path (wrong!) **The fix:** Sort by path length descending instead (`b.len().cmp(&a.len())`), which is a good proxy for depth and achieves O(1) comparison cost per the comment in #15924. Closes #15924 ## Test plan - [x] `cargo check -p oxc_linter` passes - [x] `cargo test -p oxc_linter` passes - [x] `just fmt` passes 🤖 Generated with [Claude Code](https://claude.com/claude-code)
4b48087 to
121a239
Compare
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.
Summary
Fixes the path sorting bug identified in #15924 where the linter's path sorting was intended to process "deeper" paths first (so leaf modules can be processed and released from memory earlier), but was actually sorting in reverse alphabetical order.
Example of the bug:
src/a/b/c/d.js(4 levels deep) vssrc/z.js(1 level)src/a/...<src/z.js(because 'a' < 'z')src/z.jscame BEFORE the deeper path (wrong!)The fix: Sort by path length descending instead (
b.len().cmp(&a.len())), which is a good proxy for depth and achieves O(1) comparison cost per the comment in #15924.Closes #15924
Test plan
cargo check -p oxc_linterpassescargo test -p oxc_linterpassesjust fmtpasses🤖 Generated with Claude Code