Open the-argus opened 2 years ago
Yes, please! There are widely used formatters for other languages that do this, too. Here are two of the top of my head:
Prettier gets rid of all original styling and guarantees consistency by parsing JavaScript into an AST and pretty-printing the AST.
Black reformats entire files in place. Style configuration options are deliberately limited and rarely added. It doesn't take previous formatting into account [...].
I think this would be a great addition to alejandra.
I love alejandra, but my ideal formatter is completely uncompromising. That means that whitespace, including newlines, should not be interpreted by the formatter at all. There should be an algorithmically correct way of formatting a given nix set. For example, the following code is formatted by alejandra:
However, if I add a newline, like so:
And then format...
I would prefer if there was a single interpretation of this code that alejandra subscribed to. I propose a
--strict
flag that chooses one of these. Frankly, I don't care much about which version--strict
chooses, I just would like it to choose one. I don't want to be able to even think about formatting, I don't want there to be any choice that I can make that would change the format of my code.Is this a welcome feature? If not, is there another formatter that does what I want?