eslint-community / eslint-plugin-promise

Enforce best practices for JavaScript promises

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rule for disallowing calling catch without any argument

sonnyp opened this issue · comments

commented

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();
})();