Re:Interesting Bugs Caught by ESLint's no-constant-binary-ex...
by amatecha on Thursday November 09, 2023 @01:51AM
(#38201935)
Ahh... there's a strict equality operator comparing undefined (both a value and a type) to something that's being coerced to a boolean... it will always return false. The first thing I look at when I see a strict equality comparison is "are the operands actually the same type" because that's a very common mistake (or so I've noticed)!
Huh, now I'm curious if my IDE would highlight this with a warning... will have to check!
Here's one example that the rule caught: https://github.com/captbaritone/vscode/blob/ab86e0229d6b4d0c...
I've been writing JS for over 10 years now, and I'm not sure I would have caught that in code review.