Closed xenoterracide closed 5 months ago
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 https://github.com/jhipster/prettier-java/commit/deda6ca37214420c37b5981ca23119ef49743620#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.