-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Description
Right now I use eqeqeq
to enforce strict (===) equality everywhere, except when comparing to null
. That is great, but I actually want to go one step further and enforce non-strict (==) equality when comparing any value to null
literal.
To put it another way, this will NOT currently throw any lint warning:
let foo;
console.log('is it null', foo == null);
console.log('is it really null', foo === null);
Those two statements are not easy to tell apart during code review. The issue can arise that a coder will use strict equality out of habit yet (in our codebase) they should always use loose equality when comparing to null
in order to also catch undefined
. Similar code will pass lint and pass tests and then later it might fail in production when undefined sneaks in somehow. I'd like to statically enforce loose equality for null
.
Would you be open to a PR?