Skip to content

refactor(formatter): remove unnecessary space calls in assignment-like#16876

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

refactor(formatter): remove unnecessary space calls in assignment-like#16876
graphite-app[bot] merged 1 commit intomainfrom
12-15-refactor_formatter_remove_useless_space_

Conversation

@Dunqing
Copy link
Copy Markdown
Member

@Dunqing Dunqing commented Dec 15, 2025

Remove unnecessary space elements to align with 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 #16876 will improve performances by 8.63%

Comparing 12-15-refactor_formatter_remove_useless_space_ (80d6d21) with main (a0efc41)

Summary

⚡ 1 improvement
✅ 37 untouched
⏩ 7 skipped1

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
Simulation formatter[core.js] 2.2 ms 2 ms +8.63%

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.

@Dunqing Dunqing force-pushed the 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument branch from ff5e316 to 8d1af8c Compare December 15, 2025 08:28
@Dunqing Dunqing force-pushed the 12-15-refactor_formatter_remove_useless_space_ branch from 2961ddb to 091e4ab Compare December 15, 2025 08:28
@Dunqing Dunqing force-pushed the 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument branch from 8d1af8c to 7ca6162 Compare December 15, 2025 08:37
@Dunqing Dunqing force-pushed the 12-15-refactor_formatter_remove_useless_space_ branch from 091e4ab to 2ccd1d4 Compare December 15, 2025 08:37
@Dunqing Dunqing changed the title refactor(formatter): remove unnecessary space calls in assignment-like" refactor(formatter): remove unnecessary space calls in assignment-like Dec 15, 2025
@Dunqing Dunqing marked this pull request as ready for review December 15, 2025 08:38
@graphite-app graphite-app bot changed the base branch from 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument to graphite-base/16876 December 15, 2025 08:44
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.

This diff removes explicit separators (space()) in places where they may be the only thing preventing token concatenation (e.g., a =1, a:1). Unless with_assignment_layout(...) (and the value/type printers) guarantee leading whitespace in all relevant layouts, the change risks output divergence and unreadable formatting. The operator/RHS separation responsibility should be centralized to either write_operator or write_right, and : spacing likely needs to be layout-aware to match Prettier reliably.

Summary of changes

What changed

  • Removed explicit space() doc pieces around assignment-like right-hand sides in write_right.
    • VariableDeclarator, AssignmentExpression, PropertyDefinition, and the non-union branch of TSTypeAliasDeclaration now emit only with_assignment_layout(...) / type_annotation().
  • Removed explicit space() after : for non-shorthand object/binding properties in write_operator.
    • ObjectProperty and BindingProperty now emit just ":".

Affected area

  • crates/oxc_formatter/src/utils/assignment_like.rs within impl<'a> AssignmentLike<'a, '_> methods write_operator and write_right.

@Dunqing
Copy link
Copy Markdown
Member Author

Dunqing commented Dec 15, 2025

CodSpeed Performance Report

Merging #16876 will improve performances by 8.87%

Comparing 12-15-refactor_formatter_remove_useless_space_ (2ccd1d4) with 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument (8d1af8c)1

Summary

⚡ 1 improvement ✅ 37 untouched ⏩ 7 skipped2

Benchmarks breakdown

Mode Benchmark BASE HEAD Change
⚡ Simulation formatter[core.js] 2.2 ms 2 ms +8.87%

Footnotes

  1. No successful run was found on 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument (7ca6162) during the generation of this report, so e3766e6 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.

Wow

@graphite-app graphite-app bot force-pushed the graphite-base/16876 branch from 7ca6162 to a0efc41 Compare December 15, 2025 08:53
@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
@graphite-app graphite-app bot changed the base branch from graphite-base/16876 to main 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 added the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
graphite-app bot pushed a commit that referenced this pull request Dec 15, 2025
#16876)

Remove unnecessary space elements to align with Prettier's doc
@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
Copilot AI review requested due to automatic review settings December 15, 2025 09:07
Copy link
Copy Markdown
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.

#16876)

Remove unnecessary space elements to align with 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
Copy link
Copy Markdown
Contributor

graphite-app bot commented Dec 15, 2025

Merge activity

@graphite-app graphite-app bot merged commit ea0ef3b into main Dec 15, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 12-15-refactor_formatter_remove_useless_space_ branch December 15, 2025 09:17
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 15, 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-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.

2 participants