refactor(formatter): remove the unneeded group for the return type of arrow function#16883
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 #16883 will not alter performanceComparing Summary
Footnotes
|
2ccd1d4 to
487711d
Compare
There was a problem hiding this comment.
Dropping group(...) around the arrow return type may change line-breaking behavior for complex/long return types, potentially causing formatting regressions. Either preserve grouping in the new concise expression or add targeted snapshot tests to ensure the new behavior is intended and stable.
Additional notes (1)
- Maintainability |
crates/oxc_formatter/src/write/arrow_function_expression.rs:697-703
This refactor changes behavior subtly: previously the return type was wrapped ingroup(...), which can affect line-breaking decisions and how return types participate in parent grouping. Even if it was "unneeded" in many cases, dropping thegroupmay regress formatting for long or complex return types (e.g. multi-line conditional/intersection types) by allowing different breaks than before. It would be safer to either (a) keepgroupviamap(|rt| group(&FormatNodeWithoutTrailingComments(rt)))or (b) add/adjust snapshot tests that cover long return types on arrows (including chained arrows and grouped call arguments) to prove no regression.
Summary of changes
Summary
- Simplified arrow function signature formatting by removing an extra
group(...)wrapper around the return type formatting informat_signature. - Replaced a custom
format_withblock that conditionally formatsarrow.return_type()with a more direct mapping:arrow.return_type().map(FormatNodeWithoutTrailingComments).
Affected file
crates/oxc_formatter/src/write/arrow_function_expression.rs(format_signature)
487711d to
80d6d21
Compare
d0ab43b to
095e5bc
Compare
Merge activity
|
80d6d21 to
15925fe
Compare
… arrow function (#16883) Not needed, which matches Prettier's doc
095e5bc to
7abc92b
Compare
… arrow function (#16883) Not needed, which matches Prettier's doc
15925fe to
ea0ef3b
Compare
7abc92b to
0cd2ebd
Compare

Not needed, which matches Prettier's doc