Skip to content

Latest commit

 

History

History
65 lines (45 loc) · 1.89 KB

File metadata and controls

65 lines (45 loc) · 1.89 KB

no-get

Starting in Ember 3.1, native ES5 getters are available, which eliminates much of the need to use get / getProperties on Ember objects.

Rule Details

This rule disallows:

  • this.get('someProperty') when this.someProperty can be used
  • this.getProperties('prop1', 'prop2') when { prop1: this.prop1, prop2: this.prop2 } can be used

WARNING: there are a number of circumstances where get / getProperties still need 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

Examples of incorrect code for this rule:

const foo = this.get('someProperty');
import { get } from '@ember/object';
const foo = get(this, 'someProperty');
const { prop1, prop2 } = this.getProperties('prop1', 'prop2');
import { getProperties } from '@ember/object';
const foo = getProperties(this, 'prop1', 'prop2');

Examples of correct code for this rule:

const foo = this.someProperty;
const foo = this.get('some.nested.property'); // Allowed because of nested path.
const { prop1, prop2 } = this;
const foo = { prop1: this.prop1, prop2: this.prop2 };

References