Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule proposal: prefer-nullish-coalescing #471

Open
fisker opened this issue Dec 6, 2019 · 4 comments
Open

Rule proposal: prefer-nullish-coalescing #471

fisker opened this issue Dec 6, 2019 · 4 comments

Comments

@fisker
Copy link
Collaborator

fisker commented Dec 6, 2019

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

@sindresorhus
Copy link
Owner

For inspiration: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md

This obviously has to wait until ESLint supports ??.

@EvgenyOrekhov
Copy link
Contributor

Support for nullish coalescing operator was added in ESLint 7.2.0.

@fisker fisker self-assigned this Sep 2, 2020
@sindresorhus sindresorhus changed the title Rule Proposal: prefer-nullish-coalescing Rule proposal: prefer-nullish-coalescing Sep 25, 2020
@sindresorhus sindresorhus changed the title Rule proposal: prefer-nullish-coalescing Rule proposal: prefer-nullish-coalescing Sep 25, 2020
@sindresorhus
Copy link
Owner

This is now accepted. PR welcome.

@sindresorhus
Copy link
Owner

If anyone wants to work on this, see the initial attempt and feedback in #1388.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants