eslint-plugin-no-floating-promise weekly downloads statistics
By SebastienGllmt · npm · ESLint plugins
Detects missing await on async function calls
eslint-plugin-no-floating-promise has 20,353 recorded weekly downloads on npm, a decrease of 58.4% over the past 30 days, ranking #787 of 2,391 tracked listings.
About eslint-plugin-no-floating-promise
eslint-plugin-no-floating-promise
Detects missing await on async function calls
STOP: Are you a Flow or a Typescript user? Prefer these:
Installation
You'll first need to install ESLint:
$ npm i eslint --save-dev
Next, install eslint-plugin-no-floating-promise:
$ npm install eslint-plugin-no-floating-promise --save-dev
Note: If you installed ESLint globally (using the -g flag) then you must also install eslint-plugin-no-floating-promise globally.
Usage
Add no-floating-promise to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix:
{
"plugins": [
"no-floating-promise"
]
}
Then configure the rules you want to use under the rules section.
{
"rules": {
"no-floating-promise/no-floating-promise": 2
}
}
If you're using flat config (eslint.config.js), which is default configuration format for eslint since v.9.0.0:
const noFloatingPromise = require("eslint-plugin-no-floating-promise");
module.exports = [
{
plugins: {
"no-floating-promise": noFloatingPromise,
},
rules: {
"no-floating-promise/no-floating-promise": 2
}
}
];
Rule definition
The --fix option on the command line automatically fixes problems reported by this rule.
Promises that are never awaited can cause unexpected behavior because they may be scheduled to execute at an unexpected time.
It's easy to accidentally make this mistake. For example, suppose we have the code
function writeToDb() {
// synchronously write to DB
}
writeToDb();
but the code gets refactored so that writing to the database is asynchronous.
async function writeToDb() {
// asynchronously write to DB
}
writeToDb(); // <- note we have no await here but probably the user intended to await on this!
Rule Details
This rule will fire for any call to an async function that both
- not used (not assigned to a variable, not the return type of a function, etc.)
- not awaited on
Examples of incorrect code for this rule:
/*eslint no-floating-promise: "error"*/
async function foo() {}
foo();
(async () => 5)();
// note: function is not async but a Promise return type is specified
function foo(): Promise<void> { return Promise.resolve(); };
foo();
Examples of correct code for this rule:
/*eslint no-floating-promise: "error"*/
async function foo() {}
await foo();
await (async () => 5)();
// note: function is not async but a Promise return type is specified
function foo(): Promise<void> { return Promise.resolve(); };
await foo();
// note: promise is not awaited, but it is chained with a 'then'
async function foo() {}
foo().then(() => {});
You may catch additional errors by combining this rule with no-unused-expression.
For example the following will not be considered an error by this plugin, but no-unused-expression will complain that fooResult is never used.
async function foo() {}
const fooResult = foo();
When Not To Use It
If you often make use of asynchronous functions were you explicitly do not want to await on them.
Notable design decisions
Promises returned by non-async functions
It's possible for a function to return a promise and not be async (as seen in test cases for this rule). My rule can leverage type annotations to detect these cases but if no type annotation is present, then no error is reported. We could modify this rule to traverse into the AST to see if the return is a promise or not but this sounds more expensive and would still not catch all cases so I didn't include this logic.
Additionally, TypeAnnotations are only generated for explicit Flow types so this rule can't take advantage of Flow inference. You could argue this rule would be more effective if implemented directly in Flow but this rule can still catch cases for vanilla Javascript so it didn't feel right to make Flow a dependency for this kind of linting.
Scope of the rule
Currently using then or catch silences this rule
async function foo() {}
foo().then(() => {});
You could argue this is desired since it avoids false-positive where developers explicitly do not want to await. I'm open to feedback about whether or not people want this behavior.
Missing await in non-async context
Right now my rule reports an error in the following case
async function foo() {}
function bar() {
foo();
}
However, adding an await here is not possible because bar is not an async function. In fact, my auto-fix rule would add an await in front of foo which would result in a compiler error.
However, likely this actually is an error and the user actually should make bar an async function. However, I am open to disabling this rule in this context if that's what people want.
Limitations
- It cannot make use of Flow inference (you need to explicitly specify types)
- It does not work across file boundaries (if import a function from a different file, you don't have any information)
- It doesn't work on member function calls (
foo.bar()will not detect an error even ifbaris an async function)
Description from the npm listing.
- eslint
- eslintplugin
- eslint-plugin
- Flow
- async
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (122)Similar npm ESLint plugins plugins
All 20 eslint-plugin-no-floating-promise alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/eslint-plugin-no-floating-promise. First seen Oct 16, 2026; last successful collection Oct 21, 2026. See the methodology.