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

rule: disallow lone blocks #512

Closed
michaelficarra opened this issue Jan 14, 2014 · 5 comments

Comments

Projects
None yet
2 participants
@michaelficarra
Copy link
Member

commented Jan 14, 2014

Bad: {}

Bad: a; {} b;

Bad: if(a) { b; {} c; }

Doubly Bad: { { } }

Good: if(a) { if(b) { c; } }

Basically, anything that matches BlockStatement > BlockStatement or Program > BlockStatement.

@nzakas

This comment has been minimized.

Copy link
Member

commented Jan 14, 2014

Is there any instance where you would want this capability? (I can't think
of any off the top of my head.)

@michaelficarra

This comment has been minimized.

Copy link
Member Author

commented Jan 14, 2014

Yeah, I don't think so. It should definitely be on by default. Most JS users aren't even familiar with the concept of a block.

@nzakas

This comment has been minimized.

Copy link
Member

commented Jan 14, 2014

Are you saying that this rule should be on by default? If so, then I
disagree. Most style guides require braces regardless of the number of
statements so that seems like the logical default to me (what we have right
now).

@michaelficarra

This comment has been minimized.

Copy link
Member Author

commented Jan 14, 2014

You're confusing this one with #511. This one is about standalone blocks, which have basically no use in JS. If you've used one, it's almost certainly a mistake.

@nzakas

This comment has been minimized.

Copy link
Member

commented Jan 14, 2014

Ah sorry, you are correct! I retract and agree that this should be on by
default.

(Too many emails whizzing across my screen at the moment.)

btmills added a commit to btmills/eslint that referenced this issue Feb 1, 2014

btmills added a commit to btmills/eslint that referenced this issue Feb 1, 2014

btmills added a commit to btmills/eslint that referenced this issue Feb 1, 2014

New Rule: no-lone-blocks (fixes eslint#512)
Removed extra down-traversal in favor of looking up one level at
ancestors to incorporate PR feedback.

btmills added a commit to btmills/eslint that referenced this issue Feb 1, 2014

New Rule: no-lone-blocks (fixes eslint#512)
Removed extra down-traversal in favor of looking up one level at
ancestors and changed config from warning to error to incorporate
PR feedback.

@nzakas nzakas closed this in 86260e9 Feb 1, 2014

nzakas added a commit that referenced this issue Feb 1, 2014

Merge pull request #572 from btmills/no-lone-blocks
New Rule: no-lone-blocks (fixes #512)

@michaelficarra michaelficarra referenced this issue Mar 9, 2014

Closed

WebStorm Inspectors (rollup) #667

56 of 138 tasks complete

@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.
You can’t perform that action at this time.