marcandre

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 :heart:, and Pete Gamache for the initial version of the freedom_formatter.

Most Liked Responses

arcanemachine

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. :slight_smile:

Sebb

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

marcandre

Thanks for your question and interest :slight_smile:

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.

Where Next?

Popular in Discussions Top

pillaiindu
In django there is a cache framework backed by memcached. Rails also puts a lot of emphasis on caching, and even the idea of russian-doll...
New
lorenzo
Hey everone! I created a prototype for my app using Nodejs for the api. But the framework I chose wasnt great (in general theresnt any g...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 39297 209
New
nburkley
AWS re:Invent is on at the moment with some interesting announcements. One new feature in particular is the Lambda Runtime API for AWS La...
New
CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New
sergio
There’s a new TIOBE index report that came out that shows Elixir is still not in the top 50 used languages. It also goes on to call Elix...
New
Qqwy
I would like to spark a discussion about the static access operator: .. For whom does not know: it is used in Elixir to access fields of...
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
jsonify
So, is Heroku the only free option for hosting Phoenix/Elixir at this point? I’m not ready to commit to paying monthly and was wondering ...
New

Other popular topics Top

lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 126479 1222
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New

We're in Beta

About us Mission Statement