ESLint Rule: No Floating Promises


Updated Jun 6th, 2022

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the void operator.

Certain methods accessible on the router object return a Promise. If you have the ESLint rule, no-floating-promises enabled, consider disabling it either globally, or for the affected line.

another example of how breaking a function definition out of the useEffect causes errors. Now there is seemingly a three way conflict of errors.

Putting void in front of the function call in the useEffect does the trick.

Read the next docs related to the router here.

This fixed for this rule seem whacky. Need to put “await” keyword in front of client.close() and router.push() and the “void” keyword in front of function calls?

Can also put “void” in front of router.push, especially helpful if not inside an asyn function, per this stack overflow here

or the one liner to Disable the rule for this specific line

// eslint-disable-next-line @typescript-eslint/no-floating-promises