-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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: added async in allow method in no-empty-function (fixes #12768) #13036
Conversation
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.
Is there anything in particular we can help clarify for you in regards to writing tests?
The test setup is a bit confusing with use of Array.prototype.reduce()
. If it's helpful to refactor this to make it easier to understand what's going on, I think that would be fine.
Regarding how tests work, have you looked at the documentation for the RuleTester
API?
indeed this is a bit confusing. I added this but got parsing error |
@anikethsaha Thanks for working on it 👍
You should change the parserOptions with |
thanks a lot @yeonjuan ! it worked like a charm. @kaicataldo I added two test cases. Just do let me know if you need to add some 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.
Thanks for contributing!
Would you mind updating the documentation also? - no-empty-function
@anikethsaha
What I meant was that the newly added tests should be in the array at the third parameter of Because the test cases at the second parameter of
The current test setup seems to like this: ruleTester.run("no-empty-function", rule, [
/*
* These elements are the test cases that need to be tested with each option and various invalid, valid form.
* So these elements are converted into other forms by 'toValidInvalid()'
*/
,
]).reduce(toValidInvalid, {
valid: [
/*
* These are always valid. So don't need to be converted
* That is the reason why "var foo = () => 0;" is here because it is not an empty function.
*/
{
code: "var foo = () => 0;", // it has return value '0'. always valid
parserOptions: { ecmaVersion: 6 }
}
]
})); |
@yeonjuan yes, the second parameter of I will change this 👍 |
And it would be nice if we mentioned the issue number in the PR title. |
@yeonjuan done 👍 |
cc @kaicataldo @yeonjuan I added more tests and did the docs changes as request. Do let me know if anything else needs to be changed! |
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.
Thanks for changing it 👍
I left suggestions for minor typos.
Co-Authored-By: YeonJuan <yeonjuan93@naver.com>
Co-Authored-By: YeonJuan <yeonjuan93@naver.com>
Co-Authored-By: YeonJuan <yeonjuan93@naver.com>
cc @yeonjuan done |
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.
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.
This LGTM, thank you!
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.
LGTM, thanks!
Thanks for contributing to ESLint! |
…2768) (eslint#13036) * Fix: added async in allow method in no-empty-function * Chore: added tests for async* allow * Docs: updated docs for async method and funct * Chore: more tests and test fixes and docs refactore * Update docs/rules/no-empty-function.md Co-Authored-By: YeonJuan <yeonjuan93@naver.com> * Update docs/rules/no-empty-function.md Co-Authored-By: YeonJuan <yeonjuan93@naver.com> * Update docs/rules/no-empty-function.md Co-Authored-By: YeonJuan <yeonjuan93@naver.com> * Docs: fixed the ecma version for docs snippet Co-authored-by: YeonJuan <yeonjuan93@naver.com>
Prerequisites checklist
What is the purpose of this pull request? (put an "X" next to an item)
[ ] Documentation update
[X] Bug fix (template)
[ ] New rule (template)
[X] Changes an existing rule (template)
[ ] Add autofixing to a rule
[ ] Add a CLI option
[ ] Add something to the core
[ ] Other, please explain:
What changes did you make? (Give an overview)
Added
asyncFunctions
andasyncMethods
toALLOW_OPTIONS
forno-empty-function
ruleIs there anything you'd like reviewers to focus on?
fixes #12768
Also, I am bit confused about how to write tests for valid code as for this rule, gives test cases are converted into valid and invalid