DEV Community

Discussion on: The Case for Comma-Leading Lists

Collapse
 
tao profile image
Lewis Lloyd

adding to the top will create a [+2, -1] diff in both styles. you'll need to keep the opening bracket on its own line to avoid that.

Collapse
 
moaxcp profile image
John Mercier

So yes?

Thread Thread
 
tao profile image
Lewis Lloyd

uh, yes, but 'reverse the problem' is incorrect since it exists for both

Thread Thread
 
moaxcp profile image
John Mercier

But that depends on the style of the language or developers involved. When having the bracket on a separate line is expected, "reverse the problem" seems correct to me.

Thread Thread
 
tao profile image
Lewis Lloyd

separating the bracket will fix the problem for both styles.

logically speaking, there’s no ‘reversal’ no matter how you peg it, as you’re coupling the data with its dependent comma instead of separating them

Thread Thread
 
moaxcp profile image
John Mercier

The reversal is in the location of where the style causes potential git merge issues. With comma-first the issue can happen at the top of the list with comma-last the issue can happen at the bottom of the list.

Im not sure what you mean by removing the dependency on the comma. If the language uses commas to separate the data there is no real way to remove that dependency. It is built into the language.

Thread Thread
 
tao profile image
Lewis Lloyd

ah, i get you, so in the case where brackets are on their own lines, prepending the list will still cause a double diff

in fairness, i’d argue that appending is much more common from my personal experience, be it adding adding data to a JSON, extending an SQL query or passing more attributes to an HTML tag

good spot, though 🙂