fix(formatter): incorrect formatting for member chain call with an empty arguments call argument#16875
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 #16875 will not alter performanceComparing Summary
Footnotes
|
fd3a045 to
5ff1074
Compare
ff5e316 to
8d1af8c
Compare
Merge activity
|
There was a problem hiding this comment.
- The new
Expression::CallExpressionshort-argument heuristic is quite narrow (identifier-only) and may not cover other common empty-call shapes; consider expanding it while preserving thethreshold-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_argumentincrates/oxc_formatter/src/utils/assignment_like.rsto treat certain empty-argument call expressions as “short”:- Adds a new match arm for
Expression::CallExpression(call). - Returns
truewhencall.arguments.is_empty()and the callee is anIdentifierwhose name length fits withinthreshold(accounting for()viasaturating_sub(2)).
- Adds a new match arm for
- 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 differentprintWidthsettings.
Files touched:
crates/oxc_formatter/src/utils/assignment_like.rscrates/oxc_formatter/tests/fixtures/js/assignments/issue-16707.jscrates/oxc_formatter/tests/fixtures/js/assignments/issue-16707.js.snap
8d1af8c to
7ca6162
Compare
7ca6162 to
9aa8542
Compare
9aa8542 to
7ca6162
Compare
7ca6162 to
a0efc41
Compare
There was a problem hiding this comment.
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
CallExpressionhandling tois_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.

close: #16707