Rule proposal: typescript-eslint version of the base [require-await] rule #669
Labels
enhancement: new base rule extension
New base rule extension required to handle a TS specific case
has pr
there is a PR raised to close this
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
Repro
Given the following config, it seems that there is an unresolvable conflict:
A function that returns a promise, such as:
..triggers
@typescript-eslint/promise-function-async
with the warning:Adding the
async
keyword:..then triggers
require-await
with the warning:Finally, adding the
await
keyword:..then triggers
no-return-await
with the warning:Expected Result
No errors
Actual Result
(see repro above)
Additional Info
Individually, each of the configured rules address a legitimate problem. But together they appear to be mutually exclusive.
Over in ESlint core, there was a discussion on whether an
async
function that returns the result of anotherasync
function should be allowed to omit theawait
keyword without triggeringrequire-await
.As @kaicataldo points out though, it isn’t really possible because ESLint is constrained by the limits of static analysis, and suggests that the help of a typing system (e.g Typescript) would be needed to implement this exception.
Hence I’m raising the issue here, to gather feedback on whether this implies the need for a
@typescript-eslint/require-await
version of the base rule.Versions
@typescript-eslint/eslint-plugin
1.10.2
@typescript-eslint/parser
1.10.2
TypeScript
3.5.1
ESLint
5.16.0
node
12.1.0
npm
6.9.0
The text was updated successfully, but these errors were encountered: