promise/no-new-statics

Disallow new on static Promise methods such as Promise.all

fixable

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#

example.js1 problem
async function loadPage() {
  return await new Promise.all([loadUser(), loadOrders()]);
}
example.jsNo problems
async function loadPage() {
  return await Promise.all([loadUser(), loadOrders()]);
}