no-await-in-sync-fn
NOTE: this rule is part of the
recommended
rule set.Enable full set in
deno.json
:{ "lint": { "tags": ["recommended"] } }
Enable full set using the Deno CLI:
deno lint --tags=recommended
Disallow await
keyword inside a non-async function.
Using the await
keyword inside a non-async function is a syntax error. To be
able to use await
inside a function, the function needs to be marked as async
via the async
keyword.
Invalid:
function foo() {
await bar();
}
const fooFn = function foo() {
await bar();
};
const fooFn = () => {
await bar();
};
Valid:
async function foo() {
await bar();
}
const fooFn = async function foo() {
await bar();
};
const fooFn = async () => {
await bar();
};