🚗 The "extends": "plugin:ember/octane"
property in a configuration file enables this rule.
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() {
super();
// ...
}
}
Examples of correct code for this rule:
@classic
export default class MyService extends Service {
init() {
// ...
}
destroy() {
// ...
}
}
export default class MyService extends Service {
constructor() {
super();
// ...
}
willDestroy() {
// ...
}
}