Skip to content

fix(formatter): incorrect formatting for member chain call with an empty arguments call argument#16875

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

fix(formatter): incorrect formatting for member chain call with an empty arguments call argument#16875
graphite-app[bot] merged 1 commit intomainfrom
12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument

Conversation

@Dunqing
Copy link
Copy Markdown
Member

@Dunqing Dunqing commented Dec 15, 2025

close: #16707

@github-actions github-actions bot added A-formatter Area - Formatter C-bug Category - Bug labels Dec 15, 2025
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 #16875 will not alter performance

Comparing 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument (8d1af8c) with 12-15-refactor_formatter_improve_and_simplify_the_handling_of_assignmentlikelayout_breakafteroperator (fd3a045)1

Summary

✅ 38 untouched
⏩ 7 skipped2

Footnotes

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

@Dunqing Dunqing force-pushed the 12-15-refactor_formatter_improve_and_simplify_the_handling_of_assignmentlikelayout_breakafteroperator branch from fd3a045 to 5ff1074 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 ff5e316 to 8d1af8c Compare December 15, 2025 08:28
@Dunqing Dunqing marked this pull request as ready for review December 15, 2025 08:29
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Dec 15, 2025
Copy link
Copy Markdown
Member

Boshen commented Dec 15, 2025

Merge activity

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.

  • The new Expression::CallExpression short-argument heuristic is quite narrow (identifier-only) and may not cover other common empty-call shapes; consider expanding it while preserving the threshold-based bound.
  • The new fixture appears to include a top-level assignment that is not reflected in the snapshot output, reducing test coverage and potentially making the regression test incomplete.
Summary of changes

What changed

  • Updated is_short_argument in crates/oxc_formatter/src/utils/assignment_like.rs to treat certain empty-argument call expressions as “short”:
    • Adds a new match arm for Expression::CallExpression(call).
    • Returns true when call.arguments.is_empty() and the callee is an Identifier whose name length fits within threshold (accounting for () via saturating_sub(2)).
  • Added a regression fixture and snapshot for issue #16707 under crates/oxc_formatter/tests/fixtures/js/assignments/ to validate formatting of member-chain calls like .pipe(filterNullable()) under different printWidth settings.

Files touched:

  • crates/oxc_formatter/src/utils/assignment_like.rs
  • crates/oxc_formatter/tests/fixtures/js/assignments/issue-16707.js
  • crates/oxc_formatter/tests/fixtures/js/assignments/issue-16707.js.snap

@charliecreates charliecreates bot removed the request for review from CharlieHelps December 15, 2025 08:32
@graphite-app graphite-app bot changed the base branch from 12-15-refactor_formatter_improve_and_simplify_the_handling_of_assignmentlikelayout_breakafteroperator to graphite-base/16875 December 15, 2025 08:35
@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 changed the base branch from graphite-base/16875 to 12-15-refactor_formatter_improve_and_simplify_the_handling_of_assignmentlikelayout_breakafteroperator December 15, 2025 08:37
@graphite-app graphite-app bot changed the base branch from 12-15-refactor_formatter_improve_and_simplify_the_handling_of_assignmentlikelayout_breakafteroperator to graphite-base/16875 December 15, 2025 08:37
@graphite-app graphite-app bot changed the base branch from graphite-base/16875 to main December 15, 2025 08:43
graphite-app bot pushed a commit that referenced this pull request Dec 15, 2025
@graphite-app graphite-app bot force-pushed the 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument branch from 7ca6162 to 9aa8542 Compare December 15, 2025 08:44
Copilot AI review requested due to automatic review settings December 15, 2025 08:47
@Dunqing Dunqing force-pushed the 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument branch from 9aa8542 to 7ca6162 Compare December 15, 2025 08:47
@graphite-app graphite-app bot force-pushed the 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument branch from 7ca6162 to a0efc41 Compare December 15, 2025 08:48
@graphite-app graphite-app bot merged commit a0efc41 into main Dec 15, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 12-15-fix_formatter_incorrect_formatting_for_member_chain_call_with_an_empty_arguments_call_argument branch December 15, 2025 08:53
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Dec 15, 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 formatting for member chain calls containing a call expression with empty arguments. Previously, the formatter would break such chains inappropriately. The fix adds logic to treat call expressions with no arguments and short identifier callees (like filterNullable()) as "short arguments", making chains containing them less breakable.

Key Changes

  • Added CallExpression handling to is_short_argument() to recognize empty-argument calls with short identifier callees as short arguments
  • Updated documentation to use proper Rust doc link syntax and reference the latest Prettier implementation
  • Added test case demonstrating the fix for both class property and variable declaration contexts

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 Adds CallExpression case to is_short_argument() to handle empty-argument calls with identifier callees; updates documentation with Rust doc links and newer Prettier reference
crates/oxc_formatter/tests/fixtures/js/assignments/issue-16707.js Test input demonstrating the formatting issue with .pipe(filterNullable()) chains in both class and const contexts
crates/oxc_formatter/tests/fixtures/js/assignments/issue-16707.js.snap Expected output snapshot showing correct formatting at printWidth 80 (breaks after assignment) and 100 (no break)

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

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 observable line breaks

3 participants