Skip to content

Latest commit

 

History

History
71 lines (54 loc) · 1.22 KB

classic-decorator-hooks.md

File metadata and controls

71 lines (54 loc) · 1.22 KB

ember/classic-decorator-hooks

💼 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

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() {
    // ...
  }
}

References

Related Rules