Skip to content

[@typescript-eslint/indent] SwitchCase default inconsistent with docs and ESLint #608

Closed
@benquarmby

Description

@benquarmby

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdocumentationDocumentation ("docs") that needs adding/updatingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions