Can anyone shed some light on the plugin modules resolution in ESLint when using pnpm? Despite researching numerous articles and answers online on this topic, I still find myself puzzled.
I have delved into pnpm's node_modules structure and ESLint's resolution algorithms, yet I cannot grasp why there is no need to install the plugins used by the @vercel/style-guide
module behind the scenes.
The ESLint documentation provides insights on plugin resolution:
Plugins are resolved relative to the config file. Simply put, ESLint loads the plugin as if a user were to run
in the config file.require('eslint-plugin-pluginname')
Plugins in the base configuration (loaded by extends setting) are relative to the derived config file. For instance, if
./.eslintrc
containsextends: ["foo"]
andeslint-config-foo
includesplugins: ["bar"]
, ESLint locates theeslint-plugin-bar
from the./node_modules/
directory instead ofor ancestor directories. This means every plugin in the config file and base configurations is uniquely resolved../node_modules/eslint-config-foo/node_modules/
@vercel/style-guide
offers various ESLint configs such as the react.js config, which further utilizes
extend: plugin:eslint-plugin-react
, containing plugin: { react }
.
Given this information, one would assume that when our application extends @vercel/style-guide/react
, it should be essential to install the plugins it relies on, like eslint-plugin-react
, directly as a dependency of the end-user app.
Surprisingly, my attempt to do so proved unnecessary. Why is that? What am I overlooking concerning the resolution of these plugins?