Skip to content

Latest commit

 

History

History
60 lines (49 loc) · 1.2 KB

classic-decorator-no-classic-methods.md

File metadata and controls

60 lines (49 loc) · 1.2 KB

Disallow the use of classic API methods

Rule name: classic-decorator-no-classic-methods

Disallows the use of the following 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.

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

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

References

Related Rules