marcandre
Trailing commas + mix format
For people that love trailing commas, I released v2.0 of the freedom formatter. It is now a plugin for the builtin formatter (requires Elixir 1.13.2+).
Note that elixir-ls’s next release will support formatting plugins.
Thanks to José Valim for making formatter plugins possible
, and Pete Gamache for the initial version of the freedom_formatter.
Most Liked Responses
arcanemachine
I stumbled on this thread after getting yet another compilation error from shuffling around the values in a long list (obviously, I moved the last one somewhere else in the list).
I think trailing commas are ugly, but they are simply more functional: Cleaner diffs, and makes it easier to shuffle values around.
Thanks for making this project! One less annoyance to babysit. ![]()
Sebb
What do you think about adding tabular code formatting?
And what do you think about making the formatter bringing all clauses to a single line when possible, eg here when the inspect is removed:
case number do
1 ->
:one
2 ->
:two
3 ->
:three
number ->
IO.inspect(number)
:very_big
end
marcandre
Thanks for your question and interest ![]()
I welcome PRs for new features. At first sight, both of these seem acceptable. Care must be taken into when they would trigger or not and have good test coverage.
I personally do not intend to actually write the implementation for any new option. Trailing commas is what I am interested in. It is in my mind a different beast than the rest because it is not about readability or esthetics, it is about ease of editing and about minimizing diffs. I doubt I will propose to my colleagues to use other formatting options.
If someone else writes them, I will gladly review them and maintain them though.
Popular in Discussions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #javascript
- #podcasts
- #code-sync
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








