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

Should scope of prefer-await-to-then rule be limited to functions? #122

Closed
MrSwitch opened this issue Mar 27, 2018 · 3 comments · Fixed by #126
Closed

Should scope of prefer-await-to-then rule be limited to functions? #122

MrSwitch opened this issue Mar 27, 2018 · 3 comments · Fixed by #126

Comments

@MrSwitch
Copy link

MrSwitch commented Mar 27, 2018

Description

I'm just wondering if the scope of prefer-await-to-then should be limited to functions.

// Valid, case for await, has to be in a function
a = async () => (await something())

// However this is invalid Await apparently can't be in the root
a = await something(); // invalid

// So we have to use `.then`, however it gets caught in the prefer-await-to-then rule
something().then(a => {...})

Expected behavior:

Scope of prefer-await-to-then should be limited to functions

@MrSwitch MrSwitch changed the title Should prefer-await-to-then just isolated to a function? Should scope of prefer-await-to-then rule be limited to within functions? Mar 27, 2018
@MrSwitch MrSwitch changed the title Should scope of prefer-await-to-then rule be limited to within functions? Should scope of prefer-await-to-then rule be limited to functions? Mar 27, 2018
@macklinu
Copy link
Contributor

Ah, this case makes sense. I think it'd be good to revisit this rule and add support for what you're expressing. 👍

@simonhaenisch
Copy link

any idea when this will be merged?

@macklinu
Copy link
Contributor

I'll follow up with issues and PRs today and see what I can ship as a minor or patch release.

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

Successfully merging a pull request may close this issue.

3 participants