Computed properties may be created with or without a get
method. This rule ensures that the choice
is consistent.
This rule takes a single string option
String option:
"always-with-setter"
(default) getters are required when computed property has a setter"always"
getters are required in computed properties"never"
getters are never allowed in computed properties
/// BAD
Ember.Object.extend({
fullName: computed('firstName', 'lastName', {
get() {
//...
}
})
});
// GOOD
Ember.Object.extend({
fullName: computed('firstName', 'lastName', function() {
//...
})
});
// GOOD
Ember.Object.extend({
fullName: computed('firstName', 'lastName', {
set() {
//...
},
get() {
//...
}
})
});
/// GOOD
Ember.Object.extend({
fullName: computed('firstName', 'lastName', {
get() {
//...
}
})
});
// BAD
Ember.Object.extend({
fullName: computed('firstName', 'lastName', function() {
//...
})
});
/// GOOD
Ember.Object.extend({
fullName: computed('firstName', 'lastName', function() {
//...
})
});
// BAD
Ember.Object.extend({
fullName: computed('firstName', 'lastName', {
get() {
//...
}
})
});
// BAD
Ember.Object.extend({
fullName: computed('firstName', 'lastName', {
get() {
//...
},
set() {
//...
}
})
});