sindresorhus/eslint-plugin-unicorn

Rule proposal: Prefer destructuring defaults to Object.assign/rest

Closed

#1,538 opened on Oct 2, 2021

 (10 comments) (3 reactions) (0 assignees)JavaScript (468 forks)user submission
help wantednew rule

Repository metrics

Stars
 (5,022 stars)
PR merge metrics
 (Avg merge 1d 16h) (399 merged PRs in 30d)

Description

I found this pattern and it looked like it could be standardized, but it probably isn't very common.

Fail

  const { foo, bar } = {
    foo: false,
    bar: 1,
    ...options,
  };

Pass

  const { foo = false, bar = 1} = options;

Contributor guide