Skip to content
Fallow home
All docs pages

Docs home

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

FactValue
Issue typeunlisted-dependency
Rule id in SARIF outputfallow/unlisted-dependency
Commandfallow dead-code
Default severityerror
Config key in rulesunlisted-dependencies
Filter option--unlisted-deps
Fixable with fallow fixNo
Opt-inNo

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.json above it. A private workspace, and a test or tool file, can use the declarations of a package.json above 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[].name in a tsconfig.json. The finding points at the config value.