Skip to content

fix(formatter,oxfmt): Handle nested BinaryExpression for tailwind trailing spaces#20450

Merged
graphite-app[bot] merged 1 commit intomainfrom
03-17-fix_formatter_oxfmt_handle_nested_binaryexpression_for_trailing_spaces
Mar 17, 2026
Merged

fix(formatter,oxfmt): Handle nested BinaryExpression for tailwind trailing spaces#20450
graphite-app[bot] merged 1 commit intomainfrom
03-17-fix_formatter_oxfmt_handle_nested_binaryexpression_for_trailing_spaces

Conversation

@leaysgur
Copy link
Copy Markdown
Member

Fixes #20397

can_collapse_whitespace() walks the ancestor chain looking for BinaryExpression(+) to determine if boundary whitespace must be preserved.

The loop broke on the first non-BinaryExpression ancestor, so a ConditionalExpression (ternary) between the string and the outer + caused an immediate break. So, the BinaryExpression was never seen.

Prettier's canCollapseWhitespaceIn() iterates the entire ancestor path without breaking, reacting only to BinaryExpression(+) and TemplateLiteral nodes via if checks.

@leaysgur leaysgur requested a review from Dunqing as a code owner March 17, 2026 05:18
@github-actions github-actions bot added A-cli Area - CLI A-formatter Area - Formatter C-bug Category - Bug labels Mar 17, 2026
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 changes, fast-track this PR to the front of 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.

@leaysgur leaysgur changed the title fix(formatter,oxfmt): Handle nested BinaryExpression for trailing spaces fix(formatter,oxfmt): Handle nested BinaryExpression for tailwind trailing spaces Mar 17, 2026
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 17, 2026

Merging this PR will not alter performance

✅ 49 untouched benchmarks
⏩ 7 skipped benchmarks1


Comparing 03-17-fix_formatter_oxfmt_handle_nested_binaryexpression_for_trailing_spaces (b655cfc) with main (71628e6)2

Open in CodSpeed

Footnotes

  1. 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.

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

@Dunqing Dunqing added the 0-merge Merge with Graphite Merge Queue label Mar 17, 2026
Copy link
Copy Markdown
Member

Dunqing commented Mar 17, 2026

Merge activity

…railing spaces (#20450)

Fixes #20397

`can_collapse_whitespace()` walks the ancestor chain looking for `BinaryExpression(+)` to determine if boundary whitespace must be preserved.

The loop broke on the first non-`BinaryExpression` ancestor, so a `ConditionalExpression` (ternary) between the string and the outer `+` caused an immediate break. So, the `BinaryExpression` was never seen.

Prettier's `canCollapseWhitespaceIn()` iterates the entire ancestor path without breaking, reacting only to `BinaryExpression(+)` and `TemplateLiteral` nodes via if checks.
@graphite-app graphite-app bot force-pushed the 03-17-fix_formatter_oxfmt_handle_nested_binaryexpression_for_trailing_spaces branch from b655cfc to 7c233f4 Compare March 17, 2026 15:06
@graphite-app graphite-app bot merged commit 7c233f4 into main Mar 17, 2026
21 checks passed
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 17, 2026
@graphite-app graphite-app bot deleted the 03-17-fix_formatter_oxfmt_handle_nested_binaryexpression_for_trailing_spaces branch March 17, 2026 15:19
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-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

formatter: Diff with Prettier on sortTailwindcss, string concatenation with ternary operators

2 participants