no-unsafe-finally
What it does
Section titled “What it does”Reports return, throw, and a break or continue that leaves the finally block, written in a finally. A break or continue of a loop inside the block, and a return in a function declared in the block, are not reported.
Why it matters
Section titled “Why it matters”A jump out of finally replaces how the try ended: a return there discards the value returned by the try and swallows an exception that was being thrown, so errors disappear without a trace.
To fix, move the jump out of finally (after the try statement), or handle the error in a catch.
Example
Section titled “Example”function f() { try { a(); } finally { return 1; } }function g() { try { a(); } finally { throw e; } }function h() { for (;;) { try { a(); } finally { break; } } }function i() { try { a(); } finally { for (;;) { break; } } }function j() { try { a(); } finally { function k() { return 1; } } }function l() { l: try { a(); } finally { break l; } }function m() { try { a(); } finally { m: { break m; } } }...Configuration
Section titled “Configuration”js: lint: rules: no-unsafe-finally: warn # off, warn (default), errorEnabled by the presets: js/eslint-recommended, js/biome-recommended, js/oxlint.
Suppress one line with sudsy-disable-next-line no-unsafe-finally 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-unsafe-finally |
full |