Enforce placing destructuring properties on separate lines.
$ npm install --save-dev eslint eslint-plugin-destructuring-newline
๐ง: Fixable
Rule | ๐ง |
---|---|
destructuring-newline/object-property-newline | ๐ง |
In your .eslintrc
{
"plugins": [
"destructuring-newline"
],
"rules": {
"object-curly-newline": 2, // recommended
"destructuring-newline/object-property-newline": 2
}
}
// bad
const { a, b } = obj
// good
const { a } = obj
const {
a,
b,
} = obj
Limit the number of properties per line.
// "destructuring-newline/object-property-newline": [2, { maxProperties: 3 }]
// bad
const {
a,
b,
c,
d,
} = obj
// good
const {
a, b, c,
d,
} = obj
const { a, b } = obj