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
New: require-await
rule (fixes #6820)
#7435
Conversation
@mysticatea, thanks for your PR! By analyzing the history of the files in this pull request, we identified @nzakas, @kaicataldo and @gyandeeps to be potential reviewers. |
LGTM |
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.
One @fileoverview needs to be fleshed out, and I identified another possible ast-utils candidate, otherwise looks good.
@@ -0,0 +1,105 @@ | |||
/** | |||
* @fileoverview Rule to |
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.
This needs to be fleshed out, I think. 😄
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.
Oops, I have forgotten it since I use this template after a long time.
* @param {ASTNode} node - The function node to check. | ||
* @returns {boolean} `true` if the function node is an empty function. | ||
*/ | ||
function isEmpty(node) { |
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.
Seems like this should go in ast-utils?
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.
Probably.
LGTM |
Just a heads up: we have moved to a new CLA checker on pull requests. Even if you've previously signed our CLA, we will need to you sign the new one. To do so, look at the status checks for licence/cla and click the "Details" link. Sorry for the inconvenience. |
@platinumazure I believe your concerns have been addressed in the new commits from @mysticatea . Could you take a look when you have a chance? |
What is the purpose of this pull request? (put an "X" next to item)
[X] New rule (template)
Please describe what the rule should do:
This rule disallows
async
functions which have noawait
expression.Async functions which have no
await
expression may be the unintentional result of refactoring.See #6820 also.
What category of rule is this? (place an "X" next to just one item)
[X] Enforces code style
[ ] Warns about a potential error
[ ] Suggests an alternate way of doing something
[ ] Other (please specify:)
Provide 2-3 code examples that this rule will warn about:
Why should this rule be included in ESLint (instead of a plugin)?
require-yield
rule which does the same check for generator functions.What changes did you make? (Give an overview)
This PR adds the
require-await
rule into core.In addition, this PR adds 2 functions to
ast-utils
.getFunctionNameWithKind(node)
gets the name and kind of the given function. I intended that this is an utility to use for Include function name in report message if possible / relevant #7260. Please see JSDoc comment for details.getFunctionHeadLoc(node, sourceCode)
gets the location of the function head. I intended that this is an utility to use for Return range in the lint result #3307. Please see JSDoc comment for details.Is there anything you'd like reviewers to focus on?