Struct rslint_core::groups::errors::NoUnsafeFinally [−][src]
pub struct NoUnsafeFinally {}
Expand description
Forbid the use of unsafe control flow statements in try and catch blocks.
JavaScript suspends any running control flow statements inside of try
and catch
blocks until
finally
is done executing. This means that any control statements such as return
, throw
, break
,
and continue
which are used inside of a finally
will override any control statements in try
and catch
.
This is almost always unexpected behavior.
Incorrect Code Examples
// We expect 10 to be returned, but 5 is actually returned
function foo() {
try {
return 10;
// ^^^^^^^^^ this statement is executed, but actually returning is paused...
} finally {
return 5;
// ^^^^^^^^^ ...finally is executed, and this statement returns from the function, **the previous is ignored**
}
}
foo() // 5
Throwing errors inside try statements
// We expect an error to be thrown, then 5 to be returned, but the error is not thrown
function foo() {
try {
throw new Error("bar");
// ^^^^^^^^^^^^^^^^^^^^^^^ this statement is executed but throwing the error is paused...
} finally {
return 5;
// ^^^^^^^^^ ...we expect the error to be thrown and then for 5 to be returned,
// but 5 is returned early, **the error is not thrown**.
}
}
foo() // 5
Implementations
Trait Implementations
Check an individual node in the syntax tree.
You can use the match_ast
macro to make matching a node to an ast node easier.
The reason this uses nodes and not a visitor is because nodes are more flexible,
converting them to an AST node has zero cost and you can easily traverse surrounding nodes.
Defaults to doing nothing. Read more
Check an individual token in the syntax tree. Defaults to doing nothing. Read more
Check the root of the tree one time.
This method is guaranteed to only be called once.
The root’s kind will be either SCRIPT
or MODULE
.
Defaults to doing nothing. Read more
Returns the “default value” for a type. Read more
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
A list of tags present on this rule. Empty by default.
Whether this rule is recommended, this is a simple helper around Self::tags
.
Auto Trait Implementations
impl RefUnwindSafe for NoUnsafeFinally
impl Send for NoUnsafeFinally
impl Sync for NoUnsafeFinally
impl Unpin for NoUnsafeFinally
impl UnwindSafe for NoUnsafeFinally
Blanket Implementations
Mutably borrows from an owned value. Read more
Whether this implementor has acknowledged the 1.1.0 update to
unerase
’s documented implementation requirements. Read more