Skip to main content

no-await-in-sync-fn

NOTE: this rule is part of the recommended rule set.
Enable full set in deno.json:
{ "lint": { "rules": { "tags": ["recommended"] } } }
Enable full set using the Deno CLI:
deno lint --rules-tags=recommended
This rule can be explictly included to or excluded from the rules present in the current tag by adding it to the include or exclude array in deno.json:
{ "lint": { "rules": { "include": ["no-await-in-sync-fn"], "exclude": ["no-await-in-sync-fn"] } } }

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(); }; 

Did you find what you needed?