eslint-import-resolver-meteor
eslint-import-resolver-meteor copied to clipboard
Fix import/no-extraneous-dependencies error
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?
Should be, could hardcode meteor
as an un-pathed dependency (would need to return { found: true, path: null }
from the resolver).
or maybe at this line, replace meteor/
with meteor
? https://github.com/clayne11/eslint-import-resolver-meteor/blob/master/index.js#L15
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.
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
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.
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.
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
?
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...
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
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
.
I ran into this yesterday. I eventually silenced it in .eslintrc with:
"settings": {
"import/core-modules": [ "meteor/meteor" ]
}
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.
How's this issue coming along?
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.
#19
Any progress?
+1 Would also like this to be fixed
Don't put +1s here, I can't fix it. Please post in the appropriate issue (benmosher/eslint-plugin-import#479).