freedom_formatter icon indicating copy to clipboard operation
freedom_formatter copied to clipboard

Sometimes requires running `mix format` twice

Open pguillory opened this issue 10 months ago • 2 comments

I love this library! Didn't realize how annoying the lack of trailing commas was until I installed this and got to have them again.

However one issue. I have a Git hook that verifies Elixir files are formatted correctly with mix format --check-formatted. Sometimes I run git commit and it fails, so I mix format && git add -p and try again, working as intended. However, since installing freedom_formatter, I noticed sometimes I have to do that twice. Here is a repro:

list = [:long_word, :long_word, :long_word, :long_word, :long_word, :long_word, :long_word, :long_word]
mix format
list = [
  :long_word,
  :long_word,
  :long_word,
  :long_word,
  :long_word,
  :long_word,
  :long_word,
  :long_word    # note no trailing comma
]
mix format
list = [
  :long_word,
  :long_word,
  :long_word,
  :long_word,
  :long_word,
  :long_word,
  :long_word,
  :long_word,   # now the trailing comma is there
]

It's not a huge deal, I guess I'll make an alias or something to do mix format twice, but it would be nice if you only had to run it once. Is that possible?

pguillory avatar Apr 10 '24 21:04 pguillory