💼 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.
This rule will disallow method calls that match any of the forbidden function
prototype extension method names.
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 */
}
});