test(formatter): add regression test for member chain with rest params#18835
test(formatter): add regression test for member chain with rest params#18835graphite-app[bot] merged 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds a regression test for issue #16177, which involved incorrect formatting of member chains when function expressions contained rest parameters. The fix (already implemented in commit 745bc5d) ensures that functions with rest parameters are not considered "simple", allowing member chains to stay hugged while function parameters break vertically, matching Prettier's behavior.
Changes:
- Adds test input file
issue-16177.tswith a member chain containing a function with rest parameters - Adds test snapshot
issue-16177.ts.snapverifying correct formatting at different print widths
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| crates/oxc_formatter/tests/fixtures/ts/member-chains/issue-16177.ts | Test input demonstrating member chain with function expression that has rest parameters |
| crates/oxc_formatter/tests/fixtures/ts/member-chains/issue-16177.ts.snap | Expected output snapshot showing correct formatting at printWidth 80 (chain breaks) and 100 (chain stays hugged) |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
63b48f0 to
efeeb8a
Compare
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. |
Merge activity
|
#18835) Closes #16177 ## Summary - Adds a regression test for issue #16177 ## Details The issue was that member chains would incorrectly break when a function expression had rest parameters: **Before (incorrect):** ```ts jest .spyOn(Element.prototype, "getBoundingClientRect") .mockImplementation(function (this: Element, ...args) { ``` **After (correct - matches Prettier):** ```ts jest.spyOn(Element.prototype, "getBoundingClientRect").mockImplementation(function ( this: Element, ...args ) { ``` This was fixed by #17354, which ensures the `rest` parameter is not considered "simple", allowing the member chain to stay hugged while function parameters break vertically. 🤖 Generated with [Claude Code](https://claude.ai/code)
efeeb8a to
7d35a6f
Compare

Closes #16177
Summary
Details
The issue was that member chains would incorrectly break when a function expression had rest parameters:
Before (incorrect):
After (correct - matches Prettier):
This was fixed by #17354, which ensures the
restparameter is not considered "simple", allowing the member chain to stay hugged while function parameters break vertically.🤖 Generated with Claude Code