Skip to content

ter-indent rule bug inside interfaces #46

Description

@sbking

OS: MacOS 10.12.6
Editor: VSCode 1.15.1
Typescript: 2.4.2
tslint: 5.7.0
tslint-language-service: 0.9.6

I've encountered a bug with how tslint-language-service works with the ter-indent rule inside files with interfaces. Whenever I have an interface with multiple lines inside the definition, tslint-language-service is never happy with how the interface members are indented. For example, if I have:

interface JssContext {
  jss: Jss
  registry: SheetsRegistry
  manager: WeakMap<{}, any>
}

Then I get three errors: [tslint] Expected indentation of 4 spaces but found 2. (ter-indent)

If I change the code to:

interface JssContext {
    jss: Jss
    registry: SheetsRegistry
    manager: WeakMap<{}, any>
}

Then I get six errors:

  • [tslint] Expected indentation of 2 spaces but found 4. (ter-indent)
  • [tslint] Expected indentation of 6 spaces but found 4. (ter-indent)

(times three)

I found this relevant issue that was never solved: https://github.com/Microsoft/vscode-tslint/issues/230

Here is my tslint.json:

{
  "extends": [
    "tslint-config-standard",
    "tslint-react"
  ]
}

And my tsconfig.json:

{
  "compilerOptions": {
    "allowJs": true,
    "baseUrl": "src",
    "outDir": "out",
    "module": "esnext",
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "target": "esnext",
    "lib": ["esnext", "dom"],
    "jsx": "react-native",
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "experimentalDecorators": true,
    "plugins": [
      { "name": "tslint-language-service" }
    ]
  },
  "exclude": [
    "node_modules",
    "out",
    "**/*.test.ts",
    "**/*.test.js"
  ]
}

This is happening to me inside an interface. The error is NOT reported when I run tslint with:

./node_modules/.bin/tslint -p ./tsconfig.json -c ./tslint.json

However, the above command does report other rule violations from the config presets, such as unnecessary semicolons. The only place I ever get this issue is in Visual Studio Code, when using the tslint-language-service plugin in my tsconfig. I do not get this issue when using the VSCode tslint plugin without tslint-language-service.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions