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:
1 parent
7c16d226f1
commit
a50bc4e14a
6 files changed
+132
-2
No files matched your search
@@ -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
|
||||
|
||||
```
|
||||
Reference in new issue
Block a user