Preserve end-of-line comment for if statement without blocks (#12017)

* Print as dangling comments

* Add tests

* Add changelog

* Use symbol instead of string
This commit is contained in:
Sosuke Suzuki authored and GitHub committed 2022-01-06 09:31:58 +09:00
1 parent 7c16d226f1
commit a50bc4e14a
6 files changed
+132 -2

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
#### Preserve end-of-line comment for if statements without blocks (#12017 by @sosukesuzuki)
<!-- prettier-ignore -->
```jsx
// Input
if (condition1) expression1; // comment A
else if (condition2) expression2; // comment B
else expression3; // comment C
// Prettier stable
if (condition1) expression1;
// comment A
else if (condition2) expression2;
// comment B
else expression3; // comment C
// Prettier main
if (condition1) expression1; // comment A
else if (condition2) expression2; // comment B
else expression3; // comment C
```