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

New rule: no-constant-condition #563

Closed
feross opened this Issue Jul 12, 2016 · 3 comments

Comments

3 participants
@feross
Copy link
Member

feross commented Jul 12, 2016

Disallow constant expressions in conditions.

http://eslint.org/docs/rules/no-constant-condition

This rule is overly broad by default, preventing things like while (true) with a break inside, which is really common when writing low-level modules like parsers, etc. which is why it was not enabled before now.

However, there is now a checkLoops option that can be set to false so that only things like this get checked:

if (false) {
  // ...
}

So I propose we enable this now.

@feross feross added the enhancement label Jul 12, 2016

@feross feross modified the milestone: v8 Jul 12, 2016

@jprichardson

This comment has been minimized.

Copy link
Member

jprichardson commented Jul 12, 2016

Ah, sometimes I use this to "trick" standard (if (true) return) with the unreachable code error during development. But overall, this is a good change 👍

@yoshuawuyts

This comment has been minimized.

Copy link
Contributor

yoshuawuyts commented Jul 12, 2016

Aye, works for me

@feross

This comment has been minimized.

Copy link
Member Author

feross commented Jul 12, 2016

This rule will be included in standard v8

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