quick-lint-js

Find bugs in JavaScript programs.

E0092: switch statement is missing '(' or ')' around condition

switch statements have a condition after the switch keyword. It is a syntax error to write a condition without either ( or ):

function colorToHexCode(color) {
  switch (color {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

To fix this error, write ( before the condition or ) after the condition:

function colorToHexCode(color) {
  switch (color) {
    case 'red':   return '#ff0000';
    case 'green': return '#00ff00';
    case 'blue':  return '#0000ff';
  }
}

Documentation for other errors