Skip to content

Latest commit

 

History

History
77 lines (60 loc) · 1.6 KB

classic-decorator-no-classic-methods.md

File metadata and controls

77 lines (60 loc) · 1.6 KB

classic-decorator-no-classic-methods

✅ The "extends": "plugin:ember/recommended" property in a configuration file enables this rule.

Disallows the use of the following classic API methods within a class:

  • get
  • set
  • getProperties
  • setProperties
  • getWithDefault
  • incrementProperty
  • decrementProperty
  • toggleProperty
  • addObserver
  • removeObserver
  • notifyPropertyChange
  • cacheFor
  • proto

These are "classic" API methods, and their usage is discouraged in Octane. Non-method versions of them can still be used, e.g. @ember/object#get and @ember/object#set instead of this.get and this.set.

Examples

Examples of incorrect code for this rule:

export default class MyService extends Service {
  constructor(...args) {
    super(...args);
    this.set('foo', 'bar');
  }
}

Examples of correct code for this rule:

@classic
export default class MyService extends Service {
  constructor(...args) {
    super(...args);
    this.set('foo', 'bar');
  }
}
import { set } from '@ember/object';

export default class MyService extends Service {
  constructor(...args) {
    super(...args);
    set(this, 'foo', 'bar');
  }
}
import { tracked } from '@glimmer/tracking';

export default class MyService extends Service {
  @tracked foo = 'bar';
}

References

Related Rules