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

Indent issue with multi-line var/const #3498

Closed
MikaAK opened this Issue Aug 23, 2015 · 6 comments

Comments

Projects
None yet
4 participants
@MikaAK

MikaAK commented Aug 23, 2015

I'm having an issue with indentation, before I was using 0.24 and it was all good but now with multi-line var declarations I get indent errors. I may perhapse be using the wrong config but from the docs this is what I understood to be the config that would allow for declarations like I have.

Config

"indent": [2, 2, {"VariableDeclarator": 2}],

Tried

"indent": [2, 2, {"VariableDeclarator": { "var": 2, "let": 2, "const": 3}}]

Source file

export default function() {
  const HO = 'bah',
        TE = 'mah'

  var res,
      a = 5,
      b = 4

  if (a++ === b) {
    let multiplier = HO + TE

    multiplier += '329' 

    res = multiplier
  }

  return res
}

Error

9:3 error Expected indentation of 6 space characters but found 2 indent

@eslintbot eslintbot added the triage label Aug 23, 2015

@eslintbot

This comment has been minimized.

Show comment
Hide comment
@eslintbot

eslintbot Aug 23, 2015

Thanks for the issue! We get a lot of issues, so this message is automatically posted to each one to help you check that you've included all of the information we need to help you.

Reporting a bug? Please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. The source code that caused the problem
  3. The configuration you're using (for the rule or your entire config file)
  4. The actual ESLint output complete with line numbers

Requesting a new rule? Please be sure to include:

  1. The use case for the rule - what is it trying to prevent or flag?
  2. Whether the rule is trying to prevent an error or is purely stylistic
  3. Why you believe this rule is generic enough to be included

Requesting a feature? Please be sure to include:

  1. The problem you want to solve (don't mention the solution)
  2. Your take on the correct solution to problem

Including this information in your issue helps us to triage it and get you a response as quickly as possible.

Thanks!

eslintbot commented Aug 23, 2015

Thanks for the issue! We get a lot of issues, so this message is automatically posted to each one to help you check that you've included all of the information we need to help you.

Reporting a bug? Please be sure to include:

  1. The version of ESLint you are using (run eslint -v)
  2. The source code that caused the problem
  3. The configuration you're using (for the rule or your entire config file)
  4. The actual ESLint output complete with line numbers

Requesting a new rule? Please be sure to include:

  1. The use case for the rule - what is it trying to prevent or flag?
  2. Whether the rule is trying to prevent an error or is purely stylistic
  3. Why you believe this rule is generic enough to be included

Requesting a feature? Please be sure to include:

  1. The problem you want to solve (don't mention the solution)
  2. Your take on the correct solution to problem

Including this information in your issue helps us to triage it and get you a response as quickly as possible.

Thanks!

@gyandeeps

This comment has been minimized.

Show comment
Hide comment
@gyandeeps

gyandeeps Aug 24, 2015

Member

The rule is behaving as expected. You need to specify like this

"indent": [2, 2, {"VariableDeclarator": { "var": 2, "let": 2, "const": 3}]

Docs: http://eslint.org/docs/rules/indent#options

Member

gyandeeps commented Aug 24, 2015

The rule is behaving as expected. You need to specify like this

"indent": [2, 2, {"VariableDeclarator": { "var": 2, "let": 2, "const": 3}]

Docs: http://eslint.org/docs/rules/indent#options

@MikaAK

This comment has been minimized.

Show comment
Hide comment
@MikaAK

MikaAK Aug 24, 2015

@gyandeeps I've updated my post with a better test case, I've tried {"VariableDeclarator": { "var": 2, "let": 2, "const": 3} as well and I still get the error.

MikaAK commented Aug 24, 2015

@gyandeeps I've updated my post with a better test case, I've tried {"VariableDeclarator": { "var": 2, "let": 2, "const": 3} as well and I still get the error.

@gyandeeps

This comment has been minimized.

Show comment
Hide comment
@gyandeeps

gyandeeps Aug 24, 2015

Member

What kind of parser are you using and version of eslint?
I am confused, initially you had issue with const but after your modification now the error is on line 9 which is a if. Is this correct?

Member

gyandeeps commented Aug 24, 2015

What kind of parser are you using and version of eslint?
I am confused, initially you had issue with const but after your modification now the error is on line 9 which is a if. Is this correct?

@MikaAK

This comment has been minimized.

Show comment
Hide comment
@MikaAK

MikaAK Aug 24, 2015

@gyandeeps So it is, my bad.
I'm using eslint parser and v1.2.1. I'm actually confused on how to set this up to allow for the syntax I have in my test file without spitting errors. Currently it's erroring at the if statement with the config you supplied

MikaAK commented Aug 24, 2015

@gyandeeps So it is, my bad.
I'm using eslint parser and v1.2.1. I'm actually confused on how to set this up to allow for the syntax I have in my test file without spitting errors. Currently it's erroring at the if statement with the config you supplied

@gyandeeps

This comment has been minimized.

Show comment
Hide comment
@gyandeeps

gyandeeps Aug 24, 2015

Member

Its an issue, I just confirmed it. It goes away iif you put semi after the var declaration. We will take a look.
Thanks.

Its happening because the statement var is not ending with ; at the end so espree make the end location of the var node to be line 9.

Member

gyandeeps commented Aug 24, 2015

Its an issue, I just confirmed it. It goes away iif you put semi after the var declaration. We will take a look.
Thanks.

Its happening because the statement var is not ending with ; at the end so espree make the end location of the var node to be line 9.

@gyandeeps gyandeeps added bug rule accepted and removed triage labels Aug 24, 2015

BYK added a commit that referenced this issue Aug 24, 2015

@BYK BYK self-assigned this Aug 24, 2015

BYK added a commit that referenced this issue Aug 24, 2015

BYK added a commit that referenced this issue Aug 24, 2015

BYK added a commit that referenced this issue Aug 24, 2015

BYK added a commit that referenced this issue Aug 24, 2015

@eslint eslint bot locked and limited conversation to collaborators Feb 7, 2018

@eslint eslint bot added the archived due to age label Feb 7, 2018

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