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

Issue with ember/new-module-imports rule #250

Open
Serabe opened this issue Apr 8, 2018 · 1 comment
Open

Issue with ember/new-module-imports rule #250

Serabe opened this issue Apr 8, 2018 · 1 comment

Comments

@Serabe
Copy link
Contributor

Serabe commented Apr 8, 2018

I'm going back home today. I'll try to check this at some point in the near future

emberjs/rfcs#273 (comment)

@pusle wrote:

After upgrading from Ember Cli 2.12 to 3.0 I get a lot of errors telling me to

4:12 error Use import { inject } from '@ember/service'; instead of using Ember.inject.service ember/new-module-imports

when running ember serve after the upgrade. I have gone trough a lot of these files and updated as told. Should the error notifications say to use import { inject as service } from '@ember/service'; instead?

@clcuevas
Copy link
Contributor

@Serabe I know a fix for the issue that was filed. However, upon investigating this and thinking about the rule a bit more, I came across other scenarios that wouldn't be reported or would be reported incorrectly. Here's one scenario that I've seen in older Ember applications:

import Ember from 'ember';

const {
  Controller, // This variable line gets reported properly
  computed, // This variable line gets reported, but it's incorrect because of its usage
  inject // This variable line gets reported, but it's incorrect because of its usage
} = Ember;

export default Controller.extend({
  myService: inject.service('my-service'),

  someProperty: computed.readOnly('someOtherProperty')
});

It seems that what should happen in the rule is that we should be looking for MemberExpressions that have a next child that is an Indentifier without any selectors. Right now, the selector this rule uses is MemberExpressions > Identifier[name=Ember]. This limits the rule to only look for expressions that begin with Ember.. Anything else gets ignored. I'm not sure if this was done on purpose because of some limitation/issue I can't think about at this moment.

Either way, when the time permits, I can try seeing if I can come up with a solution. Of course, if there is anyone else that wants to take a shot at this would be most welcomed.

@bmish bmish changed the title Check this issue Issue with ember/new-module-imports rule Aug 30, 2020
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