Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Latest commit

 

History

History
40 lines (31 loc) · 1.25 KB

noConstantConditionRule.md

File metadata and controls

40 lines (31 loc) · 1.25 KB

no-constant-condition (ESLint: no-constant-condition)

rule_source test_source

disallow use of constant expressions in conditions (recommended)

Rationale

A constant expression (for example, a literal) as a test condition might be a typo or development trigger for a specific behavior. For example, the following code looks as if it is not ready for production.

Config

  • "checkLoops" Setting this option to false allows constant expressions in loops (default: true).

Examples

"no-constant-condition": true
"no-constant-condition": [true, { "checkLoops": false }]

Schema

{
  "type": "object",
  "properties": {
    "checkLoops": {
      "type": "boolean"
    }
  },
  "additionalProperties": false
}