eslint-plugin-ember
eslint-plugin-ember copied to clipboard
Add `requireArgs` option in `require-super-in-lifecycle-hooks` rule
Fix #1784:
Updated require-super-in-lifecycle-hooks
rule to error when super.init()
is called without ...arguments
.
We'll also need to put this behind an option (e.g. requireArgs
) to avoid this being a breaking change. In a future major version, we could enable the option by default.
@bmish Regarding your question, "Just wondering, why are you only targeting init and not other lifecycle hooks?"
Currently, I only added the requireArgs
option for init hook as explicitly mentioned in the parent issue: https://github.com/ef4/ember-data-relationship-tracker/pull/25#pullrequestreview-1299859878
I didn't expand it to other hooks as I am not sure if all other hooks prefer to have ...arguments
as well. If other hooks don't, then enforcing this linting rule for them can lead to verbose code.
@samridhivig I see. Yeah so we only know about the Ember Data issue with init
needing args right now, but would you mind asking on the Ember Discord or otherwise doing some quick research to see if the other hooks should technically have args passed as well? I just want to avoid the situation where we need another breaking change later if we discover that all hooks need args. It also seems that we might as well require args for all hooks for consistency...which would also be helpful in case the other hooks end up needing args in the future.
Where's this rule at? Close? Looks like there are some unresolved questions?