Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 690 Bytes

no-async-await.md

File metadata and controls

22 lines (16 loc) · 690 Bytes

Disallow use of the async-await syntax (no-async-await)

The async-await syntax was introduced in ES8. In old browsers, this syntax is transpiled down to ES5, which can cause performance issues if the code is executed many times. To ensure that code performs well even in old browsers, use a standard promise chain instead.

Rule details

Example of incorrect code:

async function fetchJSON(url) {
    const res = await fetch(url);
    return res.json();
}

Example of correct code:

function fetchJSON(url) {
    return fetch(url).then((res) => res.json());
}