Description
The documentation states that the default indentation level for SwitchCase
is zero:
https://github.com/typescript-eslint/typescript-eslint/blame/61e6385c65b147a5a8b4caa2f3241e5a92c9b1bf/packages/eslint-plugin/docs/rules/indent.md#L77
The default for ESLint is also zero:
https://eslint.org/docs/rules/indent#options
In practice, the level is actually 1
. Other than the documentation being incorrect, I'd argue that turning ESLint's indent
off and setting @typescript-eslint/indent
to error
should not produce new violations on code covered by both rules.
Repro
{
"rules": {
"indent": "off",
"@typescript-eslint/indent": "error"
}
}
switch (typeof true) {
case "string":
throw new Error("never");
}
Expected Result
Does not raise a violation.
Actual Result
Raises a violation.
Additional Info
Can be worked around by explicitly setting the SwitchCase
level. Unfortunately this requires being explicit about the indentation depth also:
{
"rules": {
"indent": "off",
"@typescript-eslint/indent": ["error", 4, {
"SwitchCase": 0
}]
}
}
Versions
package | version |
---|---|
@typescript-eslint/eslint-plugin |
1.10.2 |
@typescript-eslint/parser |
1.10.2 |
TypeScript |
3.3.1 |
ESLint |
5.12.1 |
node |
10.15.4 |
yarn |
1.16.0 |