Files
test-repo/changelog_unreleased/javascript/12017.md
T
Sosuke Suzuki a50bc4e14a Preserve end-of-line comment for if statement without blocks (#12017)
* Print as dangling comments

* Add tests

* Add changelog

* Use symbol instead of string
2022-01-06 09:31:58 +09:00

538 B

Preserve end-of-line comment for if statements without blocks (#12017 by @sosukesuzuki)

// 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