In the js space, people often leave a tailing comma at the end of each line, when writing the elements of an array.<p>I was the practise of using leading comma in Elm, where we put a comma at the beginning of each line, when writing elements of a list.<p>I'm also using leading comma (and leading and/or) when writing sql query.<p>For example:<p><pre><code> select
user.id
, user.username
from user
where user.ban_time is null
and user.activate_time is not null</code></pre>
Trailing in languages which support ending the last item with a comma as this follows the usage of the semicolon.<p><pre><code> [ 1,
2,
]
</code></pre>
Leading otherwise as no language I can remember supports a leading comma on the first item:<p><pre><code> [ 1
, 2
]
</code></pre>
The entire point of this is to avoid needing to edit the prior line when inserting items into an existing lexical list this makes the diffs just:<p><pre><code> +
</code></pre>
instead of:<p><pre><code> -
+
+
</code></pre>
If you don't care about how your line diffs look, don't bother. Just auto-format your code instead.