oakmac / standard-clojure-style-js

Standard Clojure Style in JavaScript
ISC License
33 stars 1 forks source link

Perhaps rule 3 should ignore comments? #109

Open axelarge opened 2 weeks ago

axelarge commented 2 weeks ago

At the risk of introducing too much special casing, have you considered skipping over comments when determining if rule 3 should be applied?

Consider this code:

(or condition1
         ;; comment
    condition2
    condition3)

Because the comment is used to check if rule 3 should be triggered, it gets reformatted into:

(or condition1
  ;; comment
  condition2
  condition3)

While I understand the reasoning, personally I expected it to result in

(or condition1
    ;; comment
    condition2
    condition3)

What do you think?

oakmac commented 2 weeks ago

This is tricky. I considered "ignore comment lines when looking for Rule 3 alignment", but I decided it was best to not add a special case to how "Rule 3" works.

Your examples are interesting. I think if the author desires ;; comment to be vertically aligned, then he/she should align it against condition1. Otherwise we get the result from your second example.