-
-
Notifications
You must be signed in to change notification settings - Fork 204
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
Add requireArgs
option in require-super-in-lifecycle-hooks
rule
#1836
base: master
Are you sure you want to change the base?
Add requireArgs
option in require-super-in-lifecycle-hooks
rule
#1836
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.
We'll need to see some test cases to better understand what this change is doing..
We'll also need to put this behind an option (e.g. |
requireArgs
option in require-super-in-lifecycle-hooks
requireArgs
option in require-super-in-lifecycle-hooks
requireArgs
option in require-super-in-lifecycle-hooks
rule
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.
Just wondering, why are you only targeting init
and not other lifecycle hooks?
).foundMatch; | ||
|
||
if (hookName === 'init' && hasSuper && requireArgs) { | ||
const hasSuperWithArguments = hasMatchingNode( |
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.
Can we avoid searching for the node again? We should already have it from the above hasMatchingNode
call right, so we can just check if that node has arguments.
@@ -231,6 +231,19 @@ eslintTester.run('require-super-in-lifecycle-hooks', rule, { | |||
|
|||
// Does not throw with node type (ClassProperty) not handled by estraverse. | |||
'Component.extend({init() { class Foo { @someDecorator() someProp }; return this._super(...arguments); } });', | |||
|
|||
// init hook should not be checked for arguments when requireArgs = false |
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.
Let's include a test case for both:
- implicit requireArgs = false (since it's the default)
- explicit requireArgs = false
@bmish Regarding your question, "Just wondering, why are you only targeting init and not other lifecycle hooks?" Currently, I only added the I didn't expand it to other hooks as I am not sure if all other hooks prefer to have |
@samridhivig I see. Yeah so we only know about the Ember Data issue with |
Where's this rule at? Close? |
Fix #1784:
Updated
require-super-in-lifecycle-hooks
rule to error whensuper.init()
is called without...arguments
.