Improve comment handling between if statement condition and the "body" (#17998)

This commit is contained in:
fisker Cheung authored and GitHub committed 2025-10-11 16:13:44 +08:00
1 parent ec2efea041
commit 3a3db39b32
6 files changed
+228 -59

No files matched your search

+31
View File
@@ -0,0 +1,31 @@
#### Improve comment handing inside if statement (#17998 by @fisker)
<!-- prettier-ignore -->
```jsx
// Input
if (foo) // comment
{
doThing();
} else // comment for else
{
doSomethingElse();
}
// Prettier stable
if (foo) {
// comment
doThing();
} // comment for else
else {
doSomethingElse();
}
// Prettier main
if (foo) // comment
{
doThing();
} else // comment for else
{
doSomethingElse();
}
```