Skip to content

Conversation

@leaysgur
Copy link
Member

@leaysgur leaysgur commented Dec 8, 2025

Fixes #16525, closes #16541

  • Use sort-package-json: 0.0.2
  • Enable by default, can be disabled by experimentalSortPackageJson: false

@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter C-enhancement Category - New feature or request labels Dec 8, 2025
@leaysgur leaysgur changed the title feat(oxfmt): Enable experimental package.json sorting by default feat(oxfmt): Enable experimental package.json sorting by default Dec 8, 2025
Copy link
Member Author

leaysgur commented Dec 8, 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 Dec 8, 2025

CodSpeed Performance Report

Merging #16593 will not alter performance

Comparing 12-08-feat_oxfmt_enable_experimental_package.json_sorting_by_default (8649cfa) with main (0d5da26)1

Summary

✅ 42 untouched
⏩ 3 skipped2

Footnotes

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

  2. 3 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.

@graphite-app graphite-app bot changed the base branch from 12-08-feat_oxfmt_pass_filepath_field_to_prettier_formatting to graphite-base/16593 December 8, 2025 08:31
@graphite-app graphite-app bot force-pushed the 12-08-feat_oxfmt_enable_experimental_package.json_sorting_by_default branch from 6f70b8e to 3fbec5a Compare December 8, 2025 08:36
@graphite-app graphite-app bot force-pushed the graphite-base/16593 branch from 9027b54 to eb6c9bc Compare December 8, 2025 08:36
@graphite-app graphite-app bot changed the base branch from graphite-base/16593 to main December 8, 2025 08:36
@graphite-app graphite-app bot force-pushed the 12-08-feat_oxfmt_enable_experimental_package.json_sorting_by_default branch 3 times, most recently from b3ce1df to 0780cef Compare December 8, 2025 08:48
@leaysgur leaysgur force-pushed the 12-08-feat_oxfmt_enable_experimental_package.json_sorting_by_default branch 4 times, most recently from e6bafe8 to 0140045 Compare December 8, 2025 23:52
@leaysgur
Copy link
Member Author

leaysgur commented Dec 8, 2025

NOTE: Hold off for a bit.

Because, as per #16606, the infrastructure might change, and if we only pass the path to Prettier, we'd need to prepare a separate place for this feature to intervene.

@leaysgur leaysgur force-pushed the 12-08-feat_oxfmt_enable_experimental_package.json_sorting_by_default branch 2 times, most recently from b2b4c8f to 0a5276a Compare December 9, 2025 05:14
@leaysgur leaysgur marked this pull request as ready for review December 9, 2025 05:20
@leaysgur leaysgur requested a review from Dunqing as a code owner December 9, 2025 05:20
Copilot AI review requested due to automatic review settings December 9, 2025 05:20
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 enables experimental package.json sorting by default using the sort-package-json crate version 0.0.2. The feature can be disabled via the experimentalSortPackageJson: false configuration option. The implementation integrates package.json sorting into the formatting pipeline before passing files to the external formatter (Prettier).

Key Changes:

  • Added experimentalSortPackageJson configuration option (defaults to true)
  • Integrated sort-package-json crate for automatic key sorting
  • Refactored error handling in format.rs to use Result types for better composability

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tasks/website_formatter/src/snapshots/schema_markdown.snap Added documentation for the new experimentalSortPackageJson configuration field
npm/oxfmt/configuration_schema.json Added JSON schema definition for experimentalSortPackageJson with default value true
crates/oxc_formatter/tests/snapshots/schema_json.snap Updated schema snapshot to include the new configuration field
crates/oxc_formatter/src/service/oxfmtrc.rs Added experimental_sort_package_json field with default true, removed it from Prettier config passthrough
apps/oxfmt/test/__snapshots__/external_formatter.test.ts.snap Updated test snapshot showing package.json keys sorted (engines moved after dependencies)
apps/oxfmt/src/core/support.rs Added is_package_json() method to detect package.json files by checking parser name and filename
apps/oxfmt/src/core/format.rs Integrated sort-package-json before Prettier formatting, refactored to use Result-based error handling
apps/oxfmt/src/cli/format.rs Plumbed through is_sort_package_json configuration from config loading to formatter initialization
apps/oxfmt/Cargo.toml Added sort-package-json = "0.0.2" dependency
Cargo.lock Updated lockfile with sort-package-json dependency and its transitive dependencies

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@leaysgur
Copy link
Member Author

leaysgur commented Dec 9, 2025

I will make some minor adjustments to improve readability.

@leaysgur leaysgur marked this pull request as draft December 9, 2025 08:04
@leaysgur leaysgur force-pushed the 12-08-feat_oxfmt_enable_experimental_package.json_sorting_by_default branch 2 times, most recently from 1de7005 to 8649cfa Compare December 9, 2025 08:28
@leaysgur
Copy link
Member Author

leaysgur commented Dec 9, 2025

Reviews will be covered by: #16635

@leaysgur leaysgur marked this pull request as ready for review December 9, 2025 08:55
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Dec 10, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Dec 10, 2025

Merge activity

…16593)

Fixes #16525, closes #16541

- Use `sort-package-json: 0.0.2`
- Enable by default, can be disabled by `experimentalSortPackageJson: false`
@graphite-app graphite-app bot force-pushed the 12-08-feat_oxfmt_enable_experimental_package.json_sorting_by_default branch from 8649cfa to 28e0682 Compare December 10, 2025 01:47
graphite-app bot pushed a commit that referenced this pull request Dec 10, 2025
…6635)

Addressed review in #16593

- Add `OxfmtOptions` struct
- Rename `FormatFileSource` to `FormatFileStrategy`
  - And include `package.json` as `ExternalFormatterPackageJson` variant
@graphite-app graphite-app bot merged commit 28e0682 into main Dec 10, 2025
21 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 10, 2025
@graphite-app graphite-app bot deleted the 12-08-feat_oxfmt_enable_experimental_package.json_sorting_by_default branch December 10, 2025 01:53
Copilot AI pushed a commit that referenced this pull request Dec 10, 2025
…16593)

Fixes #16525, closes #16541

- Use `sort-package-json: 0.0.2`
- Enable by default, can be disabled by `experimentalSortPackageJson: false`
Copilot AI pushed a commit that referenced this pull request Dec 10, 2025
…6635)

Addressed review in #16593

- Add `OxfmtOptions` struct
- Rename `FormatFileSource` to `FormatFileStrategy`
  - And include `package.json` as `ExternalFormatterPackageJson` variant
taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
…xc-project#16593)

Fixes oxc-project#16525, closes oxc-project#16541

- Use `sort-package-json: 0.0.2`
- Enable by default, can be disabled by `experimentalSortPackageJson: false`
taearls pushed a commit to taearls/oxc that referenced this pull request Dec 11, 2025
…c-project#16635)

Addressed review in oxc-project#16593

- Add `OxfmtOptions` struct
- Rename `FormatFileSource` to `FormatFileStrategy`
  - And include `package.json` as `ExternalFormatterPackageJson` variant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatter: sort package json

4 participants