Dead code and architecture issue types
Learn what each dead code, dependency, architecture and framework finding of fallow means, and what to do about it.
You probably came here from a link in the output of fallow dead-code or fallow architecture. In the demo project, the unused export cancelOrder has the link https://fallow.tools/docs/explanations/dead-code/#unused-exports below it. The section at each link tells you what the finding means and what to do now. It also links to the rule page of the issue type. The rule page has an example, the fix and the facts: the default severity, the config key and the suppression comment.
A finding can be wrong when a tool loads the code in a way that the source text does not show. So check a finding before you remove code. Find why fallow reports a finding shows each trace command, and Dead code explains how fallow decides that code is unused.
Files and exports
Unused files
No entry point reaches the file: no reachable file imports it, and no plugin or entry pattern names it. In the demo project, nothing imports src/utils/legacy-currency.ts, but the file still shows in each search, and people still read it.
Check first: fallow dead-code --trace-file <path> shows the exports of the file, its imports and the files that import it. Then delete the file. When a tool or a script loads the file without an import, tell fallow about that loader.
Full reference: Unused files
Unused exports
A reachable file exports a name, and no other file imports it. In the demo project, nothing imports cancelOrder from src/services/orders.ts. People read each export as part of the API of the module, so they keep cancelOrder working each time they change Order.
Check first: fallow dead-code --trace src/services/orders.ts:cancelOrder shows the importers of the name, or the reason that it has none. Then remove the export, or remove the export keyword when the file uses the name itself. Code outside the project can import the name, for example when you publish the package. Then put /** @public */ on the line above the export, and fallow does not report it.
Full reference: Unused exports
Unused types
A type alias or an interface is exported, and no file uses it. The module then seems to offer a type that no code needs. Check first: fallow dead-code --trace <file>:<type> shows Namespace: type and the importers. Then remove the type, or remove its export keyword. When a package publishes the type for its users, keep it and put /** @public */ above it.
Full reference: Unused types
Namespace escapes
A file imports a module as a namespace (import * as Ns) and uses Ns as a whole value, for example Object.keys(Ns), { ...Ns } or fn(Ns). The code can then read any member through a computed key, so fallow counts each export of the module as used. One such line turns off the unused-export check for the whole module, also for a package entry with many export * lines.
This check reports the import and the count of exports that fallow does not check because of it. A binding that hides no export is not reported. Read the members by name, or import them by name, so that fallow checks the other exports. When the whole object is the intent, put // fallow-ignore-next-line namespace-escape above the import. Set the rule to error to fail a CI gate on a new escape. This check is off by default.
Full reference: Namespace escapes
Test-only exports
An exported value that production code does not use, while a test, story, fixture or test-helper file does. In the default mode the tests keep such an export alive, so fallow does not report it as an unused export. The export is often dead code that its tests keep alive, or a seam that a test uses to reach past the public interface of the module.
The check is off by default. Turn it on with "test-only-exports": "warn" in rules. It runs only without --production. A --production run reports the same export as an unused export. Only values are checked, not types. Each finding lists up to five test-side importers and tells whether each importer is next to the module (colocated_only).
Remove the export together with its tests, or test through the public functions of the module and make the item internal. A removal of the export alone breaks the tests, so fallow fix does not apply it.
Full reference: Test-only exports
Private type leaks
An exported function, class or value has a signature that uses a type of the same file, and that type is not exported. Users of the export cannot name the type. Export the type, or change the signature. This check is off by default.
Full reference: Private type leaks
Deprecated exports in use
An export has a @deprecated JSDoc tag, and reachable files still use it. The finding lists these files. Move each one to the replacement API, then remove the export. This check is off by default.
- A use in an unreachable file does not count, because that file has its own
unused-filefinding. - A deprecated export without uses is an unused export, with the note
(marked @deprecated). When the last use is gone, remove the export. - With
--changed-sinceand infallow audit, the finding counts only when the file that declares the export changed. A change that only adds a use does not bring the finding into scope. - The editor shows no diagnostic for this finding, because TypeScript already strikes through deprecated names.
Opt-in issue types has the fields of the finding.
Full reference: Deprecated exports in use
Duplicate exports
Two or more files export the same name. An auto-import can then pick the wrong file. Keep one export of the name, and import it from that file in all other places.
Full reference: Duplicate exports
Duplicate export aliases
One file exports one value under two or more names, for example export { a, a as b }. Keep one name, and change the imports of the other names.
Full reference: Duplicate export aliases
Unresolved imports
Fallow cannot find the file or the package of an import. The code probably fails when it runs. Correct the path, install the package, or add the path alias to tsconfig.json.
Full reference: Unresolved imports
Members
The issue types above look at whole files and exports. An export can be in use while a part of it is not. The next issue types look at one member of an enum, a class, a namespace or a store.
Unused enum members
No code uses a member of an enum. A reader of the enum then sees a value that the code never uses. Check first: fallow dead-code --trace <file>:<member> names the enum and the files that import it. Then remove the member. Keep it when stored data or another system still sends its value.
Full reference: Unused enum members
Unused class members
No code uses a public method or property of the class. A use through this inside the class counts as a use. Check first: fallow dead-code --trace <file>:<member> names the class and the files that import it. Then remove the member, or make it private. A member that a framework calls at run time can be a false positive: tell fallow about it.
Full reference: Unused class members
Unused protected class members
The class and its subclasses never read a protected member. Remove the member, or make it private. This check is off by default.
Full reference: Unused protected class members
Unused namespace members
No code reads a member of an exported TypeScript namespace. Remove the member, or remove its export keyword when only the namespace uses it.
Full reference: Unused namespace members. Namespace members has the rules for a use of a member and for an alias.
Unused store members
No code reads a state key, a getter or an action of a Pinia store. Remove the member. Suppress the finding when a Pinia plugin or a dynamic call uses the member.
Full reference: Unused store members
Dependencies
Code can also depend on a package that package.json does not list, or list a package that no code uses. Dependencies explains how fallow compares package.json with the imports.
Unused dependencies
A package in dependencies has no import, and no package.json script runs it. In the demo project, left-pad is such a package, and each install still downloads it. Check first: fallow dead-code --trace-dependency left-pad shows the imports of the package and the package.json that lists it. Then remove it from package.json. When another workspace imports it, move it to that workspace.
Full reference: Unused dependencies
Unused devDependencies
A package in devDependencies has no import, and no script or tool config uses it. Remove it from package.json.
Full reference: Unused devDependencies
Unused optionalDependencies
A package in optionalDependencies has no import. Make sure that no supported platform needs it, then remove it.
Full reference: Unused optionalDependencies
Type-only dependencies
A package in dependencies has only import type imports, so it never loads at run time. Move it to devDependencies. The rule has the severity warn by default, and fallow reports this issue type only in production mode.
Full reference: Type-only dependencies
Test-only dependencies
Only test files import a package in dependencies. Move it to devDependencies. Fallow does not report this issue type in production mode, because that mode leaves out the test files.
Full reference: Test-only dependencies
Dev dependencies in production
Production code imports a package of devDependencies as a value. An install without dev packages, such as npm install --omit=dev, then breaks that import. Move the package to dependencies, unless your build puts the package into its output.
Full reference: Dev dependencies used in production
Unlisted dependencies
Code imports a package that its package.json does not declare, as src/services/orders.ts of the demo project does with uuid. The import can work through a package that another workspace installs, and fail in a clean install. Declare the package in the package.json that owns the file.
Full reference: Unlisted dependencies
Unlisted binaries
A package.json script or a process call runs a command, and no installed or declared package supplies it. Add the package to devDependencies. When the operating system or the CI image supplies the command, add its name to ignoreBinaries.
Full reference: Unlisted binaries
Catalogs and overrides
Unused catalog entries
A package in a catalog of pnpm-workspace.yaml (or of a Bun root package.json) has no catalog: reference. Remove the entry. When a workspace pins the package with a version, change it to catalog: first.
Full reference: Unused catalog entries
Empty catalog groups
A named group under catalogs: has no packages. Remove the group.
Full reference: Empty catalog groups
Unresolved catalog references
A package.json uses catalog: or catalog:<name> for a package, and that catalog does not declare the package. The install fails. Add the package to the catalog, use another catalog, or pin a version.
Full reference: Unresolved catalog references
Dependency overrides
Fallow checks the override entries of pnpm, npm and Bun. Two issue types report problems with them.
Unused dependency overrides
An override targets a package that no workspace declares and the lockfile does not hold. Remove the override. When it pins a version of a package that the lockfile holds, fallow does not report it.
Full reference: Unused dependency overrides
Misconfigured dependency overrides
The key or the value of an override is not valid for the package manager, for example an empty value. Correct the entry, or remove it.
Full reference: Misconfigured dependency overrides
Override sources and the pnpm version
Each pnpm version reads other override sources. Fallow reads the pnpm version from the packageManager field of the root package.json. Fallow checks only the sources that this version reads. This applies to the override checks and to the catalog checks.
| Source | Fallow skips it for |
|---|---|
overrides in pnpm-workspace.yaml | pnpm before 10.5.1. Also pnpm 10 or earlier when the root package.json declares pnpm.overrides or resolutions. |
pnpm.overrides in the root package.json | pnpm 11 and later. |
resolutions in the root package.json (catalog checks) | pnpm 11 and later, and a project without a pnpm version. |
When fallow skips the overrides of pnpm-workspace.yaml, it records the pnpm-workspace-overrides-ignored workspace diagnostic. pnpm itself prints no warning for this case.
Architecture
The issue types above are about code that nothing uses. The next ones are about imports that exist but form a loop or cross a line that your team drew. fallow architecture reports them, and Architecture explains them.
Circular dependencies
Files import each other in a loop, directly or through other files. A file in the loop can then read a value before the value exists. Move the shared code to a new file, or reverse one import. Fallow does not report a loop of import type imports.
Full reference: Circular dependencies
Re-export cycles
Barrel files re-export from each other in a loop, or one barrel file re-exports from itself. No file in the loop declares the names, so an import from the loop gets nothing. Remove one export ... from statement of the loop.
Full reference: Re-export cycles
Package cycles
The workspaces of a monorepo import each other in a loop. A build tool then cannot build them in order. Move the shared code to a package that both import, or reverse the imports of one step.
Full reference: Package cycles
Boundary violations
A file imports a file of a zone that your boundaries config does not allow. Change the import. When the import is correct, change the boundary rules. Two related issue types use the same suppression token: a file outside each zone while boundaries.coverage.requireAllFiles is on, and a call that boundaries.calls.forbidden names.
Full reference: Boundary violations, Boundary coverage, Boundary call violations
Policy violations
A call, an import or an export breaks a rule of a rule pack in your rulePacks config. The message of the finding names the rule and the allowed alternative. Follow it, or limit the rule to other files.
Full reference: Policy violations
Framework rules
A framework adds rules that plain imports do not show, for example which exports a "use client" file may have. Fallow runs these issue types only when the project declares the framework as a dependency. React and Next.js shows a Next.js example, and Built-in plugins names the package that turns on each plugin.
Invalid client exports
A "use client" file of a Next.js app exports a name that only a server file can export, such as metadata or GET. The build fails. Move the export to a file without the directive.
Full reference: Invalid client exports
Mixed client/server barrels
One barrel file re-exports a "use client" file and a server-only file. An import from the barrel can then carry server code into the client, or the reverse. Split the barrel into a client barrel and a server barrel.
Full reference: Mixed client/server barrels
Misplaced directives
A "use client" or "use server" line comes after an import or another statement. The bundler then ignores it without a message. Move the directive to the first line of the file.
Full reference: Misplaced directives
Route collisions
Two or more route files of a Next.js App Router resolve to the same URL, for example through two route groups. The build fails. Move or merge files, so that each URL has one route file.
Full reference: Route collisions
Dynamic segment name conflicts
Two dynamic route segments at the same position use different names, such as [id] and [slug]. The build passes, and the route fails on its first request. Give the segments one name.
Full reference: Dynamic segment conflicts
Unused server actions
No code calls an export of a "use server" file. Next.js still accepts requests for the action. Call the action from code, or remove it.
Full reference: Unused server actions
Unprovided injects
A Vue inject(KEY) or a Svelte getContext(KEY) reads a key that no provide() or setContext() supplies. The read returns undefined at run time. Add the provider, or remove the read.
Full reference: Unprovided injects
Unrendered components
A barrel file keeps a component reachable, and no file renders it. Render the component where it belongs, or delete it and its re-export.
Full reference: Unrendered components
Unused component props
A component declares a prop and never reads it. Use the prop, or remove it from the declaration.
Full reference: Unused component props
Absent component props
A component reads an optional prop, and no known caller passes it. The default value then always applies. Decide if the prop still has a purpose. This check is off by default.
Fallow reports a prop only when it knows at least one reachable caller and can see each caller of the component. It skips a component that a package exports for users outside the project, because those callers are unknown. A required prop that a caller leaves out is a task for the type checker, and a prop that the component never reads is an unused component prop.
- The check covers React, Preact, Solid, Qwik, Vue, Svelte, Astro, Angular, Lit and Ember components.
- A caller that passes
compact={false}orcompact={undefined}supplies the prop. - A spread supplies props only when fallow can see each key of the object: a literal, or a local constant that the code does not change. An unknown spread, a dynamic component, a wrapper that fallow does not know, or a prop that the component passes on stops the check for that component.
- Fallow does not remove a prop. The finding does not prove that conditional UI never runs.
Full reference: Absent optional component props
Unused component emits
A Vue component declares an event with defineEmits and never emits it. Emit the event where it must fire, or remove it from the declaration.
Full reference: Unused component emits
Unused Svelte events
A Svelte component dispatches an event with createEventDispatcher, and no component listens for it. Add the listener, or remove the dispatch.
Full reference: Unused Svelte events
Unused component inputs
An Angular component declares an input and never reads it in its class or its template. Read the input, or remove it.
Full reference: Unused component inputs
Unused component outputs
An Angular component declares an output and never emits it. Emit the output where it must fire, or remove it.
Full reference: Unused component outputs
Unused load data keys
A route data function returns a key that no page reads. The rule checks a SvelteKit load() function and a React Router or Remix loader. The server still gets the data on each request. Remove the key and its fetch, or read the key in the page.
The rule skips a React Router or Remix resource route: a route module with a loader and no default export component. It also skips the body of a Response.json(...) return. An HTTP client reads that body, not a page.
Full reference: Unused load data keys
Prop drilling
A React prop goes through a chain of components that only pass it on. Move the component that uses the prop closer to the data, or give the value through a context. This check is off by default.
Full reference: Prop drilling
Thin wrapper
A React component only renders one other component with all of its props. Render the other component directly, and delete the wrapper. This check is off by default.
Full reference: Thin wrappers
Duplicate prop shape
Three or more React components in two or more files declare the same set of prop names. Make one shared props type. This check is off by default.
Full reference: Duplicate prop shapes
Unused Effect layers
An Effect Layer is used only by other layers that nothing uses, so it never runs. Remove the unused layers, or provide the layer to a runtime.
Full reference: Unused Effect layers
Unused tagged errors
Types and catchTag handlers name an Effect tagged error, and no code creates it. The failure never happens. Fail with the error where the problem occurs, or remove the class and its handlers.
Full reference: Unused tagged errors
Unproduced catch tags
A catchTag handler waits for an error tag of the project that no code produces. The handler never runs. Remove the handler, or fail with the error where the problem occurs.
Full reference: Unproduced catch tags
Functions
Constant parameters
Each call of a function passes the same value for a parameter, or no call passes an optional parameter. A branch that tests the parameter can then never run. Remove the parameter or the dead branch, or keep the parameter when it is a deliberate option. This check is off by default.
Fallow reports two reasons. With identical-argument, each call passes the same literal, such as true, null, a number or a string, or the same const with a literal value or enum member. With never-passed, the parameter is optional or has a default, and no call passes it. When the parameter is an object pattern, such as { retries = 3, signal }, fallow checks each key on its own. It does that only when each call passes an object literal without a spread or a computed key, and the parameter has no default or the default {}.
The finding claims that fallow sees each call of the function. So fallow does not report a function when one of these is true:
- The function is in the public API of a package, is an export of an entry point, or a plugin marks the export as used.
- A dynamic import, a
require, a CommonJS export or a framework auto-import can reach its module. - A module loads code from a path that fallow cannot resolve, such as
import(name), and reads a name of the same function on the result. - An import with a query, such as
./runtime.ts?raw, or a webpack loader such asraw-loader!./runtime.ts, reads its module as text. - Code uses the function as a value: a callback, an object property, an alias, or a call through
call,applyorbind. - A template, a component file or an inline script can call the function, or its module has a direct
evalor can be a classic script. - A file of the project has a parse error.
- The function reads
arguments, has overloads or decorators, is a generator, or code assigns its binding again. - The function has fewer than 2 calls.
Fallow also skips a rest parameter, an array pattern and a parameter that the function writes. A recursive call that passes the parameter on unchanged does not count as a call. Without type-aware analysis, the rule checks only module-scope functions: function declarations and const bindings with a function. Fallow does not report a function that a test file declares. In the default mode, a call in a test file counts. With --production, fallow ignores test files.
Opt-in issue types has the fields of the finding.
Full reference: Constant parameters
With type evidence
With type-aware analysis, the constant parameter check also reports a default value that no call needs, and it checks the methods of exported classes. These findings show (type evidence) in the output. A type does not prove a value at run time, so check the calls before you remove a default.
unused-default: the parameter has a default, and each call passes a value whose type excludesundefined. The default never applies.- A method of an exported class can get
never-passedorunused-default. The checker finds the calls through the type of the receiver, for examplethis.store.save(id).
Without --type-aware, the result of the rule does not change.
Full reference: Constant parameters
Suppressions
Stale suppressions
A fallow-ignore comment or an @expected-unused tag matches no finding. The code changed, and the comment stayed. Remove the comment. When the comment names an unknown issue type, correct the name. A related issue type reports a suppression comment without a reason, when your config requires one.
Full reference: Stale suppressions, Missing suppression reasons
Related
- Find why fallow reports a finding: check a finding before you remove code.
- Dead code: how fallow finds unused code.
- Suppress a finding: keep code that fallow reports, on purpose.