Bug: [prefer-nullish-coalescing] ignoreConditionalTests
doesn't ignore the boolean !
operator in a condition
#10284
Closed
4 tasks done
Labels
accepting prs
Go ahead, send a pull request that resolves this issue
bug
Something isn't working
locked due to age
Please open a new issue if you'd like to say more. See https://typescript-eslint.io/contributing.
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Uh oh!
There was an error while loading. Please reload this page.
Before You File a Bug Report Please Confirm You Have Done The Following...
Playground Link
https://typescript-eslint.io/play/#ts=5.6.3&fileType=.ts&code=DYUwLgBAZg9jBcEDOYBOBLAdgcwgHwgFdMATEKLEEiAXggHJYZ6BuAKFEgCMBDVRFBhz4ipcpWp16vVKzZsQADwAOMVJCjEAxmHQxMEMCBQBhHkhAAKAJQQA3mwCQ6KBEtN8BGbYePHW-SQYUAA6YBhsS0Y4CDUIGXprdkcAXzY0hRU1DW1dfUNjMDMLACYbeycXNwBCdxi8Lz5rHyd-QOCQMIiozBgNGLiEpKc0jI86YjIKTCp2GVpRKYl2IA&eslintrc=N4KABGBEBOCuA2BTAzpAXGUEKQAIBcBPABxQGNoBLY-AWhXkoDt8B6Y6RAM0WlqYSNkAC1pkA9gEMkyMswDm6MAG1IvaOOiQAuuDABfEPqA&tsconfig=N4KABGBEDGD2C2AHAlgGwKYCcDyiAuysAdgM6QBcYoEEkAhqqrAO4BSZlemArugDTgaMABbpoAa3YUwXXgJpR0JALKwAJtwwBJIniyxE02f0G0AZrEzR0AYWIlkJPbpt0HRAOY6AYmnQA5OnglIx4TBUhMJVhUADd0dmJVDQxQuVMoEnFkRAAZZAAjG1EJNPChElhuK3RlOkNOMPkKrmRoPDLm2iJYAFUiaBLxdDUdNXQADxGAQWhrEg4ZJozIHq0kVDbkPAAldDxq0k6Vnu8GVDxhTCqPYVcSJR0AZWZtweOInv7uB7Vc2GgDEWxi6UC%2BRB%2BIwACnRMEF9lhgctPrB1ohNtBtth4phMMhxh8hPB1Jp0HtKqhuARiNJIAVuEQ1BhMJBQZAcQU6AR4MlSU8AJ66OgTaRmIHoMCCAC%2BIClQA&tokens=false
Repro Code
ESLint Config
tsconfig
Expected Result
I would have expected that the if-statement inside
testCase2
also is allowed, but after updating from8.12.2
to8.13.0
it results in an error suggesting to use??
instead referring to theprefer-nullish-coalescing
rule.I think it should to be allowed to do this check to see whether one of two strings are truthy inside an if-statement as shown in
testCase2
.Actual Result
In the example provided
testCase2
will not run theconsole.log
statement whenfoo=""
andbar="bar"
, however, thetestCase1
runs the if-statement in the same case. This is due to the difference between||
and??
when it comes to the empty string.Meaning the rule now suggests something that is logically not the same, and would change the behavior of code similar to the one shown in the example
Additional Info
No response
The text was updated successfully, but these errors were encountered: