# prefer-promise-shorthand

Rule `sonarjs/prefer-promise-shorthand`. Shorthand promises should be used

- Source: sonarjs
- Technologies: JavaScript
- Kind: style
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1346 by reach, #647 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/prefer-promise-shorthand` | yes | suggestion | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-4634/) |

## Code examples

### Incorrect: the rule reports this

```js
let fulfilledPromise = new Promise(resolve => resolve(42));
let rejectedPromise = new Promise(function(resolve, reject) {
  reject('fail');
});
```

### Correct: the rule accepts this

```js
let fulfilledPromise = Promise.resolve(42);
let rejectedPromise = Promise.reject('fail');
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/prefer-promise-shorthand": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/prefer-native-lodash-alternative](https://lintradar.dev/rules/sonarjs/prefer-native-lodash-alternative.md): Native APIs should be preferred over Lodash and Underscore.js methods
- [sonarjs/prefer-read-only-props](https://lintradar.dev/rules/sonarjs/prefer-read-only-props.md): React props should be read-only
- [sonarjs/prefer-native-jquery-alternative](https://lintradar.dev/rules/sonarjs/prefer-native-jquery-alternative.md): Native APIs should be preferred over jQuery utility methods
- [sonarjs/prefer-regexp-exec](https://lintradar.dev/rules/sonarjs/prefer-regexp-exec.md): "RegExp.exec()" should be preferred over "String.match()"
- [sonarjs/prefer-native-axios-alternative](https://lintradar.dev/rules/sonarjs/prefer-native-axios-alternative.md): Native APIs should be preferred over Axios utility methods
- [sonarjs/prefer-single-boolean-return](https://lintradar.dev/rules/sonarjs/prefer-single-boolean-return.md): Return of boolean expressions should not be wrapped into an "if-then-else" statement

---

Web page: https://lintradar.dev/rules/sonarjs/prefer-promise-shorthand. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
