-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(eslint-config): enable return-await #4222
Conversation
@raymondfeng @strongloop/loopback-next WDYT, should we release this change as semver-major? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
馃憤 Agreed.
LGTM after fixing the existing code that breaks the rule.
Please fix the following violations:
|
7d0677b
to
81dba22
Compare
See the PR description:
The eslint fix was released in v2.10.0, we are good to proceed now. |
81dba22
to
02badb0
Compare
Hmm, it looks like there are still some false positives reported by eslint:
The code: Strangely enough, I am not able able to reproduce this on my local machine any more 馃 |
02badb0
to
360c9a0
Compare
BREAKING CHANGE: The linter will reject code using `return await` ouside of `try` blocks or forgetting to `await` before returning from inside a `try` block. Migration guide: use `return` outside of `try` blocks and `return await` inside `try` blocks. Signed-off-by: Miroslav Bajto拧 <mbajtoss@gmail.com>
This removes certain kind of linting errors that are reported on Travis but cannot be reproduced in a typical local setup where all packages are bootstrapped. Signed-off-by: Miroslav Bajto拧 <mbajtoss@gmail.com>
360c9a0
to
2e35a44
Compare
The problem mentioned by my previous comment was caused by the fact that on Travis CI, we did not bootstrap all packages. I am assuming that as a result, typescript-eslint did not have access to dependencies and therefore it used incorrect typings. In 2e35a44, I have modified our Travis CI job to run a full bootstrap before calling eslint, this seems to fix the problem on my local machine. |
Require users to await a promise before returning the result inside a
try
block. Otherwise the errors won't be caught by the catch block.Require users to NOT await a promise when the result is immediately returned outside of a
try
block. This is a (micro)performance optimization to avoid unnecessary allocation of an extra Promise instance.Rule docs: https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/return-await.md
At the moment (2019-11-28), eslint reports false positives, they should be fixed by typescript-eslint/typescript-eslint#1270. This pull request cannot be landed until that patch is released & our package-lock files are updated with the new version of the eslint plugin.The eslint fix was released in v2.10.0.
Checklist
馃憠 Read and sign the CLA (Contributor License Agreement) 馃憟
npm test
passes on your machinepackages/cli
were updatedexamples/*
were updated馃憠 Check out how to submit a PR 馃憟