ember-cli / eslint-plugin-ember

An ESLint plugin that provides set of rules for Ember applications based on commonly known good practices.
MIT License
261 stars 202 forks source link

New rule: prevent assignment of existing properties on a service (important for tests) #2080

Open NullVoxPopuli opened 8 months ago

NullVoxPopuli commented 8 months ago

I've seen some code that does:

let service = this.owner.lookup('service:foo');

service.setProperties({ 
  replacement properties and methods
});
// or
service.foo = replacement
// or
Ember.set(service, 'foo', replacement)

we should lint against this, because it can cause sutle bugs.

Additionally, you end up testing your replacements, rather than the service itself.

If someone wants to