Repository navigation
fix: keep an arrow function's call or template literal body on the same line as the arrow when it hugs its last argument or is on multiple lines - #861
Merged
Conversation
…me line as the arrow when it hugs its last argument or is on multiple lines
This was referenced Nov 3, 2026
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.
An arrow function's expression body was always moved to the next line when it was on multiple lines, even when only a hugged last argument or a template literal made it multi-line:
newexpressions stay on the same line as the arrow when they're written that way with their last argument starting on that line and continuing on the next ones (ex.a => b({,a => foo(x, () => {, ora => new Foo([). Those last arguments keep their line breaks, so this is decided from how the code is written, like the other explicit newlines, and is stable. The body still moves to the next line when the text before the last argument doesn't fit, when it's written on one line (the next line fits it on one line when it can), or when it's already on the next line.htmlin the external formatter spec), the template is now indented from the arrow's line.This is a fix rather than an option like #528, which kept every call and tagged template on the arrow's line.
In the regression corpus from #13 (about 19,000 files with six configurations), this changes 16 files, all tagged or multi-line templates that stay with the arrow (ex.
(entry) =>\n html\`` becomes(entry) => html``). The calls don't change there because the corpus has already been formatted with them on the next line.Closes #107