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

avoid-leaking-state-in-ember-objects should rule apply to service variable as well? #1877

Open
balasiya opened this issue May 26, 2023 · 3 comments

Comments

@balasiya
Copy link

Team,

avoid-leaking-state-in-ember-objects this rule is applicable to ember service as well, as service is singleton model, how this create a leak in the variable?

@bmish
Copy link
Member

bmish commented May 26, 2023

Can you provide a code sample that you want to be caught by the rule?

@balasiya
Copy link
Author

balasiya commented May 26, 2023

In our app we have a service named file, we have different routes where when file is set to favorite we will add it to service array favoritedFiles service sample code is below

import Service, { inject as service } from '@ember/service';

export default Service.extend({
favoritedFiles: []
});

but for this we are throwing lint error for leak state

How do we prevent this?? since service is a singleton, does this will leak?

@bmish
Copy link
Member

bmish commented May 29, 2023

I'm not sure if that should be considered an error. You may want to post the question on the Ember Discord, and let us know what you find out. Either way, it's a good idea to move to a native class regardless.

https://github.com/ember-cli/eslint-plugin-ember/blob/master/docs/rules/avoid-leaking-state-in-ember-objects.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants