Linter · Rules
promise/no-new-statics
Disallow new on static Promise methods such as Promise.all
Promise.all, Promise.resolve and the other static methods are plain functions, not constructors. Calling one with new throws a TypeError at run time.
The rule covers all, allSettled, any, race, reject, resolve, try and withResolvers.
--fix removes the new.
Configure
Off by default. To turn it on:
bunfig.toml
[lint.rules]
"promise/no-new-statics" = "error" # or "warn"
Examples
Reported:
async function loadPage() {
return await new Promise.all([loadUser(), loadOrders()]);
}
Not reported:
async function loadPage() {
return await Promise.all([loadUser(), loadOrders()]);
}