arcanemachine
Should the Elixir formatter allow trailing commas?
I saw this topic getting some traction over on the Erlang Forums, so I want to resurrect this topic here (previous discussion here):
Should the Elixir formatter allow trailing commas?
- Yes
- No
Most Liked
sabiwara
I think diffs are one part of the story, but another argument is that it removes friction when re-ordering items by moving lines around as well.
Not a major issue at all, but small pain that could totally be avoided with trailing commas.
The main concern I have with trailing commas is that they are not supported in function arguments, so this might introduce some visual inconsistency perhaps. But since lists / maps have distinct ASTs, I don’t think it’s an issue in practice.
Eiji
The removal of trailing commas in list and map (not calls) is causing trouble a bit especially when you deal with options passed to some macro generator. Think that you want to check something part by part i.e.:
[
key1: :value1,
key2: :value2,
key3: :value3,
# key4: :value4,
# key5: :value5,
]
When you have configured your editor to format file on save then the comma would be removed after :value3. The problem is when you want to uncomment next option(s). Every time I’m doing that I need to add the comma back which is of course simple, but really unnecessary.
Removing a single character does not help at all in my opinion and in some cases it distracts people which is really bad having in mind that Elixir was built with an approach of focus on a work on the actual problem.
dimitarvp
Yeah that’s my usual problem – moving stuff in a list. The auto-removal of the comma from the last element always throws a wrench in what should be a near-brainless process.







