no-useless-catch
JavaScript / TypeScriptsuspiciousno fixdefault: offjs/eslint-recommendedjs/biome-recommendedjs/oxlint
What it does
Section titled “What it does”Reports a catch clause whose only statement is throw of the caught error, as in catch (e) { throw e; }. It is also reported when the try has a finally. A catch that does more, or that throws something else, is not reported.
Why it matters
Section titled “Why it matters”A catch that only rethrows has the same effect as no catch: the error goes on up with its stack, so the clause is noise that makes a reader look for handling that is not there.
To fix, delete the catch (keep the finally, if there is one) or handle the error there.
Example
Section titled “Example”...try { f(); } catch (e) { throw e; }try { f(); } catch (e) { throw e; } finally { g(); }try { f(); } catch (e) { throw g; }switch (a) {}function f() {}...Configuration
Section titled “Configuration”js: lint: rules: no-useless-catch: warn # off (default), warn, errorEnabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.
Suppress one line with sudsy-disable-next-line no-useless-catch in a comment of the file’s language.
Upstream equivalents
Section titled “Upstream equivalents”The same check in other tools; Sudsy reports what each upstream rule reports.
| Tool | Rule | Match |
|---|---|---|
| eslint | no-useless-catch |
full |