feat(oxfmt): Support oxfmt --init#16720
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. |
oxfmt --init
2ef7cc9 to
369ea8c
Compare
There was a problem hiding this comment.
Pull request overview
This PR adds support for the --init flag to oxfmt, enabling users to scaffold a default configuration file (.oxfmtrc.jsonc) similar to the existing oxlint --init functionality. The implementation includes proper error handling for existing configuration files, automatic schema reference injection when the schema file is available in node_modules, and appropriate exit codes for different scenarios.
Key Changes:
- Adds
--initCLI flag to create.oxfmtrc.jsoncwith default configuration - Refactors
print_and_flushutility function tocore/utils.rsfor code reuse - Introduces new
CliRunResultvariants (InitSucceeded,InitAborted,InitFailed) for proper exit code handling
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| apps/oxfmt/src/main.rs | Adds init flag check in main entry point |
| apps/oxfmt/src/main_napi.rs | Adds init flag check in NAPI entry point |
| apps/oxfmt/src/lib.rs | Exposes new init module |
| apps/oxfmt/src/init/mod.rs | Implements run_init() function with config file creation logic |
| apps/oxfmt/src/core/utils.rs | Adds print_and_flush() utility function moved from format.rs |
| apps/oxfmt/src/cli/result.rs | Adds new result variants for init operation and maps them to exit codes |
| apps/oxfmt/src/cli/format.rs | Refactors to use utils::print_and_flush() instead of local function |
| apps/oxfmt/src/cli/command.rs | Defines --init CLI flag in MiscOptions |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
369ea8c to
c013d61
Compare
Merge activity
|
c013d61 to
559eff1
Compare

Follow up #16703, fixes #16622
I will add test for
--initand also--lsplater.