False positive for `no-misused promises`

Minimal reproduction:

Promise.resolve().finally(async () => {
  return;
});

Error:
**
Promise returned in function argument where a void return was expected. (sonarjs/no-misused-promises)**

Returning Promise in function given as argument to finally method is actually valid and works as expected under ES specification, as result of call is awaited.

ECMAScript® 2026 Language Specification

      i. Let result be ? Call(onFinally, undefined).
      ii. Let p be ? PromiseResolve(C, result).

It’s pretty likely that Promise.prototype.finally should be special-cased to allow this.

1 Like

Thanks for reporting this. Indeed I agree .finally() should be treated exactly like .then().

I created a ticket to fix this.

Cheers