sindresorhus/eslint-plugin-unicorn

Rule proposal: `prefer-nullish-coalescing`

Chiusa

#471 aperta il 6 dic 2019

 (5 commenti) (5 reazioni) (1 assegnatario)JavaScript (468 fork)user submission
help wantednew rule

Metriche repository

Star
 (5022 stelle)
Metriche merge PR
 (Merge medio 1g 16h) (399 PR mergiate in 30 g)

Descrizione

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

Guida contributor