Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Rule: no-self-referencing-properties #1124

Open
runspired opened this issue Mar 29, 2021 · 2 comments
Open

New Rule: no-self-referencing-properties #1124

runspired opened this issue Mar 29, 2021 · 2 comments
Labels
Enhancement New Rule Idea for a new lint rule

Comments

@runspired
Copy link

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;
}
@rwjblue
Copy link
Member

rwjblue commented Apr 12, 2021

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...

@runspired
Copy link
Author

@rwjblue confirm, though since macros have this issue too there will be at least a component of it that pertains to us.

@bmish bmish added the New Rule Idea for a new lint rule label May 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New Rule Idea for a new lint rule
Projects
None yet
Development

No branches or pull requests

3 participants