Starting in Ember 3.1, native ES5 getters are available, which eliminates much of the need to use get
on Ember objects.
This rule disallows using this.get('someProperty')
when this.someProperty
can be used.
WARNING: there are a number of circumstances where get
still needs to be used, and you may need to manually disable the rule for these:
- Ember proxy objects (
ObjectProxy
,ArrayProxy
) - Objects implementing the
unknownProperty
method
Examples of incorrect code for this rule:
const foo = this.get('someProperty');
import { get } from '@ember/object';
const foo = get(this, 'someProperty');
Examples of correct code for this rule:
const foo = this.someProperty;
const foo = this.get('some.nested.property'); // Allowed because of nested path.
- Ember 3.1 Release Notes describing "ES5 Getters for Computed Properties"
- Ember get Spec
- Ember ES5 Getter RFC
- es5-getter-ember-codemod
- More context about the proxy object exception to this rule