-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Recommended ESLint rules that are already handled by TypeScript are turned off in plugin:@typescript-eslint/recommended.
The no-unreachable rule is one of the disabled rules because it is covered by the TypeScript compiler error TS7027. However this TS error is suppressed by default since 2.9.1.
This means that when using the recommended rules without explicitly turning off the allowUnreachableCode flag, no ESLint or TS errors will alert the developer of the presence of unreachable code.
I am not sure what the best approach to this is, but it may be worth considering not disabling no-unreachable in the recommended rules or adding a note in the docs...
Repro
{
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
]
}From the ESLint docs:
function fn() {
x = 1;
return x;
x = 3; // this will never execute
}Expected Result
To be alerted of the unreachable code.
Actual Result
No error reported with the default TypeScript compiler options.
Versions
| package | version |
|---|---|
@typescript-eslint/eslint-plugin |
2.3.0 |
@typescript-eslint/parser |
2.3.0 |
TypeScript |
3.6.3 |
ESLint |
6.4.0 |
node |
10.16.3 |
npm |
6.9.0 |