material-ui icon indicating copy to clipboard operation
material-ui copied to clipboard

Dangling Commas

Open jkruder opened this issue 11 years ago • 8 comments

Any preference on dangling commas? I can go either way; I've been removing them as I see them because a majority of the codebase does not make use of them.

I took a look at the compiled app.js and the files under lib and they do not appear to contain trailing commas where the source did. So MUI should be compatible with IE8 in regards to trailing commas.

jkruder avatar Jul 08 '15 13:07 jkruder

In my experience dangling commas make git diff and the life of the programmer easier, it's easy to forget to add a new commas when adding a new line (having to rebuild for nothing), it does not happens with dangling commas.

cgestes avatar Jul 08 '15 14:07 cgestes

@cgestes I agree with you

oliviertassinari avatar Jul 08 '15 14:07 oliviertassinari

Sounds like we may want to enforce dangling commas. @hai-cea what do you think?

jkruder avatar Jul 08 '15 14:07 jkruder

:+1: for dangling commas.

troutowicz avatar Jul 08 '15 14:07 troutowicz

Sounds good to me :+1:

hai-cea avatar Jul 08 '15 14:07 hai-cea

Sweet. The eslint rule has a couple of options. I'm leaning towards always-multiline over always. This requires a dangling comma anywhere we have multiple lines in an object/array. Examples:

let obj = {
  key: 'value' // valid
};

let obj = {
  key: 'value', // invalid
};

let obj = {
  key: 'value',
  otherKey: 'value' // invalid
};

let obj = {
  key: 'value',
  otherKey: 'value', // valid
};

Thoughts?

jkruder avatar Jul 08 '15 14:07 jkruder

I prefer always-multiline.

troutowicz avatar Jul 08 '15 14:07 troutowicz

+1 Always multiline.

hai-cea avatar Jul 08 '15 15:07 hai-cea