✅ This rule is included in the performance preset.
Using await inside a loop causes each iteration to wait for the previous iteration to complete before starting the next one.
This sequential execution can significantly slow down your code when the awaited operations are independent and could be executed in parallel.
Consider collecting promises in an array during the loop and then using Promise.all() to await all of them in parallel.
This allows all the asynchronous operations to run concurrently, which is typically much faster than running them one at a time.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
Calls a defined callback function on each element of an array, and returns an array that contains the results.
@param ― callbackfn A function that accepts up to three arguments. The map method calls the callbackfn function one time for each element in the array.
@param ― thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
If your asynchronous operations must be executed sequentially you may wish to disable this rule for those specific cases.
For example, if each operation depends on the result of the previous one, or if you need to avoid overwhelming a rate-limited API, parallel calls may not be an option.