no-unsafe-finally
NOTE: this rule is part of the
recommended rule set.Enable full set in
deno.json:{
"lint": {
"rules": {
"tags": ["recommended"]
}
}
}Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the
include or exclude array in deno.json:{
"lint": {
"rules": {
"include": ["no-unsafe-finally"],
"exclude": ["no-unsafe-finally"]
}
}
}Disallows the use of control flow statements within finally blocks.
Use of the control flow statements (return, throw, break and continue)
overrides the usage of any control flow statements that might have been used in
the try or catch blocks, which is usually not the desired behaviour.
Invalid:
let foo = function () {
try {
return 1;
} catch (err) {
return 2;
} finally {
return 3;
}
};
let foo = function () {
try {
return 1;
} catch (err) {
return 2;
} finally {
throw new Error();
}
};
Valid:
let foo = function () {
try {
return 1;
} catch (err) {
return 2;
} finally {
console.log("hola!");
}
};