refactor(formatter): remove unnecessary space calls in assignment-like#16876
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 #16876 will improve performances by 8.63%Comparing Summary
Benchmarks breakdown
Footnotes
|
ff5e316 to
8d1af8c
Compare
2961ddb to
091e4ab
Compare
8d1af8c to
7ca6162
Compare
091e4ab to
2ccd1d4
Compare
There was a problem hiding this comment.
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 inwrite_right.VariableDeclarator,AssignmentExpression,PropertyDefinition, and the non-union branch ofTSTypeAliasDeclarationnow emit onlywith_assignment_layout(...)/type_annotation().
- Removed explicit
space()after:for non-shorthand object/binding properties inwrite_operator.ObjectPropertyandBindingPropertynow emit just":".
Affected area
crates/oxc_formatter/src/utils/assignment_like.rswithinimpl<'a> AssignmentLike<'a, '_>methodswrite_operatorandwrite_right.
Wow |
7ca6162 to
a0efc41
Compare
2ccd1d4 to
487711d
Compare
487711d to
80d6d21
Compare
#16876) Remove unnecessary space elements to align with Prettier's doc
80d6d21 to
15925fe
Compare
#16876) Remove unnecessary space elements to align with Prettier's doc
15925fe to
ea0ef3b
Compare
Merge activity
|

Remove unnecessary space elements to align with Prettier's doc