包详细信息

eslint-plugin-no-await-in-promise

hugo-vrijswijk32.5kMIT3.0.0

ESLint Plugin to error when using await inside promise statements

eslint, eslintplugin, eslint-plugin

自述文件

eslint-plugin-no-await-in-promise

npm

ESLint Plugin to error when using await inside promise statements. Using await inside a Promise.all or Promise.race will make the awaited Promise resolve first, and only after that the Promise.all or Promise.race will be called. For .all, this means the promises are run serially, for .race, the awaited promise will now always win. This is rarely what you want. This plugin will warn you against such usages and suggest an auto-fix.

Rule Details

Examples of incorrect code for this rule:

await Promise.all([await foo(), bar()]);
await Promise.race([foo(), await bar()]);

Examples of correct code for this rule:

await Promise.all([foo(), bar()]);
await Promise.race([foo(), bar()]);

Installation

You'll first need to install ESLint:

npm i eslint --save-dev
# Or
yarn add -D eslint
# Or
pnpm add -D eslint

Next, install eslint-plugin-no-await-in-promise:

npm install eslint-plugin-no-await-in-promise --save-dev
# Or
yarn add -D eslint-plugin-no-await-in-promise
# Or
pnpm add -D eslint-plugin-no-await-in-promise

Usage (flat config)

Configure the plugin in your eslint.config.js:

import noAwaitInPromise from 'eslint-plugin-no-await-in-promise';

export default [
  noAwaitInPromise.configs.recommended,
  // Other plugins here
];

更新日志

Changelog

3.0.0 (2025-06-25)

⚠ BREAKING CHANGES

  • Remove legacy recommended-legacy config. Only support ESLint >=9 and Node >=20.

Miscellaneous Chores

  • remove deprecated legacy config and only build ESM (#549) (428e016)

2.0.1 (2024-05-24)

Bug Fixes

  • fix legacy eslint configuration not working (#331) (adfaee5), closes #329

2.0.0 (2024-05-15)

⚠ BREAKING CHANGES

  • support new flat config (#322)

Features

1.1.6 (2023-12-05)

Bug Fixes

  • release-please manifest for v4 (bc814ca)

1.1.5 (2023-06-28)

Bug Fixes

  • remove types from package.json (adbefe6)

1.1.4 (2023-06-28)

Bug Fixes

  • add types to package exports (992814e)

1.1.3 (2023-04-20)

Bug Fixes

  • use provenance for releases (a78a620)

1.1.2 (2023-01-19)

Bug Fixes

1.1.1 (2022-08-16)

Bug Fixes

  • rule is now fixable instead of a suggestion (557127d)

1.1.0 (2022-08-15)

Features

  • cross-build to ES modules and CommonJS (334f0a3)

Bug Fixes

  • update lint rule message (ffecaf9)

1.0.1 (2022-08-15)

Bug Fixes

  • rule: properly setup rule inside plugin (c2a46f6)

1.0.0 (2022-08-15)

Features

  • add recommended config and update readme installation guide (aec457a)

Miscellaneous Chores