Closed ASH-Michael closed 6 years ago
@ASH-Michael can you elaborate on the specific rules?
To configure this in the .eslintrc
file, you would just need to add this rule to the rules:
object...
ember/use-ember-get-and-set: 2
//or
ember/use-ember-get-and-set: [2, {
ignoreThisExpressions: false,
}]
This will enforce the proper use of get
and set
in your projects.
//bad
this.get('fooProperty');
this.set('fooProperty', 'bar');
this.getWithDefault('fooProperty', 'defaultProp');
object.get('fooProperty');
object.getProperties('foo', 'bar');
object.setProperties({ foo: 'bar', baz: 'qux' });
//good
get(this, 'fooProperty');
set(this, 'fooProperty', 'bar');
getWithDefault(this, 'fooProperty', 'defaultProp');
get(object, 'fooProperty');
getProperties(object, 'foo', 'bar');
setProperties(object, { foo: 'bar', baz: 'qux' });
With the addition of
eslint-plugin-ember
in our projects, we can add a rule to our.eslintrc
file to enforce the proper use of get, set, and setProperties.I propose we update this section to include instructions for that.