How can I get JSLint to stop complaining about Ember.js ".property()"s in my model definitions?
E.g., when given:
isBlah: function() {
"use strict";
...
}.property("foo", "bar").cacheable()
JSLint complains about:
Unexpected '.'.
on the line with the .property() call. This happens for every occurrence of ".property()" which makes JSLint output full of "noise" and less than fully helpful...
Ember documents the following method to avoid the function prototype extensions.
Instead of .property(), use Ember.computed():
fullName: Ember.computed('firstName', 'lastName', function() {
return this.get('firstName') + ' ' + this.get('lastName');
})
Instead of .observes(), use Ember.observer():
fullNameDidChange: Ember.observer('fullName', function() {
console.log("Full name changed");
})
My solution was to convert it to:
isBlah: Em.property(function() {
"use strict";
...
}, "foo", "bar").cacheable()
Where I first add the 'property' method to Ember (before starting my app):
Em.property = function (func) {
var params = Array.prototype.slice.call(arguments, 1);
return Function.prototype.property.apply(func, params);
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With