question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[ no-constant-condition] should validate 'void' too

See original GitHub issue

Request type : Enhancement

Rule : no-constant-condition

What version of ESLint are you using? 2.5.1

What parser (default, Babel-ESLint, etc.) are you using? default

Please show your full configuration:

{
  "rules": {
    "no-constant-condition": 2   // disallow use of constant expressions in conditions
  }
}

What did you do? Please include the actual source code causing the issue.

if(void x){}
if (void x === void x){}

What did you expect to happen? Error as it is a constant condition

What actually happened? No error

As discussed in #5228 & #5696

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:12 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
ilyavolodincommented, Mar 29, 2016

Sounds reasonable to me. Although I think the primary case should be:

if (void) {}
1reaction
albertocommented, Aug 2, 2016

👍

Read more comments on GitHub >

github_iconTop Results From Across the Web

no-constant-condition - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >
ecmascript 6 - while(1) in JavaScript - Stack Overflow
A constant expression (for example, a literal) as a test condition might be a typo or development trigger for a specific behavior.
Read more >
Linter rules - Dart
Conditions should not unconditionally evaluate to true or to false . This rule is currently deprecated and available as of Dart 2.0.0.
Read more >
Don't use non-test constants in unit tests - DEV Community ‍ ‍
One reason not to do this is that it creates a situation where when production code is refactored, tests will unnecessarily get refactored ......
Read more >
void operator - JavaScript - MDN Web Docs
The void operator evaluates the given expression and then returns ... from undefined to true will not change the behavior of this code....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found