Skip to content

feat(oxfmt): Support oxfmt --init#16720

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-11-feat_oxfmt_support_--init
Dec 11, 2025
Merged

feat(oxfmt): Support oxfmt --init#16720
graphite-app[bot] merged 1 commit intomainfrom
12-11-feat_oxfmt_support_--init

Conversation

@leaysgur
Copy link
Copy Markdown
Member

@leaysgur leaysgur commented Dec 11, 2025

Follow up #16703, fixes #16622

I will add test for --init and also --lsp later.

Copilot AI review requested due to automatic review settings December 11, 2025 01:37
@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter C-enhancement Category - New feature or request labels Dec 11, 2025
Copy link
Copy Markdown
Member Author


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.

@leaysgur leaysgur changed the title feat(oxfmt): Support --init feat(oxfmt): Support oxfmt --init Dec 11, 2025
@leaysgur leaysgur force-pushed the 12-11-feat_oxfmt_support_--init branch from 2ef7cc9 to 369ea8c Compare December 11, 2025 01:39
Copy link
Copy Markdown
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 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 --init CLI flag to create .oxfmtrc.jsonc with default configuration
  • Refactors print_and_flush utility function to core/utils.rs for code reuse
  • Introduces new CliRunResult variants (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.

@leaysgur leaysgur force-pushed the 12-11-feat_oxfmt_support_--init branch from 369ea8c to c013d61 Compare December 11, 2025 01:45
@leaysgur leaysgur requested a review from Dunqing December 11, 2025 01:48
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Dec 11, 2025
Copy link
Copy Markdown
Member

Boshen commented Dec 11, 2025

Merge activity

Follow up #16703, fixes #16622

I will add test for `--init` and also `--lsp` later.
@graphite-app graphite-app bot force-pushed the 12-11-feat_oxfmt_support_--init branch from c013d61 to 559eff1 Compare December 11, 2025 01:56
@graphite-app graphite-app bot merged commit 559eff1 into main Dec 11, 2025
18 checks passed
@graphite-app graphite-app bot deleted the 12-11-feat_oxfmt_support_--init branch December 11, 2025 02:03
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 11, 2025
@leaysgur leaysgur mentioned this pull request Dec 11, 2025
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.

oxfmt: oxfmt --init

4 participants