Repository navigation
Fix unstable trailing comment on a parenthesized arrow chain - #19930
Merged
Merged
Conversation
`x = (a) => ((b) => {} /* comment */)` printed the comment before the
semicolon on the first pass and after it on the second, so the file never
settled.
The parentheses are redundant, so they are dropped. That moves the comment
next to the statement's semicolon, where the next format attaches it to the
ExpressionStatement instead of to the arrow it was written against. The same
thing happens with a nested assignment, which is already handled by attaching
the comment to the statement up front; this extends that to a chain that
passes through arrow bodies.
✅ Deploy Preview for prettier ready!Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
commit: |
✅ Deploy Preview for prettier ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
fisker
reviewed
Aug 29, 2026
Comment on lines
1258
to
1260
| // `a = (b = c /* comment */);` drops the parentheses, so the comment ends | ||
| // up trailing the whole statement anyway. Attach it there right away | ||
| // instead of leaving it on `c` for the next format to move. |
Member
There was a problem hiding this comment.
reviewed everything before submitting.
Did you actually review the changes? The comment is obviously not in the right place.
Contributor
Author
|
You're right, I missed it. That comment explains the assignment case and I left it sitting above the arrow check. It's now above the |
fisker
approved these changes
Aug 30, 2026
4 of 6 tasks
kkennethlau12393
pushed a commit
to kkennethlau12393/prettier__prettier
that referenced
this pull request
Aug 31, 2026
…rettier#19930)" This reverts commit 5a0fdd9.
kkennethlau12393
pushed a commit
to kkennethlau12393/prettier__prettier
that referenced
this pull request
Sep 1, 2026
…rettier#19930)" This reverts commit 5a0fdd9.
kkennethlau12393
pushed a commit
to kkennethlau12393/prettier__prettier
that referenced
this pull request
Sep 2, 2026
…rettier#19930)" This reverts commit 5a0fdd9.
kkennethlau12393
pushed a commit
to kkennethlau12393/prettier__prettier
that referenced
this pull request
Sep 3, 2026
…rettier#19930)" This reverts commit 5a0fdd9.
kkennethlau12393
pushed a commit
to kkennethlau12393/prettier__prettier
that referenced
this pull request
Sep 3, 2026
…rettier#19930)" This reverts commit 5a0fdd9.
kkennethlau12393
pushed a commit
to kkennethlau12393/prettier__prettier
that referenced
this pull request
Sep 5, 2026
…rettier#19930)" This reverts commit 5a0fdd9.
3 of 6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
js/arrows/arrow-chain-with-trailing-comments.jsis listed infailed-format-tests.jsas unstable. This fixes it and removes the entry.The parentheses around the inner arrow are redundant, so they are dropped. That leaves the comment sitting between
}and the statement's semicolon, and the next format attaches it to theExpressionStatementrather than to the arrow it was written against, so it prints on the other side of the semicolon.handleParenthesizedExpressionTrailingCommentalready handles the same situation for a nested assignment (a = (b = c /* comment */)) by attaching the comment to the statement immediately instead of leaving it for the next format to move. This extends that to a chain that passes through arrow bodies, so the first format produces what the second one would.Checklist
docs/directory).changelog_unreleased/*/XXXX.mdfile followingchangelog_unreleased/TEMPLATE.md.No new test is added because the fixture already exists; it was listed as unstable rather than passing, and that entry is now removed. Verified with the full
tests/format/js,typescript,jsxandflowsuites: the set of failing tests is identical tomainon my machine, with the arrows snapshot updated to the second-pass output. I used AI assistance and reviewed everything before submitting.