Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions docs/rules/require-super-in-lifecycle-hooks.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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)
);
}

Expand Down