Skip to content
This repository was archived by the owner on Jan 19, 2019. It is now read-only.
This repository was archived by the owner on Jan 19, 2019. It is now read-only.

[indent] regression with [email protected] #271

@scottohara

Description

@scottohara

This issue was originally posted over at eslint/typescript-eslint-parser#586; but it was suggested that it be raised here as well. Please refer to the original issue for additional commentary/discussion.

Repro

{
  "parser": "typescript-eslint-parser",
  "plugins": ["typescript"],
  "rules": {
    "indent": "off",
    "typescript/indent": ["error", "tab", {"VariableDeclarator": {"const": 3}}]
  }
}

(in the code below, ^ represents a tab character)

interface Foo {
  a: number;
  b: number;
}

const foo: Foo = {
^ ^ ^ ^ a: 1,
^ ^ ^ ^ b: 2
^ ^ ^ },
^ ^ ^ bar = 1;

Expected Result
No errors

Actual Result
In [email protected], code passes with no errors.

With [email protected] onwards, the errors below occur:

7:1  error  Expected indentation of 1 tab but found 4   indent
8:1  error  Expected indentation of 1 tab but found 4   indent
9:1  error  Expected indentation of 0 tabs but found 3  indent

Additional Info
The code can be modified like below to pass, but clearly this is not what the config intends:

const foo: Foo = {
  a: 1,
  b: 2
},
      bar = 1

Vanilla JS code without a type annotation passes as expected:

const foo = {
        a: 1,
		b: 2
      },
      bar = 1;

It also worth noting that the same issue occurs when using:

  • spaces instead of tabs
  • the main indent rule from eslint instead of the typescript/indent rule from eslint-plugin-typescript
eslint-plugin-typescript typescript-eslint-parser indent typescript/indent
0.14.0 20.0.0 N/A
1.0.0-rc.0 20.0.0
0.14.0 20.1.0+ N/A
1.0.0-rc.0 20.1.0+

Versions

package version
eslint 5.11.1
typescript 3.1.1
eslint-plugin-typescript 0.14.0+
typescript-eslint-parser 20.1.0+

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions