Skip to content

Latest commit

 

History

History
59 lines (43 loc) · 1.87 KB

no-function-prototype-extensions.md

File metadata and controls

59 lines (43 loc) · 1.87 KB

ember/no-function-prototype-extensions

💼 This rule is enabled in the ✅ recommended config.

By default, Ember extends certain native JavaScript objects with additional methods. This can lead to problems in some situations. One example is relying on these methods in an addon that is used inside an app that has the extensions disabled.

The prototype extensions for the function object were deprecated in RFC #272.

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

Rule Details

This rule will disallow method calls that match any of the forbidden function prototype extension method names.

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 */
  }
});

References

Related Rules