git-validator
git-validator copied to clipboard
feat(eslint-plugin): `consistent-object-array-spread`
Array
ok
let name: string = '' ;
if (Math.random() > 0.5) {
name = "foo"
}
const names = ["bar", ...(name && [name])]
fail
let name: string | undefined = undefined;
if (Math.random() > 0.5) {
name = "foo"
}
const names = ["bar", ...(name && [name])]
ok
let name: string | undefined = undefined;
if (Math.random() > 0.5) {
name = "foo"
}
const names = ["bar", ...(name ? [name] : [])]
Object
ok
let name: string | undefined = undefined;
if (Math.random() > 0.5) {
name = "foo"
}
const student = {age: 12, ...(name&&{name})}
fail
let name: string | undefined = undefined;
if (Math.random() > 0.5) {
name = "foo"
}
const student = {age: 12, ...(name ? {name} : {})}