💼 This rule is enabled in the ✅ recommended
config.
Use the correct lifecycle hooks in classic and non-classic classes. Classic
classes should use init
, and non-classic classes should use constructor
.
Additionally, non-classic classes may not use destroy
.
Examples of incorrect code for this rule:
export default class MyService extends Service {
init() {
// ...
}
destroy() {
// ...
}
}
@classic
export default class MyService extends Service {
constructor(...args) {
super(...args);
// ...
}
}
Examples of correct code for this rule:
@classic
export default class MyService extends Service {
init() {
// ...
}
destroy() {
// ...
}
}
export default class MyService extends Service {
constructor(...args) {
super(...args);
// ...
}
willDestroy() {
// ...
}
}