You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
if(one){console.log("one");}else/* if (two) */{console.log("another");}
Output:
if(one){console.log("one");}/* if (two) */else{console.log("another");}
Expected behavior:
if(one){console.log("one");}else/* if (two) */{console.log("another");}
I realize that this is a difficult problem to solve and I've seen that you already have quite a number of issues about comments and their positioning, but I didn't see this specific example shown. If it's a duplicate, feel free to close.
Basically I want to be able to temporarily transform else if into an else. But prettier is doing something unexpected, it rearranges the position of the comment, which makes it difficult to return back to else if later on.
The text was updated successfully, but these errors were encountered:
I often find it easier to duplicate the line when doing such debugging experiments:
if(one){console.log("one");// } else if (two) {}else{console.log("another");}
For me, duplicating lines and commenting out lines are quick editor shortcuts. And I find it easier to edit/delete stuff than adding /* and */. As a bonus, I still have the original line around for reference.
Prettier tends to handle lines consisting of only a // comment better than inline /**/ comments.
Not saying that things can't be improved in Prettier's comment handling (but keep in mind that comment handling is super hard), just sharing another approach.
Prettier 1.14.2
Playground link
Input:
Output:
Expected behavior:
I realize that this is a difficult problem to solve and I've seen that you already have quite a number of issues about comments and their positioning, but I didn't see this specific example shown. If it's a duplicate, feel free to close.
Basically I want to be able to temporarily transform
else if
into anelse
. But prettier is doing something unexpected, it rearranges the position of the comment, which makes it difficult to return back toelse if
later on.The text was updated successfully, but these errors were encountered: