Closed
Description
Original comment by @phaux in #1480
Here are the cases that I encounter often and could have an option to allow them:
boolean
– always allowedboolean | null | undefined
aka optional/nullable boolean – developers often want to treat the nullish case the same as false instead of explicitly sayingvalue ?? false
orvalue == null ? false : value
- allowed by
allowNullable
- allowed by
string | number
– developers often want to test for zero/empty string without explicit comparisonvalue != 0
etc.- would be allowed by e.g.
allowPrimitive
or something
- would be allowed by e.g.
object | function | null | undefined
aka nullable object/function – developers often check against the nullish case without explicitly comparing to null. I've met a lot of people that don't even know thatvalue == null
also checks for undefined.- would be allowed by
allowSafe
if we can fix it, orallowNullableObject
or something
- would be allowed by
We've learned a lot about this rule and how people want to use it. We should look into reworking the options so that it matches how people want to use the rule.