Skip to content

refactor(formatter): remove the unneeded group for the return type of arrow function#16883

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-15-refactor_formatter_remove_the_unneeded_group_for_the_return_type_of_arrow_function
Dec 15, 2025
Merged

refactor(formatter): remove the unneeded group for the return type of arrow function#16883
graphite-app[bot] merged 1 commit intomainfrom
12-15-refactor_formatter_remove_the_unneeded_group_for_the_return_type_of_arrow_function

Conversation

@Dunqing
Copy link
Copy Markdown
Member

@Dunqing Dunqing commented Dec 15, 2025

Not needed, which matches Prettier's doc

Copy link
Copy Markdown
Member Author

Dunqing commented Dec 15, 2025


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.

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Dec 15, 2025

CodSpeed Performance Report

Merging #16883 will not alter performance

Comparing 12-15-refactor_formatter_remove_the_unneeded_group_for_the_return_type_of_arrow_function (095e5bc) with 12-15-refactor_formatter_remove_useless_space_ (2ccd1d4)1

Summary

✅ 38 untouched
⏩ 7 skipped2

Footnotes

  1. No successful run was found on 12-15-refactor_formatter_remove_useless_space_ (80d6d21) during the generation of this report, so b1e923a was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 7 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@Dunqing Dunqing requested a review from leaysgur December 15, 2025 08:52
@graphite-app graphite-app bot force-pushed the 12-15-refactor_formatter_remove_useless_space_ branch from 2ccd1d4 to 487711d Compare December 15, 2025 08:53
Copy link
Copy Markdown

@charliecreates charliecreates bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 in group(...), which can affect line-breaking decisions and how return types participate in parent grouping. Even if it was "unneeded" in many cases, dropping the group may 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) keep group via map(|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 in format_signature.
  • Replaced a custom format_with block that conditionally formats arrow.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)

@charliecreates charliecreates bot removed the request for review from CharlieHelps December 15, 2025 08:54
@graphite-app graphite-app bot force-pushed the 12-15-refactor_formatter_remove_useless_space_ branch from 487711d to 80d6d21 Compare December 15, 2025 08:54
@graphite-app graphite-app bot force-pushed the 12-15-refactor_formatter_remove_the_unneeded_group_for_the_return_type_of_arrow_function branch from d0ab43b to 095e5bc Compare December 15, 2025 08:54
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
Copy link
Copy Markdown
Member

Boshen commented Dec 15, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 12-15-refactor_formatter_remove_useless_space_ branch from 80d6d21 to 15925fe Compare December 15, 2025 09:07
graphite-app bot pushed a commit that referenced this pull request Dec 15, 2025
… arrow function (#16883)

Not needed, which matches Prettier's doc
@graphite-app graphite-app bot force-pushed the 12-15-refactor_formatter_remove_the_unneeded_group_for_the_return_type_of_arrow_function branch from 095e5bc to 7abc92b Compare December 15, 2025 09:08
… arrow function (#16883)

Not needed, which matches Prettier's doc
@graphite-app graphite-app bot force-pushed the 12-15-refactor_formatter_remove_useless_space_ branch from 15925fe to ea0ef3b Compare December 15, 2025 09:11
@graphite-app graphite-app bot force-pushed the 12-15-refactor_formatter_remove_the_unneeded_group_for_the_return_type_of_arrow_function branch from 7abc92b to 0cd2ebd Compare December 15, 2025 09:12
Base automatically changed from 12-15-refactor_formatter_remove_useless_space_ to main December 15, 2025 09:17
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
@graphite-app graphite-app bot merged commit 0cd2ebd into main Dec 15, 2025
21 checks passed
@graphite-app graphite-app bot deleted the 12-15-refactor_formatter_remove_the_unneeded_group_for_the_return_type_of_arrow_function branch December 15, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatter Area - Formatter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants