Skip to content

fix(formatter): incorrect indentation of long assignment pattern in object#16709

Merged
graphite-app[bot] merged 1 commit intomainfrom
12-10-fix_formatter_incorrect_indentation_of_assignment_pattern_in_object
Dec 11, 2025
Merged

fix(formatter): incorrect indentation of long assignment pattern in object#16709
graphite-app[bot] merged 1 commit intomainfrom
12-10-fix_formatter_incorrect_indentation_of_assignment_pattern_in_object

Conversation

@Dunqing
Copy link
Copy Markdown
Member

@Dunqing Dunqing commented Dec 10, 2025

close: #16704

@github-actions github-actions bot added A-formatter Area - Formatter C-bug Category - Bug labels Dec 10, 2025
Copy link
Copy Markdown
Member Author

Dunqing commented Dec 10, 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 10, 2025

CodSpeed Performance Report

Merging #16709 will not alter performance

Comparing 12-10-fix_formatter_incorrect_indentation_of_assignment_pattern_in_object (dd0057b) with main (2a63d74)

Summary

✅ 38 untouched
⏩ 7 skipped1

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-10-fix_formatter_incorrect_indentation_of_assignment_pattern_in_object branch from 49229c7 to e4c1bda Compare December 10, 2025 15:57
@graphite-app graphite-app bot changed the base branch from 12-10-fix_formatter_should_not_insert_a_semicolon_for_method_signatures_when_no_semicolon_is_set to graphite-base/16709 December 11, 2025 00:58
@graphite-app graphite-app bot force-pushed the 12-10-fix_formatter_incorrect_indentation_of_assignment_pattern_in_object branch from e4c1bda to c71b369 Compare December 11, 2025 01:05
@graphite-app graphite-app bot force-pushed the graphite-base/16709 branch from aceb727 to 2a63d74 Compare December 11, 2025 01:05
@graphite-app graphite-app bot changed the base branch from graphite-base/16709 to main December 11, 2025 01:06
@graphite-app graphite-app bot force-pushed the 12-10-fix_formatter_incorrect_indentation_of_assignment_pattern_in_object branch from c71b369 to dd0057b Compare December 11, 2025 01:06
@Dunqing Dunqing marked this pull request as ready for review December 11, 2025 01:29
@Dunqing Dunqing requested review from Copilot and leaysgur December 11, 2025 01:29
@Dunqing Dunqing changed the title fix(formatter): incorrect indentation of assignment pattern in object fix(formatter): incorrect indentation of long assignment pattern in object Dec 11, 2025
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.

Pull request overview

This PR fixes incorrect indentation of assignment patterns in shorthand object binding properties. The issue occurred when destructuring function parameters with default values (e.g., function f({ a = defaultValue }) {}). The formatter was incorrectly treating these as having both a left-hand side (key) and right-hand side (value), when in fact the entire assignment pattern should be treated as the left-hand side only.

Key Changes:

  • Updated write_left to format the entire value (which includes the assignment pattern) instead of just the key for shorthand binding properties with assignment patterns
  • Extended has_only_left_hand_side to recognize AssignmentPattern as a "left-hand side only" case with detailed explanatory comments
  • Removed duplicate shorthand handling code that was made obsolete by the fix

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/oxc_formatter/src/utils/assignment_like.rs Fixed the logic for formatting shorthand binding properties with assignment patterns by treating AssignmentPattern values as left-hand side only, and cleaned up duplicate code
crates/oxc_formatter/tests/fixtures/js/assignments/issue-16704.js Added test case demonstrating the fix for assignment patterns in object destructuring parameters
crates/oxc_formatter/tests/fixtures/js/assignments/issue-16704.js.snap Snapshot showing expected formatting output for the test case at different print widths

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@leaysgur leaysgur added the 0-merge Merge with Graphite Merge Queue label Dec 11, 2025
Copy link
Copy Markdown
Member

leaysgur commented Dec 11, 2025

Merge activity

@graphite-app graphite-app bot force-pushed the 12-10-fix_formatter_incorrect_indentation_of_assignment_pattern_in_object branch from dd0057b to e973965 Compare December 11, 2025 01:47
@graphite-app graphite-app bot merged commit e973965 into main Dec 11, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 12-10-fix_formatter_incorrect_indentation_of_assignment_pattern_in_object branch December 11, 2025 01:53
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 11, 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.

formatter: Diff with Prettier on indentation of default option args

3 participants