Pattern: Use of async
/await
Issue: -
Using async
/await
syntax is disallowed. Use Promise-based approaches with .then() chains instead where asynchronous code is needed.
Example of incorrect code:
async function getData() {
const result = await fetch('/api');
return result.json();
}
const process = async () => {
await someAsyncOperation();
};
Example of correct code:
function getData() {
return fetch('/api')
.then(result => result.json());
}
const process = () => {
return someAsyncOperation()
.then(() => {});
};