-
-
Notifications
You must be signed in to change notification settings - Fork 721
feat(oxfmt): Support .oxfmtrc.json(c) config file
#14398
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
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. |
CodSpeed Performance ReportMerging #14398 will not alter performanceComparing Summary
|
05d91d9 to
64307ac
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 adds support for .oxfmtrc.json(c) configuration files to the oxfmt formatter tool. The implementation includes automatic discovery of config files from the current working directory upwards, support for JSONC format with comments, and the ability to specify a custom config path via the -c/--config flag.
Key changes:
- Creates a new
Oxfmtrcstruct to handle JSON-based configuration parsing and validation - Implements automatic config file discovery starting from the current directory and searching upwards
- Adds CLI support for specifying custom config file paths
Reviewed Changes
Copilot reviewed 17 out of 18 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/oxc_formatter/src/service/oxfmtrc.rs | New module implementing JSON config file parsing with support for all formatting options |
| crates/oxc_formatter/src/service/mod.rs | Exports the new oxfmtrc module |
| crates/oxc_formatter/src/lib.rs | Re-exports the Oxfmtrc struct for external use |
| crates/oxc_formatter/Cargo.toml | Adds dependencies for JSON parsing and comment stripping |
| apps/oxfmt/src/format.rs | Implements config file discovery logic and integrates config loading into the formatting pipeline |
| apps/oxfmt/src/command.rs | Adds BasicOptions struct with config file path argument |
| apps/oxfmt/src/service.rs | Updates FormatService to accept and use FormatOptions from config |
| apps/oxfmt/tests/mod.rs | Adds comprehensive tests for config file auto-discovery and explicit specification |
| Test fixtures | Various JSON/JSONC config files and test data for validation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
@Sysix If you have time, please check that everything needed for LS is ready. 🙏🏻 |
64307ac to
c633e40
Compare
.oxfmt.json(c) config file
.oxfmt.json(c) config file.oxfmtrc.json(c) config file
c633e40 to
2c70171
Compare
Sysix
left a comment
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.
looks good for the server 👍 thank you
d7b2775 to
86c4e1d
Compare
Dunqing
left a comment
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.
Looks good! There is a tiny thing that can be simplified a little.
86c4e1d to
f0c19eb
Compare
Merge activity
|
Fixes #13611 - Support config file with JSON(C) format - Automatically find the nearest one from `cwd` - Do not merge, just use the first one - Search only `.oxfmtrc.json`(not `.jsonc`) - Use `-c` or `--config` to specify path Example `.oxfmtrc.json`: ```jsonc { "indentStyle": "space", "indentWidth": 2, "lineWidth": 80, "lineEnding": "lf", "quoteStyle": "single", "jsxQuoteStyle": "double", "quoteProperties": "as-needed", "trailingCommas": "all", "semicolons": "always", "arrowParentheses": "always", "bracketSpacing": true, "bracketSameLine": false, "attributePosition": "auto", "expand": "auto", "experimentalOperatorPosition": "before", "experimentalSortImports": { "partitionByNewline": false, "partitionByComment": false, "sortSideEffects": false, "order": "asc", "ignoreCase": true } } ``` We may provide tools like `oxfmt-migrate` to convert `.prettierrc`.
f0c19eb to
51ddfa8
Compare
## [0.5.0] - 2025-10-14 ### 🚀 Features - 8077f9b oxfmt: Provide JSON schema for `.oxfmtrc.json` (#14399) (leaysgur) - 51ddfa8 oxfmt: Support `.oxfmtrc.json(c)` config file (#14398) (leaysgur) ### 🐛 Bug Fixes - c4e12df formatter: Correct checking comments around the return argument (#14585) (Dunqing) - 454303b formatter: Check empty lines between arguments incorrectly (#14584) (Dunqing) - a5554a8 formatter: Print a line break incorrectly for directives (#14577) (Dunqing) - 5db9774 formatter: Correct printing comments that are around the `StaticMemberExpression` (#14543) (Dunqing) - 620dbac formatter: No need to wrap a parenthesis for `TSConditionalType` and `TSFunctionType` when its parent is `TSUnionType` and it only has one element (#14540) (Dunqing) - 1aec74f formatter: Missing parenthesis for `ComputedMemberExpression` when its parent is an `NewExpression` (#14530) (Dunqing) - 59f1d8f formatter: Missing parenthesis for `PrivateInExpression` when its parent is an `UnaryExpression` (#14529) (Dunqing) - b06059e formatter: Correct printing comments for logical expression (#14500) (Dunqing) - be38095 formatter: Should break even if the right side of the assignment is a require when it has a leading own line comment (#14499) (Dunqing) - 4d55654 formatter: Correct printing comments for the end of union type (#14498) (Dunqing) - 4994872 formatter: Correct printing comments for `try` statement (#14497) (Dunqing) - 9a4da3d formatter: Should expand the parent if the member chain will break (#14487) (Dunqing) - bba9689 formatter: Correct printing comments around the expression of `ComputedMemberExpression` (#14486) (Dunqing) - dc5e08a formatter: Correct printing yield argument (#14485) (Dunqing) - b8a0905 formatter: No need to wrap with parentheses for a type cast node (#14484) (Dunqing) - b159215 formatter: Ignore the leading line break for the first argument of the call expression (#14483) (Dunqing) - ea8f9ed formatter: Correct checking comments between the operator and the right side for assignment like nodes (#14482) (Dunqing) - 4f19504 formatter: Block comments without a leading linebreak that are around the operator of the conditional expression should be printed as-is (#14474) (Dunqing) - ef77997 formatter: Correct printing comments for `for` statements (#14473) (Dunqing) - 31595c3 formatter: Correct printing comments for assignment pattern (#14469) (Dunqing) - 0f19be0 oxfmt: Normalize path delimiter on Windows (#14463) (leaysgur) - 5856bc9 oxc_formatter: Fix arrow_parentheses: 'avoid' > 'as-needed' (#14462) (leaysgur) ### 🚜 Refactor - 7bc86f4 formatter: Simplify foramtting import and export (#14576) (Dunqing) - 29c3cf2 formatter: Remove `SiblingNode` (#14551) (Dunqing) - 893bdac formatter: Improve printing comments for special nodes (#14544) (Dunqing) - 97bb964 formatter: Improve line break detaching logic in SourceText (#14539) (Dunqing) ### 🧪 Testing - bb43dc5 formatter: Add snapshot-based test infrastructure (#14400) (Dunqing) Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>

Fixes #13611
cwd.oxfmtrc.json(not.jsonc)-cor--configto specify pathExample
.oxfmtrc.json:{ "indentStyle": "space", "indentWidth": 2, "lineWidth": 80, "lineEnding": "lf", "quoteStyle": "single", "jsxQuoteStyle": "double", "quoteProperties": "as-needed", "trailingCommas": "all", "semicolons": "always", "arrowParentheses": "always", "bracketSpacing": true, "bracketSameLine": false, "attributePosition": "auto", "expand": "auto", "experimentalOperatorPosition": "before", "experimentalSortImports": { "partitionByNewline": false, "partitionByComment": false, "sortSideEffects": false, "order": "asc", "ignoreCase": true } }We may provide tools like
oxfmt-migrateto convert.prettierrc.