-
-
Notifications
You must be signed in to change notification settings - Fork 722
feat(formatter/sort-imports): Experimental sort-imports base #14105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(formatter/sort-imports): Experimental sort-imports base #14105
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via the merge queue:
You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #14105 will not alter performanceComparing Summary
Footnotes
|
f351a27 to
36a42e8
Compare
deebe2e to
186c068
Compare
690587c to
d1cfe9a
Compare
4e6bee7 to
fedf5fb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces experimental support for sorting imports in the formatter by implementing an IR transformation approach. The implementation allows import statements to be reordered after the main formatting process is complete.
- Adds a new
SortImportsconfiguration struct with options for partitioning by newlines, comments, and sorting side effects - Implements an IR transformation system that can be applied to the formatted document
- Provides an example demonstrating the sort imports functionality
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_formatter/src/options.rs | Adds SortImports struct and experimental_sort_imports option to FormatOptions |
| crates/oxc_formatter/src/lib.rs | Integrates sort imports transformation into the main formatting workflow |
| crates/oxc_formatter/src/ir_transform/sort_imports.rs | Implements the SortImportsTransform with placeholder logic |
| crates/oxc_formatter/src/ir_transform/mod.rs | Module definition for IR transforms |
| crates/oxc_formatter/src/formatter/mod.rs | Adds apply_transform method to Formatted struct |
| crates/oxc_formatter/examples/sort_imports.rs | Example demonstrating sort imports usage |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
fedf5fb to
d55d1c7
Compare
Merge activity
|
Part of #14253 This is preparation for implementing sort-imports by reordering IR. While performance is inferior, it is separated from the main formatting process and is completely opt-in. This should also make it easier to find the cause if any issues arise.
d55d1c7 to
6be4ae5
Compare

Part of #14253
This is preparation for implementing sort-imports by reordering IR.
While performance is inferior, it is separated from the main formatting process and is completely opt-in.
This should also make it easier to find the cause if any issues arise.