quick-lint-js

Find bugs in JavaScript programs.

E0135: expected variable name for 'catch'

A try statement can have a catch clause. The catch clause can define a variable for the caught exception. It is a syntax error to write a string literal instead of a variable name between a catch clause's parentheses:

async function downloadURLWithRetries(url) {
  for (;;) {
    try {
      return await downloadURL(url);
    } catch ('ETIMEOUT') {
      // Loop and try again.
    }
  }
}

To fix this error, replace the string literal with a variable name:

async function downloadURLWithRetries(url) {
  for (;;) {
    try {
      return await downloadURL(url);
    } catch (e) {
      if (e.code === 'ETIMEOUT') {
        // Loop and try again.
      } else {
        throw e;
      }
    }
  }
}

Documentation for other errors