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
ESLint plugin issue when using yarn (but works w/ NPM) #8547
Comments
Not sure what's going on here, but for what it's worth, I've seen Yarn do some crazy thing while trying to resolve and dedupe a dependency tree 😬 |
Thanks, @kaicataldo -- and I agree, yarn can do some crazy things, but I do really like it -- and it would be a shame to have to abandon it on my project just because I get weird behavior on linting (the actual project code works great with yarn!). I'm not familiar enough with eslint to know how to even begin debugging this. Do you have any suggestions regarding how I might debug this in order to figure out the cause? |
I would suggest manually checking which version of |
I feel that #7338 might be connected. |
@ilyavolodin: That was actually the first thing I checked. |
I'm experiencing nearly this same issue in my environment - eslint spits out |
Sounds like a mismatch between how npm and Yarn resolve the dependency tree, though @cmoesel I agree it sounds like it's doing the right thing in your case. I'll try to look into this soon and see if I can figure out what's going on! |
Thanks, @kaicataldo. I'll see if I can whip up a simple project to reproduce the issue. Stand by. |
@kaicataldo (and anyone else who wants to give it a try): Here's a link to a simple project that reproduces the problem: https://github.com/cmoesel/eslint-8547 In fact, it's even worse than my real project since there are also some react rules that can't be found (but again, it all works fine if you install with npm instead of yarn). |
In general, "works with npm but not yarn" is a yarn bug, full stop. (to be comparable tho, you'd need an npm-shrinkwrap.json file that paralleled your yarn.lock file) |
@ljharb: I don't have a strong understanding of how eslint loads plugins and extended packages -- but it seems like an incompatibility between how eslint loads these libraries and how yarn stores them. The node_modules that yarn creates actually looks ok -- the eslint-config-import v2.2.0 package (that contains the "missing" rule) is at the root of node_modules. I'm not saying that it's not a yarn bug -- but if yarn is doing something wrong, it's not yet obvious what it is. The eslint maintainers probably know better how their module loading works, so they may be in a better position to at least identify where the incompatibility is (rather than the yarn maintainers). That said, I recognize this is an open source community and while I'll gladly accept help, I'll never expect it! |
Excuse the cross-post, but wanted to let you know someone on the yarn side asked for more info, which caused me to update my example project w/ more data. Details below (in case they are helpful). Versions
NPM You will find the results of In the
and under react-scripts@0.9.5 w/ v 2.0.1:
Yarn You will find the results of In the
and twice (?) under react-scripts@0.9.5 w/ v2.0.1:
|
I'm also facing the same issue. I install my packaged through yarn and when I add
My package.json:
The wierd thing is, I have an |
The reason for this is that when a project is initialized using create-react-app and react-scripts uses an older version of a plugin like eslint-plugin-react, eslint will not find the version used by eslint-config-sk22 and use the older version instead, which can result in errors.
After upgrading |
Yeah, temporarily. Because |
Then react-scripts should have them as peer deps, not deps, so that this doesn't reoccur. This is a requirement of eslint (just like having react as a peer dep everywhere but the top level is a requirement of react). |
I can confirm that using a fork of |
Please link us to the react-scripts PR that fixes this, once it's filed. |
Replied in facebook/create-react-app#2411 (comment). I don’t think adding any |
This is not a
It prints:
In other words, despite there being a top-level ESLint dependency, Yarn links If Yarn fixes the issue, the problem should go away. |
Raised yarnpkg/yarn#3535 |
The fix is ready and will be released in Yarn 0.26 and a patch of 0.25. |
Thanks for following up on this! Closing, as the issue was resolved. |
Yes, thank you @bestander and everyone else involved! |
Tell us about your environment
What parser (default, Babel-ESLint, etc.) are you using?
default
Please show your full configuration:
The
package.json
has these modules (which support eslint) indevDependencies
:My
.eslintrc
:What did you do? Please include the actual source code causing the issue.
Ran eslint after using yarn to install my project (instead of npm):
node_modules/.bin/eslint src/*
What did you expect to happen?
No linter errors.
What actually happened? Please include the actual, raw output from ESLint.
Many files (maybe all js files?) had an error like this:
In addition, one file had the error above plus some other errors that I thought were disabled by the config:
This works if I
npm install
my project instead ofyarn install
. I'm not sure what's going on, but it's worth noting that:'import/no-named-default'
) was introduced in eslint-plugin-import v2.2.0react-scripts
specifies"eslint-plugin-import" : "2.0.1"
as a dependencyeslint-config-airbnb
specifies"eslint-plugin-import" : "^2.2.0"
as a peerDependency"eslint-plugin-import" : "^2.2.0"
as a devDependency to satisfy that peerDependency.If there's something wrong with the way we have this configured, please let me know! I've also submitted an issue to yarn in case it is a bug in yarn (yarnpkg/yarn/issues/3332).
The text was updated successfully, but these errors were encountered: