Skip to content

[@typescript-eslint/indent] False positive on chained calls in multiline const declaration #119

Closed
@scottohara

Description

@scottohara

Repro

{
  "rules": {
    "@typescript-eslint/indent": ["error", 2, { "VariableDeclarator": { "const": 3 } }]
  }
}
const div: JQuery<HTMLElement> = $('<div>')
        .addClass('some-class')
        .appendTo($('body')),

      button: JQuery<HTMLElement> = $('<button>')
        .text('Cancel')
        .appendTo(div);

Expected Result
No errors

Actual Result

2:1  error  Expected indentation of 2 spaces but found 8  @typescript-eslint/indent
3:1  error  Expected indentation of 2 spaces but found 8  @typescript-eslint/indent

Additional Info

  1. Only the indentation on lines 2-3 seems to trigger the error. Similar indentation used on lines 6-7 does not trigger the error.
  2. The error only seems to trigger when generic type annotations (e.g. JQuery<HTMLElement>) are used.

An example without generics does not error:

const name: string = '  Typescript  '
        .toUpperCase()
        .trim(),

      greeting: string = ` Hello ${name} `
        .toUpperCase()
        .trim();

Versions

package version
@typescript-eslint/eslint-plugin 1.0.0
@typescript-eslint/parser 1.0.0
TypeScript 3.2.1
ESLint 5.11.1
node 11.5.0
npm 6.5.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingpackage: eslint-pluginIssues related to @typescript-eslint/eslint-plugin

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions