Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new rule to warn about async functions without await #80

Closed
ajafff opened this issue Feb 21, 2018 · 2 comments
Closed

Add new rule to warn about async functions without await #80

ajafff opened this issue Feb 21, 2018 · 2 comments

Comments

@ajafff
Copy link
Member

ajafff commented Feb 21, 2018

This rule requires at least one await expression in the function body.
@AlCalzone suggested such a rule in microsoft/TypeScript#22024

This rule would not advertise fixes, because async functions automagically catch sync exceptions and convert them to rejected promises. Removing the async modifier during fixing could change the runtime behavior of the function.

@ajafff
Copy link
Member Author

ajafff commented Feb 21, 2018

The implementation is not the hard part. But this rule needs a good name.
ESLint has require-await, but one could think it's somehow about require().

@ajafff
Copy link
Member Author

ajafff commented Feb 24, 2018

Because of the implicit catching of sync exceptions in async functions, there's actually no way to detect if the async modifier is unnecessary. Ergo this rule does not prevent any programmer error but will lead to a lot of confusion as the runtime behavior changes.
That said and given the arguments in eslint/eslint#10000 I'm not convinced this rule needs to be part of the core library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant