Rejection swallowed
This is how the comment reads inline, under the flagged line.
Why it matters
An empty .catch turns every failure into silent success. The bug shows up later, far from the cause, with no log.
What to do
Let it reject, handle the specific error you expect, or log and rethrow.
Examples
save(user).catch(() => {});await save(user); // the caller decides what a failure means
What it catches
It reads a pattern on each line, aware of strings and comments. Languages: TypeScript and JavaScript. Scope: All files. These cases are the rule's own tests: the first set must be flagged and the second must not.
Flagged
save(x).catch(() => {});load().catch(() => null)
p.catch(noop)
Left alone
save(x).catch((e) => report(e));
Research
Empty catch, `except: pass`, `.catch(() => {})`, and catch blocks that only log. The failure disappears from the person who could fix it.
- Ruff: try-except-pass
- Taxonomy: swallowed exceptions
- skill: code-review
Turn it off or change it
In a config file for the CLI, or in the API's rules field:
{
"rules": {
"disable": [
"promise-catch-noop"
],
"severity": {
"promise-catch-noop": "low"
}
}
}
.catch(() => {})throws the error away. When this fails, nothing will say so.