[][src]Struct rslint_core::groups::errors::NoUnsafeFinally

pub struct NoUnsafeFinally {}

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

impl NoUnsafeFinally[src]

pub fn new() -> Self[src]

Trait Implementations

impl Clone for NoUnsafeFinally[src]

impl CstRule for NoUnsafeFinally[src]

impl Debug for NoUnsafeFinally[src]

impl Default for NoUnsafeFinally[src]

impl<'de> Deserialize<'de> for NoUnsafeFinally[src]

impl Rule for NoUnsafeFinally[src]

impl Serialize for NoUnsafeFinally[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> DynClone for T where
    T: Clone
[src]

impl<T> Erasable for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Serialize for T where
    T: Serialize + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.