Skip to content

[ESLint] Enable != for comparing null #4807

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

Closed
xixixao opened this issue Jul 22, 2018 · 3 comments
Closed

[ESLint] Enable != for comparing null #4807

xixixao opened this issue Jul 22, 2018 · 3 comments

Comments

@xixixao
Copy link

xixixao commented Jul 22, 2018

!= null is the correct and safer way to compare against optional values. I suggest we configure ESLint with ["warn", "always", {"null": "ignore"}].

@xixixao xixixao changed the title Enable != for comparing null [ESLint] Enable != for comparing null Jul 22, 2018
@bugzpodder
Copy link

This approach is not recommended for new developers who might not be aware of != null and !== null.

@xixixao
Copy link
Author

xixixao commented Jul 22, 2018

@bugzpodder Developers need to learn lots of things, including lots about the syntax of the language they use. The Lint rules should guide them to the right practices. A novice developer seeing this warning will go ahead and change != null to !== null (or undefined), causing a very hard to find bug at some later point in time.

What do I need to do to make this change? Does it only require consensus here, or do we need to change ESLint defaults?

@xixixao
Copy link
Author

xixixao commented Jul 22, 2018

In fact, now that I see the code, this is a bug. The config is using a deprecated option that no longer works.

@lock lock bot locked and limited conversation to collaborators Jan 18, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants