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

comment at end of line confuses indent's handling of ternary operator #9729

Closed
Jessidhia opened this issue Dec 18, 2017 · 3 comments · Fixed by Urigo/tortilla#62, mono-js/mono-notifications#5, mono-js/mono-push#5 or terrajs/lib-starter#5 · May be fixed by ali8889/emerald-wallet#4
Assignees
Labels
accepted There is consensus among the team that this change meets the criteria for inclusion archived due to age This issue has been archived; please open a new issue for any further discussion bug ESLint is working incorrectly indent Relates to the `indent` rule rule Relates to ESLint's core rules

Comments

@Jessidhia
Copy link

Jessidhia commented Dec 18, 2017

Tell us about your environment

  • ESLint Version: 4.13.1
  • Node Version: 9.2.0

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

Please show your full configuration:

Configuration
module.exports = {
  parser: 'babel-eslint',
  rules: {
    'indent': ['error', 2, { SwitchCase: 1 }]
  }
}

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 obj = {
  foo () {
    return condition ? // comment
    1 :
      2
  }
}
npx eslint path/to/file.js

What did you expect to happen?
1 to be indented at the same level as 2

What actually happened? Please include the actual, raw output from ESLint.
The source code above is formatted according to eslint --fix.

indent wants to indent the 1 at the same level as the return statement. Removing the // comment after the ? clears indent's confusion and it does put 1 at the same indent level as 2.

Putting the ? on the next line also works around the problem.

@eslint-deprecated eslint-deprecated bot added the triage An ESLint team member will look at this issue soon label Dec 18, 2017
@platinumazure platinumazure added 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 and removed triage An ESLint team member will look at this issue soon labels Dec 20, 2017
@platinumazure
Copy link
Member

This sounds like a bug to me, but I'll defer to @not-an-aardvark.

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion and removed evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Dec 20, 2017
@platinumazure
Copy link
Member

platinumazure commented Dec 22, 2017

Working on this. (Edit: Might take me a couple of days-- if someone else wants to work on this, just let me know here and I'll stop. Thanks!)

@not-an-aardvark
Copy link
Member

I think I see what's wrong -- I'll work on it for a bit.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.