Should packages explicitly list eslint as a devDependency if they have a lint script, or is relying on workspace hoisting acceptable? #12781
Replies: 3 comments
Yes, IMO dependencies should always be explicit - relying on implicit hoisting is dangerous and can lead to issues that are super hard to debug. You can enforce this by defining See: https://medium.com/pnpm/pnpms-strictness-helps-to-avoid-silly-bugs-9a15fb306308 PS |
|
Yes, list it explicitly. Relying on hoisting is a correctness accident waiting to happen. The practical reasons:
The Turborepo docs don't list it because the examples focus on the config package setup, not the consuming package's deps. It's an omission in the example, not a deliberate design choice. wujekbogdan's suggestion about // packages/eslint-config/package.json
{
"peerDependencies": {
"eslint": "^9.0.0"
}
}This way any package that depends on |
|
Yes, packages should explicitly list their own eslint as a devDependency. Relying on hoisting is a silent time bomb. Here's why:
The right setup for a Turborepo: // packages/my-app/package.json
{
"devDependencies": {
"eslint": "workspace:*", // follows root
"@repo/eslint-config": "workspace:*"
},
"scripts": {
"lint": "eslint ."
}
}Use |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Summary
In my Turborepo, I'm unsure about dependency declaration best practices. Currently, some packages have npm scripts that call CLI tools (like
eslint), but these tools aren't explicitly listed asdevDependenciesin those packages; they're only listed in a centralized (eslint-)config package. The specific section in the docs also do not explicitly list them but it's not clear if it's done on purpose or not.Due to npm workspace hoisting, the scripts work fine because all dependencies are available in the root
node_modules.Is it a best practice to explicitly list all CLI tools used in a package's scripts as
devDependencies?Example
All reactions