# promise/spec-only

> Disallow `Promise` static methods that are not part of the language

Libraries such as Bluebird add methods like `Promise.map` and `Promise.props`. The built-in `Promise` doesn't have them, so the call throws a `TypeError` wherever the library's `Promise` isn't the one in scope.

The rule allows `all`, `allSettled`, `any`, `race`, `reject`, `resolve`, `try` and `withResolvers`. It reports every other property read from `Promise`, called or not. That includes `Promise.prototype`.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"promise/spec-only" = "error" # or "warn"
```

Every option, set to its default:

```toml bunfig.toml
[lint.rules]
"promise/spec-only" = ["error", {
  allowedMethods = [], # list of strings
}]
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
const pages = await Promise.map(urls, url => fetch(url));
```

{/* bad */}
```js
const then = Promise.prototype.then;
```

Not reported:

{/* good */}
```js
const pages = await Promise.all(urls.map(url => fetch(url)));
```

## Options

| Option | Default | What it does |
| --- | --- | --- |
| `allowedMethods` | `[]` | More names to allow, for example from a polyfill. Names are case-sensitive. |

{/* good {"options": [{"allowedMethods": ["map", "prototype"]}]} */}
```js
const pages = await Promise.map(urls, url => fetch(url));
const then = Promise.prototype.then;
```

{/* bad {"options": [{"allowedMethods": ["map"]}]} */}
```js
const user = await Promise.props({ profile: loadProfile(), orders: loadOrders() });
```
