floating-promise
An async call whose promise a statement drops: not awaited, returned, chained (.then(...), .catch(...), .finally(...)) or started on purpose with void, when it can't reject. On by default, as a warning.
Why: the caller goes on before the work is done: what it does next, and what its own caller does, may need the work finished. floating-rejection reports a dropped call that can reject, because its failure would reach nobody; this one reports the others, because nothing else does, and the day the function gains a failure, nobody is told to look at this call. void says the drop is on purpose, so a reader (and this rule) knows. Guide: Async.
❌ Rejected: the dialog closes, and the next screen reads the draft, before it is saved
✕ Rejectedfloating-promise
ts
type Draft = { readonly id: string; readonly text: string };
async function save(draft: Draft): Promise<void> {
await Promise.resolve();
console.log(`saved ${draft.id}: ${draft.text}`);
}
export function close(draft: Draft, hide: () => void): void {
save(draft);
hide();
}✅ Accepted: awaited where what follows needs it, or started on purpose
✓ Accepted0 diagnostics
ts
type Draft = { readonly id: string; readonly text: string };
async function save(draft: Draft): Promise<void> {
await Promise.resolve();
console.log(`saved ${draft.id}: ${draft.text}`);
}
export async function close(draft: Draft, hide: () => void): Promise<void> {
await save(draft);
hide();
}
// The dialog may close at once: nothing after it reads the draft.
export function closeNow(draft: Draft, hide: () => void): void {
void save(draft);
hide();
}Where it applies: a promise dropped as a statement, wherever the statement is: in a function of yours, a hook (onMounted, useEffect), a listener or a timer, the last one or not. No list of callers decides it; void does, where the drop is on purpose. Not a statement, and so not reported: the value of an arrow written without braces (() => refresh(), which hands the promise to whoever calls it), a function passed by name (onMounted(refresh), @click="refresh"), and a Vue template's handler (@click="refresh()"). Where those can fail, floating-rejection and uncaught-propagation speak.
✅ Accepted: started on purpose in a listener, and handed back by an arrow
✓ Accepted0 diagnostics
ts
async function reload(filter: string): Promise<void> {
await Promise.resolve();
console.log(`showing ${filter}`);
}
export function watchFilter(select: HTMLSelectElement, signal: AbortSignal): void {
select.addEventListener(
"change",
() => {
void reload(select.value);
},
{ signal },
);
select.addEventListener("focus", () => reload("all"), { signal });
}Why a warning: most dropped promises are deliberate. On a real project written by agents (about 760 files), the 168 void statements included 43 on project functions that can't reject; read one by one, all 43 were fire-and-forget on purpose (a list reloading itself after a filter changes, a dialog, a timer's poll, a background save), each with a comment saying why it never rejects, and none was an ordering defect. Without the void, each would have been this finding, and void is the one-word answer. The finding still means "say which one it is", and --deny-warnings makes it count.
Quick fixes: Add await (in an async function) · Start it on purpose with void.
What the rule can't see: a promise dropped somewhere other than a statement (an element of an array nobody reads, an argument of a function that ignores it); a call of a function the checker doesn't follow, or of one whose return type isn't written and isn't async. A dropped call that can reject is floating-rejection's, and one whose promise holds a Result is must-use-result's: each call gets one finding. A promise read as its value is promise-as-value.