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 (first == null) returnsecond;
elseif (second == null) returnfirst;
Output:
if (first == null) returnsecond; elseif (second == null) returnfirst;
Expected behavior:
no error, results should be consistent, however I'm not certain if prettier is creating the wrong output or if checkstyle is configured wrong. I'm kind of wondering if prettier can/should be adding the braces here in the first place.
The text was updated successfully, but these errors were encountered:
Prettier JavaScript seems to leave the input as it is in this case (i.e. it wants a newline separating the if and else if, and doesn't automatically add braces.) We do have #459 that considers forcing braces around conditional bodies. That change would probably require more discussion than simply adding/keeping the newline, so I would suggest that the action item for this ticket is to add/keep the newline between the if and else if to mimic Prettier JavaScript's behavior (and to avoid violating the Checkstyle config we provide.)
I would be fine with leaving the input as is. I'm not sure how I feel about this particular style of code in general but reducing it to one line seems like the wrong answer. I temporarily fixed this code by adding braces around the first one
checkstyle, I copied pasta-ed from deda6ca#diff-6c435908fe54a62733ee357cc3ef828f242045ba31fa59d6d3f763b5352d694e which is just a link to the version in master at the time of this writing
Input:
Output:
Expected behavior:
no error, results should be consistent, however I'm not certain if prettier is creating the wrong output or if checkstyle is configured wrong. I'm kind of wondering if prettier can/should be adding the braces here in the first place.
The text was updated successfully, but these errors were encountered: