requireYodaConditions

Requires the variable to be the right hand operator when doing a boolean comparison

Types: Array or Boolean

Values:

  • true specifies that yoda conditions are required for most possible comparison operators
  • Array: represents the list of quoted operators that requires yoda conditions

Example

"requireYodaConditions": true
"requireYodaConditions": [
    "==",
    "===",
    "!=",
    "!=="
]
Valid for mode true or ['==']
if (1 == a) {
    return
}
Invalid for mode true or ['==']
if (a == 1) {
    return
}
Rule source
Test source