-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Closed
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedThis change will require a new major version to be releasedpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginrecommended-rulesDiscussion about recommended rule setsDiscussion about recommended rule sets
Milestone
Description
- I have tried restarting my IDE and the issue persists.
- I have updated to the latest version of the packages.
- I have read the FAQ and my problem is not listed.
Repro
{
"extends": ["plugin:@typescript-eslint/recommended"]
}
typeof window === undefined
typeof window === null
Expected Result
error Typeof comparisons should be to string literals valid-typeof
Actual Result
🦗
Additional Info
The @typescript-eslint/recommended
ruleset disables the valid-typeof
ESLint rule on the basis that it's covered by TypeScript's "This condition will always return 'false'" handling.
However, this is incorrect: TypeScript does not detect this incorrect condition in the case of null
and undefined
, and so the valid-typeof
rule should be re-enabled in the recommended
preset.
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
4.23.0 |
@typescript-eslint/parser |
4.23.0 |
TypeScript |
4.2.4 |
ESLint |
7.26.0 |
node |
12.13.1 |
Metadata
Metadata
Assignees
Labels
accepting prsGo ahead, send a pull request that resolves this issueGo ahead, send a pull request that resolves this issuebreaking changeThis change will require a new major version to be releasedThis change will require a new major version to be releasedpackage: eslint-pluginIssues related to @typescript-eslint/eslint-pluginIssues related to @typescript-eslint/eslint-pluginrecommended-rulesDiscussion about recommended rule setsDiscussion about recommended rule sets