Unlisted dependencies
What an unlisted-dependency finding of fallow dead-code means, why it matters and how to fix it.
What it reports
Dependency used but not in package.json.
Dependencies explains how fallow finds it.
Why it matters
Packages imported without an applicable dependency declaration in package.json. This includes workspace packages imported from the repository root: npm workspace links make a package resolvable, but do not declare a dependency. Package self-references are allowed. Private packages and tooling may use ancestor declarations; publishable runtime code must declare its own dependencies.
Example
Root src/app.ts imports @acme/shared, an npm workspace package. The root package.json lists workspaces but does not list @acme/shared as a dependency, so the import is unlisted even when npm links it into node_modules.
Fix
Declare the imported package in the owning package.json, including the root manifest for root code. Use dependencies for runtime needs or devDependencies for tooling/tests, with a version accepted by your package manager. Self-references need no declaration. For deliberately ambient packages, use ignoreDependencies as an explicit opt-out.
Facts
| Fact | Value |
|---|---|
| Issue type | unlisted-dependency |
| Rule id in SARIF output | fallow/unlisted-dependency |
| Command | fallow dead-code |
| Default severity | error |
Config key in rules | unlisted-dependencies |
| Filter option | --unlisted-deps |
Fixable with fallow fix | No |
| Opt-in | No |
When to keep the code
- When your project allows imports of packages that it does not declare, add those names to
ignoreDependencies.
Notes
- A file uses the nearest
package.jsonabove it. A private workspace, and a test or tool file, can use the declarations of apackage.jsonabove its own. Production code of a publishable workspace must declare its packages itself. - Fallow also reports a package that a tool config names and loads without an import, such as a
compilerOptions.plugins[].namein atsconfig.json. The finding points at the config value.