Skip to content

Rule for disallowing calling catch without any argument #207

@sonnyp

Description

@sonnyp

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions