Standard: Remove `eqeqeq` opt-in for nulls

Created on 1 Oct 2020  路  3Comments  路  Source: standard/standard

What version of this package are you using?
14.3.4

What problem do you want to solve?
eqeqeq enforced for nulls

What do you think is the correct solution to this problem?
Setting the second arg to eqeqeq to "null": "always" (or removing the setting altogether as this is the default)
https://eslint.org/docs/rules/eqeqeq

Are you willing to submit a pull request to implement this change?
Yes

I was surprised to see:

if (foo == null)

Is valid in standardjs.

I can't find any background on this so I thought I'd ask why standardjs opts-in to more specific handling of null in eslint eqeqeq. I don't often come across this kind of explicit equality check but I noticed it on a code review I was doing and it jumped out at me. Personally, I'd like to enforce triple equals always for consistency. Is there a strong reason for having this exception?

https://eslint.org/docs/rules/eqeqeq#always

Most helpful comment

foo == null is the equivalent of foo === undefined || foo === null

I personally most often (especially when dealing with GraphQL 馃槄) want to check both of those, and then use the shorthand == null. I feel that forcing people to write the longer form would be a bit too much 馃

All 3 comments

foo == null is the equivalent of foo === undefined || foo === null

I personally most often (especially when dealing with GraphQL 馃槄) want to check both of those, and then use the shorthand == null. I feel that forcing people to write the longer form would be a bit too much 馃

That's actually really quite useful and a good argument to keep it as-is. 馃憤

Yep, let's keep this as-is :)

Was this page helpful?
0 / 5 - 0 ratings