sindresorhus/eslint-plugin-unicorn

Rule proposal: `prefer-nullish-coalescing`

Closed

#471 opened on Dec 6, 2019

 (5 comments) (5 reactions) (1 assignee)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

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing_operator

https://github.com/tc39/proposal-nullish-coalescing

let foo = (undefined || null) || bar;

// equals

let foo = (undefined || null) ?? bar;

anyway, it not safe for foo || bar -> foo ?? bar, we should use ESLint suggestion api

Contributor guide