Prettier 3.8.1
Playground link
Input:
All are prettier tests at
|
!(x || y); |
|
!(/* foo */ x || y); |
|
!(x || y /* foo */); |
!(x || y);
!(/* foo */ x || y);
!(x || y /* foo */);
Output:
!(x || y);
!(/* foo */ (x || y));
!((x || y) /* foo */);
Expected output:
!(x || y);
!(/* foo */ x || y);
!(x || y /* foo */);
Note: Same as input
Why?
The added parentheses are unnecessary - !(x || y) already groups the expression clearly.
Also, this is inconsistent: multi-line chains with comments don't get extra parentheses:
!(
x || // foo
y // bar
);
<!-- short explanation of expected output -->
Prettier 3.8.1
Playground link
Input:
All are prettier tests at
prettier/tests/format/js/unary-expression/comments.js
Lines 31 to 33 in 812a4d0
Output:
Expected output:
Note: Same as input
Why?
The added parentheses are unnecessary -
!(x || y)already groups the expression clearly.Also, this is inconsistent: multi-line chains with comments don't get extra parentheses: