Listed dependencies missing in package.json trigger import/no-extraneous-dependencies:
'${packageName}' should be listed in the project's dependencies. Run 'npm i -S ${packageName}' to add it.
We should pass an argument to this rule to support Yarn, so the message would be:
'${packageName}' should be listed in the project's dependencies. Run 'yarn add ${packageName}' to add it.
-1, if you're using yarn, you can't avoid knowing npm exists, nor how to convert npm commands to yarn commands - especially because most of the ecosystem uses npm.
I get where @sindresorhus and @ljharb are coming from, 馃憥-ing this. I think an argument would be crufty.
That said, yarn is prevalent enough (read: I'm also using it, so tons of people must be 馃槈) that I wouldn't be against a PR noticing it at startup (checking for yarn on path via which yarn or some such) and magically using a yarn-flavored message instead.
But I'm not going to implement it any time soon, and I wouldn't prioritize it, so closing this for now. Thanks though!
would you be willing to merge this if someone opened a PR?
The only thing that would make sense is detecting if yarn.lock is present, and giving the yarn commands instead, but I don't see what value it would have.
The value would be that people who use Yarn as package manager would see a Yarn specific message?
I had a couple of instances where students I teached were using yarn, saw this linting error/warning, installed it via the message and in result had an out of sync yarn.lock file.
You could argue that students should know what they are doing, but all bits help right?
I'd argue that students should be using npm :-) Fair point tho.
not gonna touch that subject here ;)