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

Indentation for certain TypeScript code broken in 4.19.0 #10117

Closed
Kimahriman opened this issue Mar 22, 2018 · 1 comment
Closed

Indentation for certain TypeScript code broken in 4.19.0 #10117

Kimahriman opened this issue Mar 22, 2018 · 1 comment
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion indent Relates to the `indent` rule rule Relates to ESLint's core rules

Comments

@Kimahriman
Copy link

Kimahriman commented Mar 22, 2018

  • ESLint Version: 4.19.0
  • Node Version: 8.4.0
  • npm Version: 5.7.1

What parser (default, Babel-ESLint, etc.) are you using? typescript-eslint

Please show your full configuration:

Configuration
---
env:
  browser: true
  es6: true
  node: true
  jest: true
plugins:
  - react
  - promise
parser: typescript-eslint-parser
parserOptions:
  sourceType: module
extends:
  - eslint:recommended
  - plugin:react/recommended
rules:
  semi:
    - error
    - never
  indent:
    - error
    - 4
    - SwitchCase: 1
  arrow-spacing:
    - error
    - before: true
      after: true
  keyword-spacing:
    - warn
    - before: true
      after: true
  space-before-blocks: warn
  space-before-function-paren:
    - warn
    - never
  space-in-parens: warn
  space-infix-ops: off # Doesn't work with typescript right now
  comma-spacing: warn
  brace-style:
    - error
    - 1tbs
  prefer-const: error
  object-curly-spacing:
    - error
    - always
  no-case-declarations: off
  no-console: off
  no-multi-spaces: error
  no-trailing-spaces: warn
  no-undef: off # Doesn't work with typescript right now
  no-unused-vars: off # Doesn't work with typescript right now
  no-var: error
  no-whitespace-before-property: warn

  # react plugin rules
  react/prop-types:
    - error
    - skipUndeclared: true
  react/no-did-mount-set-state:
    - off
  react/no-did-update-set-state:
    - error
  react/no-will-update-set-state:
    - error
  react/no-unused-prop-types:
    - warn
  react/no-string-refs:
    - error
  react/no-find-dom-node: off
  react/no-multi-comp:
    - warn
    - ignoreStateless: true

  # react jsx rules
  react/jsx-curly-spacing:
    - error
    - always
  react/jsx-indent:
    - error
    - 4
  react/jsx-indent-props:
    - error
    - 4
  react/jsx-closing-bracket-location:
    - error
    - nonEmpty: after-props
      selfClosing: after-props
  react/jsx-no-target-blank:
    - error
  react/jsx-tag-spacing:
    - error
    - closingSlash: never
      beforeSelfClosing: never
      afterOpening: never

  # promise plugin rules
  promise/always-return: off
  promise/no-return-wrap: error
  promise/param-names: error
  promise/catch-or-return: off
  promise/no-native: off
  promise/no-nesting: warn
  promise/no-promise-in-callback: off
  promise/no-callback-in-promise: warn
  promise/avoid-new: warn

What did you do? Please include the actual source code causing the issue, as well as the command that you used to run ESLint.

const arr = ['a', 'b', 'c']
    .map<string>(x => {
        return x
    })
eslint --ext .ts test.ts

What did you expect to happen?

No linting errors.

What actually happened? Please include the actual, raw output from ESLint.

  3:1  error  Expected indentation of 4 spaces but found 8  indent
  4:1  error  Expected indentation of 0 spaces but found 4  indent

✖ 2 problems (2 errors, 0 warnings)
  2 errors, 0 warnings potentially fixable with the `--fix` option.

This issue has something specifically to do with TypeScript. However, it was caused by a change in the 4.19.0 release of ESLint so I'm posting it here to see if there are any insights or any obvious things that might be wrong with the ESLint change, or something obvious that would have to be changed in the TypeScript parser. If I remove the generic typing from the code above to make it:

const arr = ['a', 'b', 'c']
    .map(x => {
        return x
    })

Then it lints fine. I've traced the issue to this commit: 2e68be6#diff-f7ae198ea24182d178b8f3376e61b6edR1406. Specifically the function starting at that line. If I comment that out, I have no issues. This was supposed to fix #9995 and was fixed in #10054. Not sure if this was done incorrectly or some corresponding change needs to be made in the TypeScript parser. I don't know enough of how ESLint works so any info would be helpful.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Mar 22, 2018
@aladdin-add aladdin-add added bug ESLint is working incorrectly rule Relates to ESLint's core rules evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion indent Relates to the `indent` rule and removed triage An ESLint team member will look at this issue soon labels Mar 22, 2018
@eslint-deprecated
Copy link

Unfortunately, it looks like there wasn't enough interest from the team
or community to implement this change. While we wish we'd be able to
accommodate everyone's requests, we do need to prioritize. We've found
that issues failing to reach accepted status after 21 days tend to
never be accepted, and as such, we close those issues.
This doesn't mean the idea isn't interesting or useful, just that it's
not something the team can commit to.

Thanks for contributing to ESLint and we appreciate your understanding.

@eslint-deprecated eslint-deprecated bot added the auto closed The bot closed this issue label Dec 11, 2018
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Jun 10, 2019
@eslint-deprecated eslint-deprecated bot added the archived due to age This issue has been archived; please open a new issue for any further discussion label Jun 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
archived due to age This issue has been archived; please open a new issue for any further discussion auto closed The bot closed this issue bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion indent Relates to the `indent` rule rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

2 participants