New check idea: `DUPLICATE_PACKAGE_NAME`
I was creating a new package in a monorepo by copying an existing one. I forgot to change the name and ended up with two workspaces having identical names. pnpm install did not complain, manypkg did not either. It’d be great to see an error (DUPLICATE_PACKAGE_NAME?) in this case.
Here is an MWE for @manypkg/[email protected]:
https://github.com/kachkaev/manypkg-issue-235
packages/a/package.json → "name": "a"
packages/b/package.json → "name": "b"
packages/c/package.json → "name": "a" ❗ should be "c"
pnpm manypkg check
## Recieved
☔️ success workspaces valid!
## Expected
☔️ error Workspaces at "packages/a" and "package/c" have the same name "a"
Side observation: I removed "name" from packages/c/package.json just to see what happens. pnpm manypkg check produced this:
☔️ error PackageJsonMissingNameError: The following package.jsons are missing the "name" field:
☔️ error packages/c/package.json
☔️ error at validatePackages (/path/to/project/node_modules/@manypkg/get-packages/dist/manypkg-get-packages.cjs.dev.js:57:11)
☔️ error at Object.getPackages (/path/to/project/node_modules/@manypkg/get-packages/dist/manypkg-get-packages.cjs.dev.js:35:3)
☔️ error at async /path/to/project/node_modules/@manypkg/cli/dist/manypkg-cli.cjs.dev.js:813:7 {
☔️ error directories: [ 'packages/c/package.json' ]
☔️ error }
I was expecting to see INVALID_PACKAGE_NAME but got the crash instead. This is a pretty niche edge case, so not a big deal. Just flagging in case if a fix can be easily done simultaneously.
Both should be improved/fixed. Thanks for raising an issue. I might not have time to implement this myself though - PRs are welcome 😉