π Prefer a single object destructuring declaration per local const source.
πΌπ« This rule is enabled in the β
recommended config. This rule is disabled in the βοΈ unopinionated config.
π§ This rule is automatically fixable by the --fix CLI option.
Prefer one object destructuring declaration when consecutive declarations read from the same local const source.
This rule only reports adjacent declarations with the same declaration kind and the same identifier source. The source identifier must resolve to a local const binding, so mutable or unresolved sources are ignored. More complex patterns are ignored by design.
// β
const foo = {};
const {bar} = foo;
const {baz} = foo;
// β
const foo = {};
const {bar, baz} = foo;// β
let foo = {};
const {bar} = foo;
const {baz} = foo;// β
import foo from 'foo';
const {bar} = foo;
const {baz} = foo;// β
const {bar} = foo;
console.log(bar);
const {baz} = foo;