Skip to content

No Discarded Rejection

Suggestion
small-rules/no-discarded-rejection

Warn when a Promise rejection handler explicitly discards the failure and resolves to undefined.

Rationale

An empty catch turns a Promise that didn’t work into a Promise whose value is undefined. The miss is hidden. You do not log it, and you do not give a fallback.

The rule warns on the empty forms. It does not add a throw. It only follows a Promise it can see from the syntax and the scope. To hide one on purpose, use an oxlint-disable comment and say why.

Diagnostic Messages

noDiscardedRejection
This rejection handler discards the failure without recording it or recovering from it.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-discarded-rejection": "warn"
}
}

Examples

discarded Promise rejection
Promise.resolve(request()).catch(() => undefined);
recorded Promise rejection
Promise.resolve(request()).catch((exception) => { logFailure(exception); });