pnpm: ESlint plugins are conflicted each other migrating to pnpm
pnpm version: 6.32.9
Code to reproduce the issue:
I tried to reproduce error using CRA, but couldnāt figure out exact condition š¢
Expected behavior:
ESLint plugins donāt conflict
Actual behavior:
Plugin ā@typescript-eslintā was conflicted between ā.eslintrc.jsonā and ā.eslintrc.json Ā» eslint-config-react-app#overrides[0]ā. ERROR in Plugin ā@typescript-eslintā was conflicted between ā.eslintrc.jsonā and ā.eslintrc.json Ā» eslint-config-react-app#overrides[0]ā.
The reason why I posted this issue on pnpm is that eslint didnāt conflict when we were using npm. This error was occurred migrating from npm to pnpm. I tried lots of experiments.
- Remove
node_modules
and install from scratch -> Failed - Remove all eslint packages and re-install from scratch -> Failed
From this situation, I cannot no longer guess what is the real problem? I think installation mechanism of pnpm is related to this issue. Is there other reason that you think? Thanks for your reading.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 8
- Comments: 17
I had a similar issue:
The problem is Iām using
eslint
configs that declare plugins as regular non-peer dependencies.auto-install-peers
does not seem to work for me like I want - I donāt want to manually install all peer dependencies of the config package in my projectsUsing PNPMās
override
field inpackage.json
, I force a single version of the problematic package - e.g.esling-plugin-prettier
in my case:The problem still persisted, because
eslint
uses file path to figure out if the plugin is the same package. I think it didnāt even resolve symlinks usingfs.realpath
.So I made a
patch-package
patch to fix this. But resolving symlinks still didnāt help: even though theeslint-plugin-prettier
was the exact same version and hardlinked to the same place on disk, PNPM can put the same package in different ānode_modules contextsā depending on the set of dependencies itās used together with.So the final patch checks is the file is hardlinked to the same place on disk⦠not sure if this is 100% correct, because of these different ānode_modules contextsā but it works for me.
The patch generated using
@milahu/patch-package-with-pnpm-support
:Iām not sure about performance of the synchronous
fs.statSync
calls - but it seems ok for my use case. šAlso, Iām using Ubuntu WSL - Iām not exactly sure how cross-platform nodeās
stat
implemetation is - is it āpolyfilledā for Windows or not.Fixed with:
.npmrc
@baeharam I faced a similar issue, after upgrading to pnpm 7. I resolved it by adding
eslint
andeslint-config-react-app
todevDependencies
as described here.