Skip to content

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Sep 25, 2025

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.

@github-actions github-actions bot added A-formatter Area - Formatter C-enhancement Category - New feature or request labels Sep 25, 2025
Copy link
Member Author

leaysgur commented Sep 25, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

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-hq
Copy link

codspeed-hq bot commented Sep 25, 2025

CodSpeed Performance Report

Merging #14105 will not alter performance

Comparing 09-25-feat_formatter_experimental_sort-imports_base (6be4ae5) with main (bb679b5)1

Summary

✅ 33 untouched
⏩ 4 skipped2

Footnotes

  1. No successful run was found on main (b3c5132) during the generation of this report, so bb679b5 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 4 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@leaysgur leaysgur force-pushed the 09-25-feat_formatter_experimental_sort-imports_base branch 2 times, most recently from f351a27 to 36a42e8 Compare September 25, 2025 07:44
@leaysgur leaysgur force-pushed the 09-25-feat_formatter_experimental_sort-imports_base branch 3 times, most recently from deebe2e to 186c068 Compare September 26, 2025 09:18
@leaysgur leaysgur force-pushed the 09-25-feat_formatter_experimental_sort-imports_base branch 3 times, most recently from 690587c to d1cfe9a Compare September 30, 2025 01:29
@leaysgur leaysgur force-pushed the 09-25-feat_formatter_experimental_sort-imports_base branch 3 times, most recently from 4e6bee7 to fedf5fb Compare October 2, 2025 01:47
@leaysgur leaysgur marked this pull request as ready for review October 2, 2025 03:47
@leaysgur leaysgur requested a review from Dunqing as a code owner October 2, 2025 03:47
Copilot AI review requested due to automatic review settings October 2, 2025 03:47
Copy link
Contributor

Copilot AI left a 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 SortImports configuration 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.

@leaysgur leaysgur changed the title feat(formatter): Experimental sort-imports base feat(formatter/sort-imports): Experimental sort-imports base Oct 2, 2025
@leaysgur leaysgur marked this pull request as draft October 2, 2025 10:32
@leaysgur leaysgur force-pushed the 09-25-feat_formatter_experimental_sort-imports_base branch from fedf5fb to d55d1c7 Compare October 6, 2025 00:14
@leaysgur leaysgur marked this pull request as ready for review October 6, 2025 09:37
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Oct 7, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Oct 7, 2025

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.
@graphite-app graphite-app bot force-pushed the 09-25-feat_formatter_experimental_sort-imports_base branch from d55d1c7 to 6be4ae5 Compare October 7, 2025 00:31
@graphite-app graphite-app bot added 0-merge Merge with Graphite Merge Queue and removed 0-merge Merge with Graphite Merge Queue labels Oct 7, 2025
@graphite-app graphite-app bot merged commit 6be4ae5 into main Oct 7, 2025
39 of 40 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 7, 2025
@graphite-app graphite-app bot deleted the 09-25-feat_formatter_experimental_sort-imports_base branch October 7, 2025 01:06
@Boshen Boshen mentioned this pull request Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatter Area - Formatter C-enhancement Category - New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants