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

Fix import/no-extraneous-dependencies error #11

Open
merlinstardust opened this issue Aug 2, 2016 · 18 comments
Open

Fix import/no-extraneous-dependencies error #11

merlinstardust opened this issue Aug 2, 2016 · 18 comments

Comments

@merlinstardust
Copy link

Using this plugin along with airbnb's config, results in the error

'meteor' should be listed in the project's dependencies. Run 'npm i -S meteor' to add it import/no-extraneous-dependencies

Is this fixable through this package?

@benmosher
Copy link

Should be, could hardcode meteor as an un-pathed dependency (would need to return { found: true, path: null } from the resolver).

@benmosher
Copy link

or maybe at this line, replace meteor/ with meteor? https://github.com/clayne11/eslint-import-resolver-meteor/blob/master/index.js#L15

@clayne11
Copy link
Owner

clayne11 commented Aug 2, 2016

Could you post a reproduction?

I can't replace meteor/ with meteor - the special resolution rule for meteor packages should only be applied if the package starts with meteor/. There could be an npm package called meteor-schema or something (random name) and we wouldn't want to apply the meteor package resolution in that case. It would be the regular node_module resolution.

If you post a reproduction I'll take a look at it.

@merlinstardust
Copy link
Author

This is the line that's generating it

import {Meteor} from 'meteor/meteor';

Or did you want a full repo reproduction? Because that will be trickier

@clayne11
Copy link
Owner

clayne11 commented Aug 2, 2016

Ideally a full reproduction. If you give me a full reproduction I can fix it much more quickly, otherwise it'll have to wait until I have time to set up a project and reproduce it before I can look at the actual issue.

@pablolarvor
Copy link

pablolarvor commented Aug 3, 2016

Same problem here ..

I have this error on import {Meteor} from 'meteor/meteor';

no-extraneous-dependencies 'meteor' should be listed in the project's dependencies. Run 'npm i -S meteor' to add it.

@clayne11
Copy link
Owner

clayne11 commented Aug 3, 2016

I remember running into this a couple months ago actually. I simply shut the rule off. I couldn't figure out a way around it. Any other idea @benmosher? Could we add an ignore array to the rule so that we can omit meteor?

@benmosher
Copy link

Ah, yeah, actually, I misunderstood the issue at first. I think you could use the import/core-modules setting to ignore it. Will treat it as a built-in.

# .eslintrc.yml
settings:
  import/core-modules: [ meteor ]

No way to expose that via the resolver API ATM, I think. Though that would be cool...

@exKAZUu
Copy link
Contributor

exKAZUu commented Aug 8, 2016

I created a reproduction repository. I got the following errors.
https://github.com/exKAZUu/test-eslint-import-resolver-meteor

..... /test-eslint-import-resolver-meteor/client/main.js
  1:1  error  'meteor' should be listed in the project's dependencies. Run 'npm i -S meteor' to add it  import/no-extraneous-dependencies
  2:1  error  'meteor' should be listed in the project's dependencies. Run 'npm i -S meteor' to add it  import/no-extraneous-dependencies

..... /test-eslint-import-resolver-meteor/server/main.js
  1:1  error  'meteor' should be listed in the project's dependencies. Run 'npm i -S meteor' to add it  import/no-extraneous-dependencies

@clayne11
Copy link
Owner

clayne11 commented Aug 8, 2016

Thanks for the repro! I played around with a few different settings but I couldn't get the resolver to ignore the meteor/ imports. My suggestion for now is to disable the rule in question ("import/no-extraneous-dependencies": "off" in your .eslintrc) until we can get this fixed in eslint-plugin-import. As far as I can tell there's nothing that can be done at the resolver level as this rule is coming from eslint-plugin-import.

@willxy
Copy link

willxy commented Aug 8, 2016

I ran into this yesterday. I eventually silenced it in .eslintrc with:

  "settings": {
    "import/core-modules": [ "meteor/meteor" ]
  }

@clayne11
Copy link
Owner

clayne11 commented Aug 8, 2016

Of course you can fix the issue on a case-by-case basis by including every single meter/foo import individually into import/core-modules, however that would completely defeat the purpose of using the resolver in the first place. It will no longer check for the validity of ANY of your Meteor imports. I would highly recommend turning off the the import/no-extraneous-dependencies rule for the time being. IMO it is the lesser of the two evils.

@merlinstardust
Copy link
Author

How's this issue coming along?

@clayne11
Copy link
Owner

clayne11 commented Oct 8, 2016

It's being tracked in the linked issue import-js/eslint-plugin-import#479. I'm sure @benmosher would accept a PR if you wanted to help out.

@HenriBeck
Copy link

#19

@PolGuixe
Copy link

Any progress?

@bcbweb
Copy link

bcbweb commented Jan 28, 2017

+1 Would also like this to be fixed

@clayne11
Copy link
Owner

Don't put +1s here, I can't fix it. Please post in the appropriate issue (import-js/eslint-plugin-import#479).

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

9 participants