-
Notifications
You must be signed in to change notification settings - Fork 153
feat(await-async-queries): add auto-fix #1077
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
base: main
Are you sure you want to change the base?
feat(await-async-queries): add auto-fix #1077
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1077 +/- ##
==========================================
+ Coverage 96.41% 96.44% +0.02%
==========================================
Files 50 50
Lines 2679 2700 +21
Branches 1099 1107 +8
==========================================
+ Hits 2583 2604 +21
Misses 96 96 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…g-library into feature/add-fixer-for-await-async-queries
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.
Looks great! Just a small nitpick.
if (functionExpression.async) { | ||
return IdentifierNodeFixer; | ||
} else { | ||
/** | ||
* Mutate the actual node so if other nodes exist in this | ||
* function expression body they don't also try to fix it. | ||
*/ | ||
functionExpression.async = true; | ||
|
||
return [ | ||
IdentifierNodeFixer, | ||
fixer.insertTextBefore(functionExpression, 'async '), | ||
]; | ||
} |
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.
nitpick: What do you think of this alternative to avoid branching the code with duplicated parts? (the IdentifierNodeFixer mainly)
if (functionExpression.async) { | |
return IdentifierNodeFixer; | |
} else { | |
/** | |
* Mutate the actual node so if other nodes exist in this | |
* function expression body they don't also try to fix it. | |
*/ | |
functionExpression.async = true; | |
return [ | |
IdentifierNodeFixer, | |
fixer.insertTextBefore(functionExpression, 'async '), | |
]; | |
} | |
const ruleFixes = [IdentifierNodeFixer]; | |
if (!functionExpression.async) { | |
/** | |
* Mutate the actual node so if other nodes exist in this | |
* function expression body they don't also try to fix it. | |
*/ | |
functionExpression.async = true; | |
ruleFixes.push( | |
fixer.insertTextBefore(functionExpression, 'async ') | |
); | |
} | |
return ruleFixes; |
Checks
Changes
Context
Fixes #914
also some of #202
Reference: #917