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

function body indentation false positive ("indent" rule) #3173

Closed
feross opened this issue Jul 27, 2015 · 7 comments
Closed

function body indentation false positive ("indent" rule) #3173

feross opened this issue Jul 27, 2015 · 7 comments
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 rule Relates to ESLint's core rules

Comments

@feross
Copy link
Contributor

feross commented Jul 27, 2015

With this code:

export function create (id, xfilter, rawType,
                        width=defaultWidth, height=defaultHeight,
                        footerHeight=defaultFooterHeight,
                        padding=defaultPadding) {
  // ... function body, indented two spaces
}

And this config:

"indent": [2, 2, { "indentSwitchCase": true }]

There is an unexpected error:

/t.js:6:2: Expected indentation of 24 characters.

I expect to be able to use 2 spaces indentation for the function body. The indentation of the function parameters should not effect the body.

@eslintbot
Copy link

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
Copy link
Member

Multi-line is still a problem with indent rule.
Kinda related #1801

@gyandeeps gyandeeps added the triage An ESLint team member will look at this issue soon label Jul 27, 2015
@nzakas nzakas added bug ESLint is working incorrectly rule Relates to ESLint's core rules accepted There is consensus among the team that this change meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 28, 2015
@targos
Copy link

targos commented Aug 1, 2015

Cross-referencing: nodejs/node#2286

@thealjey
Copy link

@feross you can reformat your code slightly to make it perfectly valid with the current version of ESLint (1.1.0):

export function create (id, xfilter, rawType,
                        width=defaultWidth, height=defaultHeight,
                        footerHeight=defaultFooterHeight,
                        padding=defaultPadding
) {
  // ... function body, indented two spaces
}

it actually looks much more readable to me this way :)

@silverwind
Copy link
Contributor

@thealjey that looks too confusing imho, and I think it wouldn't comply with the 1tbs option of the brace-style rule. :)

@gyandeeps I hope this issue is not forgotten. If I recall correctly, it's the last issue blocking us from upgrading 0.24 to 1.x in node.

@gyandeeps
Copy link
Member

@silverwind Whenever we put the accepted tag to an issue that means it is open for people to contribute. So its never forgotten, it just that sometimes it takes time and sometimes its quick.

@thealjey
Copy link

@silverwind yes, in fact, it does comply with 1tbs

@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 7, 2018
@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 Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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 rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

7 participants