[New Rule] add noAsyncWithoutAwait rule#3945
[New Rule] add noAsyncWithoutAwait rule#3945JoshuaKGoldberg merged 15 commits intopalantir:masterfrom
Conversation
|
@eranshabi please merge latest |
|
I fixed the rule's support of implicit promise return statements. |
|
All builds are green now |
|
@giladgray @jkillian @suchanlee anything else needed for merge? |
|
We'd really like to add this rule to our project, is there any chance someone can review this? |
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Functionality looks good! Waiting on a few touchups of the implementation details and some more rationale details.
src/rules/noAsyncWithoutAwaitRule.ts
Outdated
| optionExamples: [true], | ||
| options: null, | ||
| optionsDescription: "Not configurable.", | ||
| rationale: "Cleaner code, can possibly reduce transpiled output", |
There was a problem hiding this comment.
Please explain this in more detail. Someone reading this rule's page on palantir.github.io would leave with more questions than they started with.
src/rules/noAsyncWithoutAwaitRule.ts
Outdated
| if (this.isAsyncFunction(node) | ||
| && !this.functionBlockHasAwait(node.body as ts.Node) | ||
| && !this.functionBlockHasReturn(node.body as ts.Node) | ||
| && !this.isShortArrowReturn(node)) { |
There was a problem hiding this comment.
Performance nit: please move isShortArrowReturn first. Seems like we could be slightly faster by performing that very fast check before doing deeper searches.
|
Thanks for the feedback @JoshuaKGoldberg, fixed by latest commit. |
|
Hey @JoshuaKGoldberg is anything else needed before merging? |
JoshuaKGoldberg
left a comment
There was a problem hiding this comment.
Took a deeper look - some things to fix up.
So sorry for the delay @eranshabi! I had a pending review started then dropped it ☹
|
Thanks for the review @JoshuaKGoldberg, I pushed a fix for everything. |
|
anything else needed for merge? @JoshuaKGoldberg @giladgray |
|
@eranshabi I took another structural look and posted some feedback. Once all mine are addressed Edit: it's been a bit since the original review so apologies in advance if some of the feedback is duplicate 😊 |
|
All right, I cleaned up the merge conflicts and pending PR comments, then refactored this to be a walker function instead of the deprecated class-based approach. It's good to go! FYI @eranshabi - this'll be in the next TSLint release. Thanks so much for sending this PR in... about a year ago! Sorry it took so long to merge. 😄😢 |
PR checklist
Overview of change:
Add a new rule ("noAsyncWithoutAwait"). The rule makes sure that a function will not be an
asyncfunction, unless it has anawait;Is there anything you'd like reviewers to focus on?
CHANGELOG.md entry:
[new-rule]
no-async-without-await