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

Update: make no-lone-blocks report blocks in switch cases (fixes #8047) #8062

Merged
merged 1 commit into from Feb 18, 2017

Conversation

not-an-aardvark
Copy link
Member

What is the purpose of this pull request? (put an "X" next to item)

[x] Bug fix (#8047)

What changes did you make? (Give an overview)

This updates no-lone-blocks to report block statements in SwitchCase nodes. As described in #8047, it does not report blocks if they are the only statement in SwitchCase nodes.

Is there anything you'd like reviewers to focus on?

Nothing in particular

@not-an-aardvark not-an-aardvark added accepted There is consensus among the team that this change meets the criteria for inclusion bug ESLint is working incorrectly rule Relates to ESLint's core rules labels Feb 10, 2017
@mention-bot
Copy link

@not-an-aardvark, thanks for your PR! By analyzing the history of the files in this pull request, we identified @vitorbal, @jrvidal and @btmills to be potential reviewers.

@eslintbot
Copy link

LGTM

Copy link
Member

@platinumazure platinumazure left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@alberto
Copy link
Member

alberto commented Feb 10, 2017

I think this is the same case as #7879 so it should be a breaking change too.

@not-an-aardvark
Copy link
Member Author

not-an-aardvark commented Feb 10, 2017

This is a slightly different case from #7879. #7879 concerns the curly braces containing switch statement bodies, which can optionally be handled by the padded-blocks rule even though they're not actually block statements. Since a user might expect padded-blocks to only handle statements that are actually blocks by default, #7879 is a breaking change. On the other hand, this PR concerns curly braces inside switch cases, which are actually block statements. In my opinion, this is a bugfix (so it's semver-minor), in contrast to #7879 which is changing previously-intentional behavior.

@alberto
Copy link
Member

alberto commented Feb 11, 2017

Fair enough.

@eslintbot
Copy link

LGTM

@mysticatea
Copy link
Member

mysticatea commented Feb 14, 2017

I'm not confident, but maybe it should ignore the following case.
Sometimes I have seen the style which puts breaks on the same level as cases.
(if my memory is correct, there was a such issue in indent issues.)

switch (a) {
    case 1:
    {
        doSomething();
    }
    break; // SwitchCase has 2 statements and the last one is a BreakStatement.

    case 2:
    {
        doSomething();
    }
    break;
}

@alberto
Copy link
Member

alberto commented Feb 18, 2017

@mysticatea I think we could add an exception if it's requested.

@alberto alberto merged commit cfb65c5 into master Feb 18, 2017
@ilyavolodin ilyavolodin deleted the no-lone-blocks-switches branch February 18, 2017 14:48
@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 bug ESLint is working incorrectly rule Relates to ESLint's core rules
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants