Skip to content

Latest commit

 

History

History
50 lines (33 loc) · 1.84 KB

File metadata and controls

50 lines (33 loc) · 1.84 KB

Disallow unnecessary usage of Ember's getProperties function

Rule name: no-get-properties

Starting in Ember 3.1, native ES5 getters are available, which eliminates much of the need to use get and getProperties on Ember objects. In particular, getProperties no longer needs to be used with destructuring assignments.

Rule Details

This rule disallows unnecessarily using this.getProperties() with destructuring assignments.

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

Examples of incorrect code for this rule:

const { abc, def } = this.getProperties('abc', 'def');
import { getProperties } from '@ember/object';
const { abc, def } = getProperties(this, 'abc', 'def');

Examples of correct code for this rule:

const { abc, def } = this;
const { foo, barBaz } = this.getProperties('foo', 'bar.baz'); // Allowed because of nested path.

References

Related Rules