Prettier 3.8.1
Playground link
Input:
|
function memberInAndOutWithCalls() { |
|
return ( |
|
// Reason for a |
|
aFunction.b() |
|
).c.d() |
|
} |
function memberInAndOutWithCalls() {
return (
// Reason for a
aFunction.b()
).c.d()
}
Output:
function memberInAndOutWithCalls() {
return (
aFunction
.b// Reason for a
()
.c.d()
);
}
Expected output:
function memberInAndOutWithCalls() {
return (
// Reason for a
aFunction.b()
).c.d();
}
Why?
The comment // Reason for a was a leading comment inside parentheses, intended to explain the entire expression being returned. The output moves it to between .b and (), which loses the original intent of explaining "reason for a" (the whole expression)
Prettier 3.8.1
Playground link
Input:
prettier/tests/format/js/comments/return-statement.js
Lines 82 to 87 in 812a4d0
Output:
Expected output:
Why?
The comment
// Reason for awas a leading comment inside parentheses, intended to explain the entire expression being returned. The output moves it to between.band(), which loses the original intent of explaining "reason for a" (the whole expression)