-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
fix(eslint-plugin): [no-floating-promises] handle TaggedTemplateExpression #8758
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
fix(eslint-plugin): [no-floating-promises] handle TaggedTemplateExpression #8758
Conversation
Thanks for the PR, @naruaway! typescript-eslint is a 100% community driven project, and we a 8000 re incredibly grateful that you are contributing to that community. The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately. Thanks again! 🙏 Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently on https://opencollective.com/typescript-eslint. |
✅ Deploy Preview for typescript-eslint ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #8758 +/- ##
==========================================
- Coverage 87.98% 87.36% -0.63%
==========================================
Files 404 255 -149
Lines 14045 12498 -1547
Branches 4110 3923 -187
==========================================
- Hits 12358 10919 -1439
+ Misses 1382 1304 -78
+ Partials 305 275 -30
Flags with carried forward coverage won't be shown. Click here to find out more.
|
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.
I don't know if they work differently but could you add tests for tag`aaa`.then
, tag`aaa`.catch
, and tag`aaa`.finally?
2bc344c
to
d5f77d4
Compare
@Josh-Cena thanks for the review, I just added test cases for then/catch/finally for sure. I think adding these makes sense to make sure the logic is the same as the function call |
d5f77d4
to
fa4c831
Compare
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.
We normally ask that PRs (other than small docs fixes) have a backing issue for discussion. But this one is pretty small and straightforward. Just requesting changes on tests. Thanks! 🏷️
packages/eslint-plugin/tests/rules/no-floating-promises.test.ts
Outdated
Show resolved
Hide resolved
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.
…ssion (typescript-eslint#8758) * fix(eslint-plugin): [no-floating-promises] handle TaggedTemplateExpression * Improve test cases
…ssion (typescript-eslint#8758) * fix(eslint-plugin): [no-floating-promises] handle TaggedTemplateExpression * Improve test cases
PR Checklist
Overview
This PR makes "no-floating-promises" rule to raise error when floating promise is created from a tagged templates, which is essentially a function call in this context.
The motivating example is with dax, which is a popular library to write shell script in TypeScript.
Its
$
API is a tagged template and it returns a Promise (with other methods on it) and we need toawait
on that.If we forget to
await
, execution orders will be messed up and the main script might exit too early.After this PR, "no-floating-promises" will be able to capture the mistake in the following snippet:
I added the corresponding test cases in the PR and confirmed that the test fails before the implementation change in this PR.