eslint-plugin-ember
eslint-plugin-ember copied to clipboard
New Rule: no-self-referencing-properties
This rule would catch the issue that led to the bug in #1118
This rule would lint all macros as well as computed properties and getters for self-referential behavior. It would be applied to classic syntax as well as native syntax.
import Component from '@ember/component';
import { computed } from '@ember/object';
import { reads } from '@ember/object/computed';
export default MyComponent extends Component {
// BAD
get foo() {
return this.foo;
}
// BAD
@computed('bar')
get bar() {
return this.bar;
}
// BAD
@computed('not-biz')
get biz() {
return this.biz;
}
// BAD
@reads('baz') baz;
}
Seems good, though I'm not 100% sure this belongs in eslint-plugin-ember. It doesn't really seem like an "ember thing", it seems like a generate JavaScript best practice thing...
@rwjblue confirm, though since macros have this issue too there will be at least a component of it that pertains to us.