Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/rules/require-super-in-lifecycle-hooks.md
Expand Up @@ -8,7 +8,7 @@

Call super in lifecycle hooks.

When overriding lifecycle hooks inside Ember Components, Controllers, Routes, Mixins, or Services, it is necessary to include a call to super.
When overriding lifecycle hooks inside Ember Components, Controllers, Routes, Mixins, or Services, it is necessary to include a call to super. It is necessary to call the super.int() hook with arguments.

## Examples

Expand All @@ -20,7 +20,7 @@ import Component from '@ember/component';
export default Component.extend({
init() {
this.set('items', []);
}
},
});
```

Expand All @@ -30,7 +30,7 @@ import Component from '@ember/component';
export default Component.extend({
didInsertElement() {
// ...
}
},
});
```

Expand All @@ -53,7 +53,7 @@ export default Component.extend({
init(...args) {
this._super(...args);
this.set('items', []);
}
},
});
```

Expand All @@ -64,7 +64,7 @@ export default Component.extend({
didInsertElement(...args) {
this._super(...args);
// ...
}
},
});
```

Expand Down
3 changes: 2 additions & 1 deletion lib/rules/require-super-in-lifecycle-hooks.js
Expand Up @@ -44,7 +44,8 @@ function isNativeSuper(node, hook) {
types.isMemberExpression(node.callee) &&
node.callee.object.type === 'Super' &&
types.isIdentifier(node.callee.property) &&
node.callee.property.name === hook
node.callee.property.name === hook &&
(hook !== 'init' || node.arguments.length > 0)
samridhivig marked this conversation as resolved.
Show resolved Hide resolved
);
}

Expand Down