-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[monorepo] Formatting (prettier) fails when root package doesn't include a plugin in a nested project #4238
Copy link
Copy link
Closed
Labels
Description
Formatting (prettier) fails when root package doesn't include a plugin in a nested project (//package.json)
Current Behavior
Next code fails
pnpm exec lerna version --no-commit-hooks -y
with error
lerna info auto-confirmed
lerna info execute Skipping releases
lerna ERR! Error: Cannot find package 'prettier-plugin-tailwindcss' imported from /<projectPath>/noop.js
Expected Behavior
Should work as expected
Steps to Reproduce
- Create a
monorepowithpnpm - Create a
frontendfolder - In frontend folder install
prettier@3.6.2and any prettier plugin likeprettier-plugin-tailwindcss - In
rootinstallprettier@3.6.2 - In
rootinstall & init lerna, do some changes to makelerna versionwork - Run
pnpm exec lerna version --no-commit-hooks -y
Steps to Resolve the issue
In file
| const fileInfo = await resolvedPrettier.getFileInfo(fullFilePath, { ignorePath }); |
const fileInfo = await resolvedPrettier.getFileInfo(fullFilePath, { ignorePath });
to
const fileInfo = await resolvedPrettier.getFileInfo(fullFilePath, { ignorePath, resolveConfig: false });
Why it works: with option resolveConfig: false prettier doesn't resolve the config and only checks if it is ignored or not (you do not use entire config). So in this case prettier will not try to load non existing plugin from the root and just return the needed information
Failure Logs / Configuration
Error already provided
Environment
lerna notice cli v9.0.0
lerna info versioning independent
Environment info:
System:
OS: Linux 6.6 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
CPU: (8) x64 AMD Ryzen 7 5800HS with Radeon Graphics
Binaries:
Node: 22.20.0 - ~/.local/share/pnpm/node
npm: 10.9.3 - ~/.local/share/pnpm/npm
Utilities:
Git: 2.51.0 - /usr/bin/git
npmPackages:
lerna: 9.0.0 => 9.0.0
Reactions are currently unavailable