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

Early exit vs if else #231

Closed
dcousens opened this issue Aug 13, 2015 · 2 comments

Comments

@dcousens
Copy link
Member

commented Aug 13, 2015

Case 1

if (condition) {
  return true
} else {
  // ... code
}

Case 2

if (condition) return true

// ... code

IMHO, I find case 2 to be the clearest and cleanest, @feross did you have any thoughts on this? Should we align to either convention? Even if we do, can we do anything about it?

It would have to be consistent for continue, break and return statements.

@dcousens dcousens added the question label Aug 13, 2015

@feross

This comment has been minimized.

Copy link
Member

commented Aug 13, 2015

I prefer case 2, but there's no way to enforce this with eslint, nor do I think we should do that. :)

@feross feross closed this Aug 13, 2015

@dcousens

This comment has been minimized.

Copy link
Member Author

commented Aug 13, 2015

No worries, just though I'd bring it up as I had a case of nit picking about it in a recent repository, and it just stirred up an unnecessary discussion.

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

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