If object literal is element of multiline array, it open bracket has to start in new line. This rule is created to work with "comma-dangle": [2, "always-multiline"] rule. When only comma-dangle rule is turned on, it allows ugly ending comma
The following patterns are considered warnings:
var multilineArray = [{
value: 1
}];
var multilineArray = [{
value: 1
}, {
value: 2
}];
var multilineArray = [
{
value: 1
}, {
value: 2
}
];
// when used with comma-dangle rule
var multilineArray = [{
value: 1
}, {
value: 2
}, ]; // <-- this dangle comma is so ugly
The following patterns are not considered warnings:
var singleLineArray = [{}];
var singleLineArray = [{ value:1 }];
var multilineArray = [
{
value: 1
}
];
var multilineArray = [
{
value: 1
},
{
value: 2
}
];
// when used with comma-dangle rule
var multilineArray = [
{
value: 1
},
{
value: 2
},
];
If you are not using comma-dangle rule or prefere collapse brackets.