quick-lint-js

Find bugs in JavaScript programs.

E0138: missing condition for if statement

An if statement has a condition which determines whether the body will execute or not. It is an error to omit an if statement's condition:

let firstName = person.firstName;
let lastName = person.lastName;
if {
  firstName = lastName;
}

To fix this error, write the condition with parentheses after the if keyword:

let firstName = person.firstName;
let lastName = person.lastName;
if (firstName === "") {
  firstName = lastName;
}

Introduced in quick-lint-js version 0.2.0.

Documentation for other errors