AbsoluteJS

absolute/no-useless-catch

Disallow catch blocks that contain only comments or no-op statements.

Code QualityProblem
View on GitHub

#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

Incorrect
TS
try {
	await save();
} catch (error) {
	// ignore
}

No-op expressions are not handling

TS
try {
	await save();
} catch (error) {
	error;
	error.message;
	void error;
}
Correct

Rethrow the error

TS
try {
	await save();
} catch (error) {
	throw error;
}

Handle or record the failure

TS
try {
	await save();
} catch (error) {
	console.error(error);
	return null;
}
TS
try {
	await save();
} catch (error) {
	failed = true;
}

#Configuration

Enable this rule in your ESLint configuration:

JS
{
	rules: {
		'absolute/no-useless-catch': 'error'
	}
}

#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.

#Resources