absolute/no-useless-catch
Disallow catch blocks that contain only comments or no-op statements.
#Rule Details
Disallows catch blocks that do not do real work. Core ESLint’s no-empty rule allows comment-only blocks, which makes it easy for generated code to silence an error path with // ignore while still swallowing the exception. This rule treats comments as non-work and requires the catch body to handle, propagate, or record the failure.
The rule reports empty blocks, comment-only blocks, EmptyStatements, and expression statements with no side effect such as error;, error.message;, or void error;. It allows statements that change control flow or have observable effects: throw, return, function calls, assignments, updates, declarations, and other real statements.
#Examples
try {
await save();
} catch (error) {
// ignore
}No-op expressions are not handling
try {
await save();
} catch (error) {
error;
error.message;
void error;
}Rethrow the error
try {
await save();
} catch (error) {
throw error;
}Handle or record the failure
try {
await save();
} catch (error) {
console.error(error);
return null;
}try {
await save();
} catch (error) {
failed = true;
}#Configuration
Enable this rule in your ESLint configuration:
{
rules: {
'absolute/no-useless-catch': 'error'
}
}#Related Rules
#When Not To Use It
If a boundary intentionally swallows a failure, still prefer a real statement that records the decision, returns a fallback, or rethrows a wrapped error. Disable the rule only for code where silent failure is an explicit API contract.