avoid-leaking-state-in-ember-objects should rule apply to service variable as well?
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?
Can you provide a code sample that you want to be caught by the rule?
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?
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