Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ter-indent rule bug inside interfaces #46

Open
sbking opened this issue Aug 29, 2017 · 1 comment
Open

ter-indent rule bug inside interfaces #46

sbking opened this issue Aug 29, 2017 · 1 comment

Comments

@sbking
Copy link

sbking commented Aug 29, 2017

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.

@josiahruddell
Copy link

I'm having the same problem, had to disable the ter-indent rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants