Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rule for disallowing calling catch without any argument #207

Open
sonnyp opened this issue Oct 28, 2020 · 0 comments
Open

Rule for disallowing calling catch without any argument #207

sonnyp opened this issue Oct 28, 2020 · 0 comments

Comments

@sonnyp
Copy link

sonnyp commented Oct 28, 2020

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();
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants