Unused dependencies
What an unused-dependency finding of fallow dead-code means, why it matters and how to fix it.
What it reports
Dependency listed but never imported.
Dependencies explains how fallow finds it.
Why it matters
Packages listed in dependencies that are never imported or required by any source file. A package that only a framework or a CLI tool loads can be reported when no plugin of fallow knows that use. To keep such a package, add it to ignoreDependencies.
Example
package.json lists left-pad, but no source, script, config, or plugin-recognized file imports it.
Fix
Remove the dependency after checking runtime/plugin usage. If another workspace uses it, move the dependency to that workspace.
Facts
| Fact | Value |
|---|---|
| Issue type | unused-dependency |
| Rule id in SARIF output | fallow/unused-dependency |
| Command | fallow dead-code |
| Default severity | error |
Config key in rules | unused-dependencies |
| Filter option | --unused-deps |
Fixable with fallow fix | Yes |
| Opt-in | No |
Note. --unused-deps controls unused-dependency, unused-dev-dependency, unused-optional-dependency, type-only-dependency, test-only-dependency, and dev-dependency-in-production.
When to keep the code
- A peer dependency of another package: fallow counts a required peer as used when the package that requires it is installed and in use. When only an environment outside the project needs the peer, check that environment before you remove it.
- A package that the code never imports, such as a polyfill that the runtime loads: add it to
ignoreDependencies.
Notes
In a monorepo, a workspace package in dependencies counts like a package from npm. When a workspace declares @repo/ui and never imports it, fallow reports it.