Closed
Description
Before You File a Proposal Please Confirm You Have Done The Following...
- I have searched for related issues and found none that match my proposal.
- I have searched the current rule list and found no rules that match my proposal.
- I have read the FAQ and my problem is not listed.
My proposal is suitable for this project
- I believe my proposal would be useful to the broader TypeScript community (meaning it is not a niche proposal).
Link to the rule's documentation
https://typescript-eslint.io/rules/return-await
Description
The current in-try-catch
option handles two separate concerns
- Correctness - requiring
await
where it impacts control flow (due totry-catch-finally
) - Stylistic - forbidding
await
elsewhere
I would propose for there to be a rule option that handles only the correctness portion. That is to say, it should enforce await
wherever in-try-catch currently does, but not report where in-try-catch
forbids await
.
Fail
// same as in-try-catch
async function f() {
try {
return returnsPromise();
} catch { }
}
Pass
async function f() {
return returnsPromise();
}
async function f() {
return await returnsPromise();
}
// same as in-try-catch
async function f() {
try {
return await returnsPromise();
} catch { }
}
Additional Info
I think this would be valuable in order to be able to recommend a less disruptive version of the rule in a preset, see #8667