-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershas prthere is a PR raised to close thisthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin
Description
Before You File a Bug Report Please Confirm You Have Done The Following...
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have searched for related issues and found none that matched my issue.
- I have read the FAQ and my problem is not listed.
Playground Link
ESLint Config
{
"rules": {
"@typescript-eslint/no-unnecessary-boolean-literal-compare": "warn"
}
}
Repro Code
declare const x;
if(x instanceof Error === false) {}
is turned into
declare const x;
if(!x instanceof Error) {}
which is semantically different:
Operator precedence: ===
< instanceof
< !
Expected Result
Firstly, there should be an option to explicitly allow (identifier instanceof identifier === false)
.
I prefer it over (!(identifier instanceof identifier))
.
As for the actual bug, the following code is expected (with the aforementioned example and the above option disabled):
declare const x;
if(!(x instanceof Error)) {}
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomershas prthere is a PR raised to close thisthere is a PR raised to close thispackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-plugin