Skip to content

Commit 75f4c00

Browse files
author
blond
committed
docs: add example for no-unsafe-finally rule
1 parent e3999c0 commit 75f4c00

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

examples/bad/overwrite.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,14 @@ try {
88
} catch (e) {
99
e = 10; // Overwrite the reference to the error.
1010
}
11+
12+
/*eslint no-unsafe-finally: "error"*/
13+
(() => {
14+
try {
15+
return 1; // 1 is returned but suspended until finally block ends
16+
} catch(err) {
17+
return 2;
18+
} finally {
19+
return 3; // 3 is returned before 1, which we did not expect
20+
}
21+
})(); // We expect this function to return 1, but result is 3.

0 commit comments

Comments
 (0)