eslint-plugin-promise icon indicating copy to clipboard operation
eslint-plugin-promise copied to clipboard

Rule for disallowing calling catch without any argument

Open sonnyp opened this issue 5 years ago • 0 comments

I would like to suggest a rule to prevent calling the promise catch method without any argument. It works "differently" than the catch block and it might lead to bugs when one expects the rejection to be ignored.

Demonstration

async function iReject() {
  throw 'foobar';
}

(async () => {
  try {
    await iReject();
  } catch {
    // fine
  }

  // fine
  await iReject().catch(() => {});

  // throws
  await iReject().catch();
})();

sonnyp avatar Oct 28 '20 14:10 sonnyp