Struct rslint_core::groups::errors::NoAwaitInLoop [−][src]
pub struct NoAwaitInLoop {}
Expand description
Disallow await inside of loops.
You may want to await
a promise until it is fulfilled or rejected, inside of loops. In such cases, to take
full advantage of concurrency, you should not await
the promise in every iteration, otherwise your async
operations will be executed serially.
Generally it is recommended that you create all promises, then use Promise.all
for them. This way your async
operations will be performed concurrently.
Incorrect Code Exapmles
async function foo(xs) {
const results = [];
for (const x of xs) {
// iteration does not proceed until `bar(x)` completes
results.push(await bar(x));
}
return baz(results);
}
Correct Code Examples
async function foo(xs) {
const results = [];
for (const x of xs) {
// push a promise to the array; it does not prevent the iteration
results.push(bar(x));
}
// we wait for all the promises concurrently
return baz(await Promise.all(results));
}
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 NoAwaitInLoop
impl Send for NoAwaitInLoop
impl Sync for NoAwaitInLoop
impl Unpin for NoAwaitInLoop
impl UnwindSafe for NoAwaitInLoop
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