Skip to content

fix(formatter): merge the right side of LogicalExpression if it's a LogicalExpression and both have the same operator#14097

Merged
graphite-app[bot] merged 1 commit intomainfrom
09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator
Sep 29, 2025
Merged

fix(formatter): merge the right side of LogicalExpression if it's a LogicalExpression and both have the same operator#14097
graphite-app[bot] merged 1 commit intomainfrom
09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator

Conversation

@Dunqing
Copy link
Member

@Dunqing Dunqing commented Sep 25, 2025

I wrote the implementation, and it isn't a port from anywhere. This is to align with Prettier's unbalancing LogicalExpression behavior.

We can't use the same approach that Prettier does because our AST isn't mutable, so we have to do the same thing in the formatting phase, which makes the code a little hard to understand. However, our own is more performant.

Copy link
Member Author

Dunqing commented Sep 25, 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.

@Dunqing Dunqing changed the title fix(formatter): merge the right side of LogicalExpression if it's a LogicalExpression and both have the same operator fix(formatter): merge the right side of LogicalExpression if it's a LogicalExpression and both have the same operator Sep 25, 2025
@codspeed-hq
Copy link

codspeed-hq bot commented Sep 25, 2025

CodSpeed Instrumentation Performance Report

Merging #14097 will not alter performance

Comparing 09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator (ed33fad) with main (cb29117)1

Summary

✅ 33 untouched
⏩ 4 skipped2

Footnotes

  1. No successful run was found on main (2b2c345) during the generation of this report, so cb29117 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

  2. 4 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 force-pushed the 09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator branch 2 times, most recently from 305f21b to 20ecffb Compare September 25, 2025 07:33
@Dunqing Dunqing force-pushed the 09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator branch from 20ecffb to a044f67 Compare September 25, 2025 07:52
@Dunqing Dunqing marked this pull request as ready for review September 26, 2025 12:03
@Dunqing Dunqing changed the base branch from 09-24-feat_formatter_correct_printing_parameters_with_return_type_for_function-like_node to graphite-base/14097 September 26, 2025 16:42
@Dunqing Dunqing force-pushed the graphite-base/14097 branch from 4e5d480 to 763ef82 Compare September 26, 2025 16:42
@Dunqing Dunqing force-pushed the 09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator branch from a044f67 to 7cad4d7 Compare September 26, 2025 16:42
@Dunqing Dunqing changed the base branch from graphite-base/14097 to 09-24-feat_formatter_correct_printing_parameters_with_return_type_for_function-like_node September 26, 2025 16:42
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Sep 29, 2025
@graphite-app
Copy link
Contributor

graphite-app bot commented Sep 29, 2025

Merge activity

@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 29, 2025
@graphite-app graphite-app bot force-pushed the 09-24-feat_formatter_correct_printing_parameters_with_return_type_for_function-like_node branch from 763ef82 to ce44f65 Compare September 29, 2025 12:59
@graphite-app graphite-app bot force-pushed the 09-24-feat_formatter_correct_printing_parameters_with_return_type_for_function-like_node branch from ce44f65 to c75e179 Compare September 29, 2025 13:00
@graphite-app graphite-app bot force-pushed the 09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator branch from 7cad4d7 to acc4f32 Compare September 29, 2025 13:00
@graphite-app graphite-app bot changed the base branch from 09-24-feat_formatter_correct_printing_parameters_with_return_type_for_function-like_node to graphite-base/14097 September 29, 2025 13:17
@graphite-app graphite-app bot force-pushed the graphite-base/14097 branch from c75e179 to cb29117 Compare September 29, 2025 13:23
@graphite-app graphite-app bot force-pushed the 09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator branch from acc4f32 to 6792579 Compare September 29, 2025 13:23
@graphite-app graphite-app bot changed the base branch from graphite-base/14097 to main September 29, 2025 13:24
@graphite-app graphite-app bot force-pushed the 09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator branch from 6792579 to 9976dde Compare September 29, 2025 13:24
@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Sep 29, 2025
… `LogicalExpression` and both have the same `operator` (#14097)

I wrote the implementation, and it isn't a port from anywhere. This is to align with [Prettier's unbalancing LogicalExpression](https://github.com/prettier/prettier/blob/7584432401a47a26943dd7a9ca9a8e032ead7285/src/language-js/parse/postprocess/index.js#L64-L69) behavior.

We can't use the same approach that Prettier does because our AST isn't mutable, so we have to do the same thing in the formatting phase, which makes the code a little hard to understand. However, our own is more performant.
Copilot AI review requested due to automatic review settings September 29, 2025 13:37
@graphite-app graphite-app bot force-pushed the 09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator branch from 9976dde to ed33fad Compare September 29, 2025 13:37
Copy link
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@graphite-app graphite-app bot merged commit ed33fad into main Sep 29, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 09-25-fix_formatter_merge_the_right_side_of_logicalexpression_if_it_s_a_logicalexpression_and_both_have_the_same_operator branch September 29, 2025 13:43
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Sep 29, 2025
@Boshen Boshen mentioned this pull request Oct 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-formatter Area - Formatter C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants