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

Prevent confusing if-statement usage #616

Closed
willsoto opened this issue Sep 9, 2016 · 4 comments

Comments

@willsoto
Copy link

commented Sep 9, 2016

As per the suggestion here, I am opening up a an issue to discuss extending the rules around if blocks.

The blocks were originally indented like so:

if (condition) {
  // stuff
} if (anotherUnrelatedCondition) {
  // more
} 

I found this confusing because at first glance it looks like if; else if blocks.


I would image the rule could be something like:

ensure 1 newline between if blocks

Other suggestions are welcome.

@dcousens

This comment has been minimized.

Copy link
Member

commented Sep 10, 2016

That really should be disallowed. The wriggle room for accidents is pretty high.

@KhaledMohamedP

This comment has been minimized.

Copy link

commented Sep 10, 2016

Totally agree here. It should be disallowed 👍

@feross

This comment has been minimized.

Copy link
Member

commented Sep 11, 2016

Agreed. This should be prevented. However, there's no eslint rule that allows us to catch this case.

I just opened an issue to get the eslint team's thoughts: eslint/eslint#7116

@feross feross changed the title Discussion: lint formatting of if blocks Prevent confusing if-statement usage Sep 11, 2016

@feross feross added the blocked label Sep 11, 2016

@feross feross modified the milestone: standard v9 Sep 11, 2016

@feross feross removed this from the standard v9 milestone Feb 9, 2017

@feross

This comment has been minimized.

Copy link
Member

commented Feb 9, 2017

Closing this, as we're blocked. I'll re-open if the ESLint issue makes any progress.

@feross feross closed this Feb 9, 2017

@lock lock bot locked as resolved and limited conversation to collaborators May 10, 2018

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
4 participants
You can’t perform that action at this time.