-
-
Notifications
You must be signed in to change notification settings - Fork 739
feat(oxfmt): Enable experimental package.json sorting by default
#16593
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(oxfmt): Enable experimental package.json sorting by default
#16593
Conversation
package.json sorting by default
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 #16593 will not alter performanceComparing Summary
Footnotes
|
6f70b8e to
3fbec5a
Compare
9027b54 to
eb6c9bc
Compare
b3ce1df to
0780cef
Compare
e6bafe8 to
0140045
Compare
|
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. |
b2b4c8f to
0a5276a
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 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
experimentalSortPackageJsonconfiguration option (defaults totrue) - Integrated
sort-package-jsoncrate for automatic key sorting - Refactored error handling in
format.rsto useResulttypes 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.
|
I will make some minor adjustments to improve readability. |
1de7005 to
8649cfa
Compare
|
Reviews will be covered by: #16635 |
Merge activity
|
8649cfa to
28e0682
Compare
…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`
…c-project#16635) Addressed review in oxc-project#16593 - Add `OxfmtOptions` struct - Rename `FormatFileSource` to `FormatFileStrategy` - And include `package.json` as `ExternalFormatterPackageJson` variant

Fixes #16525, closes #16541
sort-package-json: 0.0.2experimentalSortPackageJson: false