ember-cli / eslint-plugin-ember

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

"service" import not treated the same as "inject as service" #2030

Open elwayman02 opened 11 months ago

elwayman02 commented 11 months ago

In some lint rules, doing import { service } from '@ember/service'; is not detected the same as import { inject as service } from '@ember/service'; when determining if a service is in use.

For example, in order-in-routes, foo: service() has a different expected position whether or not inject as service was detected at the top of the file. Similarly, require-computed-property-dependencies treats services as a missing dependency if you used import { service }, but not if you used import { inject as service }.

The various linting rules that have handling for services need to be evaluated for this use-case to handle the new best practice around service imports.

https://api.emberjs.com/ember/5.4/functions/@ember%2Fservice/service

bmish commented 11 months ago

I think this is related to how many rules started out just looking for service() instead of actually checking the name it was imported. I fixed a lot rules (https://github.com/ember-cli/eslint-plugin-ember/issues/590) but not all.

bitxplora commented 1 month ago

This import { service } from '@ember/service'; works for me; there is a need for more context on this issue