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

Documentation for padded-blocks rule is out of date. #6628

Closed
jseminck opened this issue Jul 8, 2016 · 3 comments
Closed

Documentation for padded-blocks rule is out of date. #6628

jseminck opened this issue Jul 8, 2016 · 3 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 documentation Relates to ESLint's documentation enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules

Comments

@jseminck
Copy link

jseminck commented Jul 8, 2016

Yesterday we spent quite some time figuring out how to correctly configure the padded-blocks rule. The problem we faced was that we wanted to disable padding (use option never) for all switches, classes and blocks.

But the documentation doesn't mention the option {blocks: never}. It only mentions:

  • String"never" (which applies to blocks only)
  • {switches: "never"}
  • {classes: "never"}

See docs: https://github.com/eslint/eslint/blob/master/docs/rules/padded-blocks.md

As it's not possible to supply both a String and an object, as parameter, this basically got us confused. :)

Edit: If needed I could make a PR and try to clarify the documentation part.

Additionally, I would have expected that passing in never as a String would actually set blocks, classes and switches, and then the object option should only be used when you want to mix/match the different options... but I assume it's the way it is because the additional options were added after the initial rule was already created?

@eslintbot eslintbot added the triage An ESLint team member will look at this issue soon label Jul 8, 2016
@jseminck jseminck closed this as completed Jul 8, 2016
@jseminck
Copy link
Author

jseminck commented Jul 8, 2016

Looks like my comment was incorrect. "never" according to code should still work as I interpreted the following line incorrectly initially. Will try to find out why it didn't not work for us.
https://github.com/eslint/eslint/blob/master/lib/rules/padded-blocks.js#L53

@jseminck jseminck reopened this Jul 8, 2016
@alberto
Copy link
Member

alberto commented Jul 8, 2016

Hi @jseminck thanks for commenting.

There is a mention in the docs about blocks as an object key:

If you want to enforce padding within switches and classes, a configuration object can be passed as the rule argument to configure the cases separately ( e.g. { "blocks": "always", "switches": "always", "classes": "always" } ).

We could add some examples there, though.

Your original assumption is correct, the string option only affects blocks, for backwards compatibility reasons. It's also mentioned in the docs

By default, this rule ignores padding in switch statements and classes.

@platinumazure
Copy link
Member

@pedrottimark Wondering if you could take a look at this issue and see if you think we could improve the information architecture in the padded-blocks documentation.

@platinumazure platinumazure added bug ESLint is working incorrectly rule Relates to ESLint's core rules documentation Relates to ESLint's documentation evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion and removed triage An ESLint team member will look at this issue soon labels Jul 8, 2016
@alberto alberto added enhancement This change enhances an existing feature of ESLint accepted There is consensus among the team that this change meets the criteria for inclusion and removed bug ESLint is working incorrectly evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion labels Jul 8, 2016
@eslint-deprecated eslint-deprecated bot locked and limited conversation to collaborators Feb 6, 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 6, 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 documentation Relates to ESLint's documentation enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Projects
None yet
Development

No branches or pull requests

4 participants