Add requireArgs option in require-super-in-lifecycle-hooks rule#1836
Add requireArgs option in require-super-in-lifecycle-hooks rule#1836samridhivig wants to merge 6 commits intoember-cli:masterfrom
requireArgs option in require-super-in-lifecycle-hooks rule#1836Conversation
bmish
left a comment
There was a problem hiding this comment.
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-hooksrequireArgs option in require-super-in-lifecycle-hooks rule
bmish
left a comment
There was a problem hiding this comment.
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.
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.
| // 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.
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-hooksrule to error whensuper.init()is called without...arguments.