# promise/no-return-in-finally

> Disallow `return` in a `finally()` callback

The chain ignores the value a `finally()` callback returns. The next step gets the result from before the `finally()`, so the returned value is lost.

The rule reports a `return` statement at the top level of the callback's body. An arrow function without braces isn't reported.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"promise/no-return-in-finally" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
loadItems()
  .finally(() => {
    hideSpinner();
    return "done";
  })
  .then(result => console.log(result)); // the items, not "done"
```

Not reported:

{/* good */}
```js
loadItems()
  .finally(() => {
    hideSpinner();
  })
  .then(items => console.log(items));

loadItems().finally(() => hideSpinner());
```

Returning a promise does have an effect, because the chain waits for it. The rule reports that `return` too.

{/* bad */}
```js
query(sql).finally(() => {
  return connection.close();
});
```

Use `await` instead:

{/* good */}
```js
query(sql).finally(async () => {
  await connection.close();
});
```
