Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy