[prefer-nullish-coalescing] add option to only flag where behavior would be the same #1265
Labels
enhancement: plugin rule option
New rule option for an existing eslint-plugin rule
has pr
there is a PR raised to close this
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Repro
Expected Result
This should not trigger a rule error, because using
??
would be a different behavior: It would not apply the default value ifbar
is an empty string.I would expect there to be an option so that it only flags cases where it can confidently say that there is no change in behavior, like when the type is an object. Maybe something like
ignoreTypes: ["number", "string", "boolean"]
.Actual Result
It flags uses of
||
where the behavior is different than??
, i.e. with strings, booleans and numbers.Additional Info
Versions
@typescript-eslint/eslint-plugin
2.9.0
@typescript-eslint/parser
2.9.0
TypeScript
3.7.2
ESLint
6.6.0
node
12.11.0
npm
6.13.1
The text was updated successfully, but these errors were encountered: