Skip to content
Fallow home
All docs pages

Docs home

Unused files

What an unused-file finding of fallow dead-code means, why it matters and how to fix it.

What it reports

File is not reachable from any entry point.

Dead code explains how fallow finds it.

Why it matters

No code runs the file, but people still read it, search it and update it in refactors. A bug fix in the file has no effect on the running program.

Example

src/old-widget.ts is not imported by any entry point, route, script, or config file.

Fix

Delete the file if it is genuinely dead. If a framework or a tool loads it implicitly, add the file to entry, to supportEntry for a file that only tests or tooling load, or to dynamicallyLoaded for a file that the code loads at runtime by a computed path.

Facts

FactValue
Issue typeunused-file
Rule id in SARIF outputfallow/unused-file
Commandfallow dead-code
Default severityerror
Config key in rulesunused-files
Filter option--unused-files
Suppression comment// fallow-ignore-file unused-file
Fixable with fallow fixNo
Opt-inNo

When to keep the code

A file is a false positive when a tool or a script loads it without an import. Tell fallow about the loader, and the finding goes away:

  • A script that you run by hand, such as node scripts/seed.ts: run it from a package.json script. Fallow reads the scripts.
  • A script that runs in production: add it to entry.
  • A tool or setup file that does not ship: add it to supportEntry.
  • A file that code loads with a computed path, such as a plugin or locale directory: add the pattern to dynamicallyLoaded.
  • A file of a framework without a plugin: write a custom plugin.