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

import/named does not report non-existent exports in yarn workspace #2005

Open
jd2rogers2 opened this issue Mar 12, 2021 · 6 comments
Open

Comments

@jd2rogers2
Copy link

Screen Shot 2021-03-12 at 9 45 07 AM

https://github.com/jd2rogers2/eslint-plugin-import-bug-minimal-repo for testing it for yourself

as seen above, no report for import/named despite not having an helloFooV2 export from foo/index.js
foo and bar are both separate workspaces, bar lists foo as a dependency, and foo is in node_modules
i would expect it to report
maybe a larger issue as there is also #1832

@Skidle
Copy link

Skidle commented Jun 15, 2021

Hey @jd2rogers2 , I encountered a similar false positive error in my project and managed to fix it with the following:

image

@jd2rogers2
Copy link
Author

@Skidle thanks for taking a look!
i'm not so sure it's because of the airbnb extension though
here i remove the extension and just use the plugin and rule directly, and still eslint . does not report

@Skidle
Copy link

Skidle commented Jun 23, 2021

@jd2rogers2 yes, since my comment I realized that it happens with or withour airbnb plugin. If you don't use airbnb config, import/ignore will be node_modules by default, effectively ignoring yarn workspaces too.
So you need to add 'import/ignore': ['!^@my'], to ignore anything that's not your workspace.

@jd2rogers2
Copy link
Author

jd2rogers2 commented Jun 25, 2021

@Skidle still no luck on my end :(
i tried out your solution here but i don't get any eslint reports for the import that i expect should receive an error
(even added new rule to make sure eslint command is running correctly)
Screen Shot 2021-06-25 at 3 03 14 PM

were you testing in your own repo or by cloning down mine? if you're working in another project would love to be able to find out the differences somehow
and thanks again for you help and time on this!

@Skidle
Copy link

Skidle commented Jul 7, 2021

@jd2rogers2 you need also to change require to import from in bar.js. Works for me here :)

@andrewzey
Copy link

I've just encountered this and was able to determine that the existence of the "import/resolver" key, even if the value is just an empty object, is what's causing import/named to not detect invalid imports.

Still working on figuring out how to get it working with an import/resolver, but that should give some clue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

4 participants