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

Remove unnecessary await in returns from async functions #2788

Conversation

wbinnssmith
Copy link
Contributor

See #2705 and #2707 for rationale.

Test Plan: lint, flow, and test. Run the simple example and verify its output.

This sets violations of the `no-return-await` to `error`. `return await` is redundant as values returned from an async function are effectively wrapped in a `Promise.resolve`, and awaiting another promise in addition to this will defer resolution another microtick.

[eslint is good enough to detect the valid use case of `return await` in a `try`/`catch`](https://eslint.org/docs/rules/no-return-await). We also get clever with a short circuiting `||` in `Resolver` so I disabled it there, but we should probably rewrite it to be clearer in the future.

Test Plan: `yarn && yarn lint && yarn test`
@wbinnssmith wbinnssmith changed the base branch from v2-work-so-far to wbinnssmith/cherry-pick-windows-test-await March 13, 2019 17:53
@wbinnssmith
Copy link
Contributor Author

This also cherry-picks enabling the lint rule from master.

@padmaia padmaia merged commit 71a7125 into wbinnssmith/cherry-pick-windows-test-await Mar 13, 2019
@padmaia padmaia deleted the wbinnssmith/v2-no-return-await branch March 13, 2019 22:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants