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/promise-function-async/
Description
I am finding cases in my code where it accidentally is returning undefined or some other guard type (null, etc) from a function that we expected to be async, but the rule promise-function-async is not flagging those as I expected it to (allowing us to catch those mistakes).
Please add an option to promise-function-async
that will allow it to flag any function that returns promises at all, either as the main return type, or as a union containing promises.
Fail
function getSomething(id?: string) {
if (!id) {
return undefined
}
return db.getByID(id)
}
Pass
async function getSomething(id?: string) {
if (!id) {
return undefined
}
return db.getByID(id)
}
Additional Info
There is an issue for the opposite of my request, #1005. I’d like that feature back (probably behind an option, seeing as it was designated as a bug before).