eslint-plugin-no-await-in-promise
v3.0.1
Published
ESLint Plugin to error when using await inside promise statements
Downloads
180,405
Maintainers
Readme
eslint-plugin-no-await-in-promise
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 eslintNext, 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-promiseUsage (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
];