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

padded-blocks: Change default behavior so that string config affects blocks, classes, and switch statements #7879

Closed
platinumazure opened this issue Jan 6, 2017 · 6 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 breaking This change is backwards-incompatible enhancement This change enhances an existing feature of ESLint rule Relates to ESLint's core rules
Milestone

Comments

@platinumazure
Copy link
Member

platinumazure commented Jan 6, 2017

What rule do you want to change?

padded-blocks

Does this change cause the rule to produce more or fewer warnings?

More in certain circumstances.

How will the change be implemented? (New option, new default behavior, etc.)?

Change default behavior so that a configuration of "always" or "never" will affect classes and switch statements, as well as blocks.

Currently "always" and "never" only affect blocks for backward compatibility reasons. This proposal is to change that behavior (making the rule more intuitive and consistent) in a major release.

Please provide some example code that this change will affect:

/* eslint padded-blocks: ["error", "always"] */

switch (foo) {
    case 1:
        doSomething();
        break;
}

class Foo {
    bar() {
        doSomething();
    }
}

What does the rule currently do for this code?

Does not warn, since these are not BlockStatements.

What will the rule do after it's changed?

Warn-- the switch and class lack appropriate padding. Analogous cases can be created for the "never" string configuration as well.

@platinumazure platinumazure added breaking This change is backwards-incompatible enhancement This change enhances an existing feature of ESLint evaluating The team will evaluate this issue to decide whether it meets the criteria for inclusion rule Relates to ESLint's core rules labels Jan 6, 2017
@alberto
Copy link
Member

alberto commented Jan 6, 2017

Previous discussions:
#5845 particularly #5845 (comment)

#5092

@alberto alberto added this to the v4.0.0 milestone Jan 6, 2017
@platinumazure
Copy link
Member Author

platinumazure commented Jan 6, 2017

My thoughts:

  • 5845: breaking changes should not be introduced unless harm of not doing so is greater than harm of doing so
    • For me, I'm on the fence on this. We've just fixed the documentation explaining how "always" and "never" work, so we can always point users to the docs. However, the inconsistent behavior of those options was always done only as a back-compat thing, and I think we're far away enough from that history that new users will just find the behavior confusing and we should fix it (and longtime users of this rule have had plenty of time to look at the rule docs and switch over to a more explicit configuration if desired). I don't think this change is worth deprecating this rule and creating a new one, but I also understand the potential pain of making this change.
  • 5092: Intentionally decided to make a non-breaking change on this pre-2.0.0
    • That was then... this is now. I'm happy to let the team come to consensus on whether this change is worthwhile or not. Personally, I'd like to unify the behavior of "always" and "never" so it works for all the supported "block-like types".

Another option: If we wanted to deprecate the string option altogether, we could provide a config transform (maybe?) which would turn "always"/"never" into the appropriate object config. That way the configuration is more explicit, at the cost of not allowing a simple config for a common case.

@treybrisbane
Copy link

As a new ESLint user who has recently been bitten by this (see #7868), I'm in favour of this change (either as a new rule, or as a future breaking change to padded-blocks). Even though the docs have now been updated regarding this, I still find the existing behaviour to be unintuitive.

@not-an-aardvark
Copy link
Member

This has 3 👍s from team members, so I'm labelling it as accepted.

@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 Jan 19, 2017
@platinumazure platinumazure self-assigned this Jan 19, 2017
@platinumazure
Copy link
Member Author

This being a breaking change, does TSC need to review? (Currently we have two 👍s from TSC members and no opposition, so hopefully it'd be pretty smooth sailing.)

@platinumazure
Copy link
Member Author

@alberto Reassigning this to you since you have a PR up for this. Thanks for writing a PR!

@alberto alberto removed their assignment Mar 16, 2017
@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 breaking This change is backwards-incompatible 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