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

pub struct NoAsyncPromiseExecutor {}

Disallow async functions as promise executors.

Promise executors are special functions inside new Promise() constructors which take a resolve and reject parameter to resolve or reject the promise. The function is a normal function therefore it could be an async function. However this is usually wrong because: - Any errors thrown by the function are lost. - It usually means the new promise is unnecessary.

Incorrect code examples

let foo = new Promise(async (resolve, reject) => {
    doSomething(bar, (err, res)) => {
       /* */
    });
});
let foo = new Promise(async function(resolve, reject) => {
    /* */
});

Correct code examples

Use a normal non-async function.

let foo = new Promise(function(resolve, reject) => {
    /* */
})

Implementations

impl NoAsyncPromiseExecutor[src]

pub fn new() -> Self[src]

Trait Implementations

impl Clone for NoAsyncPromiseExecutor[src]

impl CstRule for NoAsyncPromiseExecutor[src]

impl Debug for NoAsyncPromiseExecutor[src]

impl Default for NoAsyncPromiseExecutor[src]

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

impl Rule for NoAsyncPromiseExecutor[src]

impl Serialize for NoAsyncPromiseExecutor[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.