← Back

comma-dangle warning

Requires trailing commas when the last element or property is in a different line than the closing ] or } and disallows trailing commas when the last element or property is on the same line as the closing ] or }

Examples

❌  Incorrect

let object1 = { a: 'b', c: 'd', };

let object2 = {
    a: 'b',
    c: 'd'
};

let array1 = ['a', 'b', 'c',];

let array2 = [
    'a',
    'b',
    'c'
];

✅  Correct

let object1 = { a: 'b', c: 'd' };

let object2 = {
    a: 'b',
    c: 'd',
};

let array1 = ['a', 'b', 'c'];

let array2 = [
    'a',
    'b',
    'c',
];