Skip to content

Latest commit

 

History

History
41 lines (33 loc) · 907 Bytes

no-function-prototype-extensions.md

File metadata and controls

41 lines (33 loc) · 907 Bytes

no-function-prototype-extensions

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

Do not use Ember's function prototype extensions.

Use computed property syntax, observer syntax or module hooks instead of .property(), .observes() or .on() in Ember modules.

Examples

Examples of incorrect code for this rule:

export default Component.extend({
  abc: function () {
    /* custom logic */
  }.property('xyz'),
  def: function () {
    /* custom logic */
  }.observes('xyz'),
  ghi: function () {
    /* custom logic */
  }.on('didInsertElement')
});

Examples of correct code for this rule:

export default Component.extend({
  abc: computed('xyz', function () {
    /* custom logic */
  }),
  def: observer('xyz', function () {
    /* custom logic */
  }),
  didInsertElement() {
    /* custom logic */
  }
});