eslint-import-resolver-meteor icon indicating copy to clipboard operation
eslint-import-resolver-meteor copied to clipboard

Fix import/no-extraneous-dependencies error

Open merlinstardust opened this issue 8 years ago • 18 comments

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?

merlinstardust avatar Aug 02 '16 22:08 merlinstardust

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

benmosher avatar Aug 02 '16 22:08 benmosher

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

benmosher avatar Aug 02 '16 22:08 benmosher

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.

clayne11 avatar Aug 02 '16 22:08 clayne11

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

merlinstardust avatar Aug 02 '16 23:08 merlinstardust

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.

clayne11 avatar Aug 02 '16 23:08 clayne11

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.

pablolarvor avatar Aug 03 '16 17:08 pablolarvor

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?

clayne11 avatar Aug 03 '16 18:08 clayne11

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...

benmosher avatar Aug 04 '16 09:08 benmosher

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

exKAZUu avatar Aug 08 '16 09:08 exKAZUu

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.

clayne11 avatar Aug 08 '16 15:08 clayne11

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

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

willxy avatar Aug 08 '16 15:08 willxy

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.

clayne11 avatar Aug 08 '16 15:08 clayne11

How's this issue coming along?

merlinstardust avatar Oct 08 '16 18:10 merlinstardust

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

clayne11 avatar Oct 08 '16 18:10 clayne11

#19

HenriBeck avatar Nov 23 '16 22:11 HenriBeck

Any progress?

PolGuixe avatar Jan 26 '17 22:01 PolGuixe

+1 Would also like this to be fixed

bcbweb avatar Jan 28 '17 04:01 bcbweb

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

clayne11 avatar Jan 28 '17 20:01 clayne11