Skip to content
Fallow home
All docs pages

Docs home

fallow dead-code

Find the options, output fields, baseline format and exit codes of fallow dead-code, which finds unused files, exports and dependencies.

fallow dead-code reports the files, exports, dependencies and members that no entry point reaches.

For the concepts and the workflow, read Dead code.

Synopsis

fallow dead-code [OPTIONS] [PATH]

fallow check is a hidden alias of fallow dead-code.

Options

ArgumentDescription
[PATH]Scope reported findings to this file or directory (default: whole project). The full project graph is still built; only reported items are narrowed

Issue types

OptionDescription
--unused-filesOnly report unused files
--unused-exportsOnly report unused exports
--unused-depsOnly report dependency findings: unused dependencies, dev dependencies and optional dependencies, plus type-only, test-only and dev-in-production dependencies
--unused-typesOnly report unused type exports
--private-type-leaksOpt in to private type leak API hygiene findings and only report that issue type
--deprecated-exports-in-useOpt in to @deprecated exports that are still in use and only report that issue type
--unused-enum-membersOnly report unused enum members
--unused-class-membersOnly report unused class members
--unused-store-membersOnly report unused store members
--unused-namespace-membersOnly report unused namespace members
--unused-protected-class-membersOnly report unused protected class members
--namespace-escapesOnly report namespace imports that the code uses as a whole value (enables this rule)
--test-only-exportsOnly report exported values that only test-side files use (enables this rule)
--unprovided-injectsOnly report unprovided injects
--unrendered-componentsOnly report unrendered components
--unused-component-propsOnly report unused component props
--absent-component-propsReview optional props omitted by known reachable callers (enables this rule)
--constant-parametersReview parameters that each visible call passes in one way (enables this rule)
--unused-component-emitsOnly report unused component emits
--unused-component-inputsOnly report unused component inputs
--unused-component-outputsOnly report unused component outputs
--unused-svelte-eventsOnly report unused Svelte dispatched events
--unused-effect-layersOnly report Effect layers composed only into unused layers
--unused-tagged-errorsOnly report Effect tagged errors that no code produces
--unproduced-catch-tagsOnly report catchTag handlers for a tag that no code produces
--unused-server-actionsOnly report unused server actions
--unused-load-data-keysOnly report unused SvelteKit load() data keys
--unresolved-importsOnly report unresolved imports
--unlisted-depsOnly report unlisted dependencies
--unlisted-binariesOnly report binaries that no installed package provides
--duplicate-exportsOnly report duplicate exports
--duplicate-export-aliasesOnly report bindings that one file exports under two or more names
--circular-depsOnly report circular dependencies. Deprecated alias: use fallow architecture --cycles
--re-export-cyclesOnly report re-export cycles. Deprecated alias: use fallow architecture --cycles
--package-cyclesOnly report dependency cycles between workspace packages. Deprecated alias: use fallow architecture --cycles
--boundary-violationsOnly report boundary violations. Deprecated alias: use fallow architecture --boundaries
--policy-violationsOnly report rule-pack policy violations. Deprecated alias: use fallow architecture --policy
--stale-suppressionsOnly report stale suppressions
--unused-catalog-entriesOnly report unused pnpm catalog entries
--empty-catalog-groupsOnly report empty pnpm catalog groups
--unresolved-catalog-referencesOnly report unresolved pnpm catalog references
--unused-dependency-overridesOnly report unused package-manager dependency overrides
--misconfigured-dependency-overridesOnly report misconfigured package-manager dependency overrides
--include-dupesAlso run duplication analysis and cross-reference with dead code

Tracing

OptionDescription
--trace <FILE:EXPORT>Trace why an export is used/unused (format: FILE:EXPORT_NAME)
--trace-file <PATH>Trace all edges for a file (imports, exports, importers)
--trace-dependency <PACKAGE>Trace where a dependency is used
--impact-closure <PATH>Compute the impact closure for a file (the transitive affected-but-not-in-diff set + coordination gap). Walks reverse-deps and re-export chains.
--symbol-impact <FILE:EXPORT>Compute exact-symbol consumers, affected files, and targeted tests

Scope

OptionDescription
--file <PATH>Only report issues in the specified file(s). Accepts multiple values.
--finding-id <ID>Only report the findings with these finding_id values. Repeat the flag or pass a comma-separated list.

Output

OptionDescription
--top <TOP>Show only the top N items per category. Human output only: the JSON, SARIF, and CodeClimate envelopes drive exit codes and CI baselines, so they always carry every finding and a consumer slices the arrays itself

The global options are in these groups: Project, Output, Scope, Baselines, Gates, Duplication, Type-aware, Performance.

Option details

  • A filter option such as --unused-exports reports only its issue type. You can give more than one filter. When a filter asks for a rule that the config sets to off, fallow does not run that check. It prints a note on stderr, and the JSON output gets a requested-rule-off entry in workspace_diagnostics.
  • Without a filter option, fallow dead-code also reports the findings of fallow architecture: cycles, boundary violations and policy violations.
  • --file leaves out the findings that belong to no file, for example an unused dependency. It prints a warning for a path that does not exist.
  • --symbol-impact needs --type-aware. Without it, fallow prints Error: --symbol-impact requires --type-aware.

Gate on dependency findings

--unused-deps selects six issue types. Three are unused packages: unused-dependencies, unused-dev-dependencies and unused-optional-dependencies. Three are used packages in the wrong section of package.json: type-only-dependencies, test-only-dependencies and dev-dependencies-in-production. Only the unused packages are candidates for removal.

To fail only when a package is unused, run the filter without --ci. The exit code then counts only the rules at error:

fallow dead-code --unused-deps --quiet
  • A project with only used packages exits with code 0, also when a used package is in the wrong section.
  • A project with an unused package in dependencies exits with code 1.
  • unused-dev-dependencies and unused-optional-dependencies are at warn by default. They do not fail the run until you set them to error in rules.

--ci sets --fail-on-issues, so a rule at warn also fails the run, and a used package in the wrong section exits with code 1. To keep these findings out of the gate, give a second config file with -c. This file extends the main config file and sets the placement rules to off:

{
  "extends": [".fallowrc.json"],
  "rules": {
    "dev-dependencies-in-production": "off",
    "type-only-dependencies": "off",
    "test-only-dependencies": "off"
  }
}
fallow dead-code --unused-deps --ci -c .fallowrc.ci.json

This command exits with code 0 on a project with only used packages, and with code 1 on a project with an unused package. It gives no requested-rule-off note: for --unused-deps, fallow gives the note only for the three rules of unused packages.

Cross-reference with duplication

--include-dupes also runs the duplication analysis, and compares its clone groups with the dead code findings. It lists each clone instance that is in an unused file, or that overlaps an unused export or an unused type. When you delete such code, you remove dead code and duplication in one change.

● Duplicated + Unused (safe to delete)

  src/utils/old-invoice.ts:4-20 (entire file is unused)

  1 combined finding: 1 in unused file, 0 overlapping unused exports

Fallow prints this section only in the human format, and not with --quiet. The JSON output and the other formats do not change, and the section does not change the exit code.

Output

  3 entry points detected (2 package.json, 1 plugin)

── Unused Code ─────────────────────────────────────

● Unused files (1)
  src/utils/legacy-currency.ts
  Files not reachable from any entry point
  https://fallow.tools/docs/explanations/dead-code/#unused-files

● Unused exports (3)
  src/lib/format.ts
    :3 formatPercent
  src/lib/index.ts
    :1 formatPercent (re-export)
  src/services/orders.ts
    :18 cancelOrder
  Exported symbols with no known consumers
  https://fallow.tools/docs/explanations/dead-code/#unused-exports
  To auto-fix: fallow fix --dry-run
  To suppress: // fallow-ignore-next-line unused-export

── Dependencies ─────────────────────────────────────

● Unused dependencies (1)
  left-pad
  Listed in dependencies but never imported
  https://fallow.tools/docs/explanations/dead-code/#unused-dependencies

● Unlisted dependencies (1)
  uuid
  Packages imported in code but missing from package.json
  https://fallow.tools/docs/explanations/dead-code/#unlisted-dependencies

✗ 1 file · 3 exports · 1 unused dependency · 1 unlisted dependency (0.02s)
  • The first line counts the entry points by source.
  • Each section is one issue type. It lists the findings, then a description, a link, and the commands that fix or suppress a finding.
  • (re-export) marks the line of a barrel file when no file imports the name through that barrel file. Remove that line. Remove the original export only when the list also shows it, because a direct import can still use it.
  • The last line counts the findings of each issue type, and gives the run time.

With --format json, the output has these top-level fields:

FieldContent
kind"dead-code". A --group-by run gives "dead-code-grouped".
schema_version, version, elapsed_msThe version of this output format, the fallow version and the run time.
total_issuesThe number of findings in all arrays.
summaryThe number of findings for each issue type. Each key is always present.
entry_pointsThe number of entry points, in total and for each source.
unused_files, unused_exports, and the other issue arraysOne array for each issue type. An opt-in issue type has its array only when its rule is on.
cascade_hiddenThe number of unused exports, types and members in unused files that the report hides. Absent when it is 0. --show-cascade reports them.
baseline, baseline_stalenessThe entries of the loaded baseline, how many matched, and how many are stale. Present only with --baseline.
regressionThe result of --fail-on-regression.
finding_id_queryThe answer to --finding-id. See Finding ids.
gate_outcomesOne entry for each gate of the run, with status and enforced. Always present.
request_outcomesThe result of each scope request. See Request outcomes.
workspace_diagnosticsProblems with the project setup, for example a config pattern that matches nothing.
next_stepsCommands to run next.
baseline_deltasThe change of each count against the loaded baseline. Present only in a baseline run.
package_baselinesThe Git ref that each workspace package used as its base. Absent when no package base applies.
shared_stateThe shared-state inventory of fallow architecture. It does not count in total_issues or in a gate. Optional.
_metaMetadata of the run, for example telemetry.analysis_run_id.

Each finding has path, a position (line, col), a finding_id, an effective_severity (error or warn) and an actions array. The JSON output reference has each field.

Actions

Each action in the actions array of a finding has these fields:

FieldContent
typeThe action, for example remove-export, delete-file, remove-dependency, suppress-line, suppress-file or add-to-config.
auto_fixabletrue when fallow fix applies the action. Fallow sets it for each finding, so one type can be true on one finding and false on another.
descriptionWhat the action does.
commentThe suppression comment to add. Optional.
noteMore context, when fallow fix cannot apply the action. Optional.
config_key, value, value_schemaThe config key to change, the value to write, and the URL of the JSON Schema of the value. Optional.
scope"per-location" on a suppress action that applies to one location of a finding. Optional.

The guards of fallow fix decide auto_fixable for each finding. So filter on the value of each action, not on type. These actions can have another value on another finding:

Actionauto_fixable
remove-catalog-entrytrue only when the hardcoded_consumers array of the finding is empty. Else a workspace package still pins a version of the package, and fallow fix skips the entry.
remove-dependency, move-dependencyWhen used_in_workspaces is not empty, the first action is move-dependency with false. Else it is remove-dependency with true. See Unused dependencies in a monorepo.
add-to-config for ignoreExports (duplicate exports)true when a config file exists, or when no config file exists and the directory is not in a monorepo package. false in a monorepo package without a config file at the workspace root.
remove-export of an unused export or unused type in a generated filefalse, with the reason in note. The generator writes the file again, so fallow fix keeps the file. The finding has no suppress-line action. It has an add-to-config action with the ignoreExports rule for the file.
add-to-config for ignoreExports (unused exports and unused types)Always false. A finding has it when its file is generated code. An unused export also has it when its file is in a shadcn/ui folder that a components.json names. The human report prints one hint with the config entry for each group of 3 findings or more.
update-catalog-referenceAlways false. fallow fix cannot switch a catalog reference.
suppress-line, suppress-fileAlways false.

A dependency finding has an add-to-config action with config_key: "ignoreDependencies" and the package name in value, not a suppression comment.

Finding ids

Each finding has a finding_id of the form dc1:<rule>:<16 hex digits>, for example dc1:unused-export:b650995c7b5b87c1. Fallow computes it from the rule, the root-relative path and the name. A line change, a new format or a new order of declarations keeps the id. A new file name or a new symbol name gives a new id. When two findings have the same subject, the second id gets the suffix ~1.

In SARIF output, the partialFingerprints of a dead code result have the key fallowFinding/v1 with the finding_id. Use it to join a SARIF result to its JSON finding. A finding with one result for each location, for example an unlisted dependency with one result for each import, has no such key, because one id then names more than one result.

Finding id query

--finding-id reports only the findings with the ids that you give. The JSON output then has a finding_id_query object:

FieldContent
requestedThe requested ids, in the order of the arguments.
foundThe requested ids that the report holds.
missingThe requested ids that the report does not hold.
filteredThe requested ids that a filter of this run removed. These findings still exist.
conclusivetrue when no option of the run can hide a finding that still exists.
inconclusive_reasonsThe reasons when conclusive is false. An open set of names.
analysis_fingerprintA hash (af1:<16 hex digits>) of the inputs other than the source code: the fallow version, the config, the plugins, and the manifest and tsconfig files.

A missing id means that the finding is gone only when conclusive is true and the analysis_fingerprint is the same as in your earlier run. A scope option, a filter option, production mode, --baseline or a rule at off makes the answer inconclusive. A malformed id exits with code 2.

Trace output

--trace FILE:EXPORT shows why an export is used or unused. In the JSON output, each entry of direct_references has these fields:

FieldContent
from_file, kind, lineThe consumer, the kind of import, and the 1-based line of the import.
search_visibilityfound: a whole-word text search for the export name finds the consumer. renamed: the consumer has the name, but uses the export under another name. missed: the consumer does not have the name.
reasonWhy a search does not find the use: import-alias, default-import, re-export-alias, namespace-use, dynamic-import or pass-through.
search_asThe name to search for in this consumer. Absent when no single name finds the use.

The trace object also has is_used, reason, re_export_chains (each barrel file that exports the name again) and plugin_credits (the plugin and the file pattern that mark the export as used, for example a Next.js page).

  • pass-through marks a consumer that only exports the name again, for example a barrel file or import { foo } from "./x"; export { foo }. Such a consumer is found: a change of the export needs no edit there, and the trace lists the files that import through it. A .vue, .svelte, .astro or .mdx file that imports the export is never pass-through, because a template can use the binding.
  • A match in a comment or a string counts as found, because a text search finds it too. The fields are absent when fallow cannot read the source of the consumer.
  • When code uses the export as a type and as a value, direct_references_by_namespace gives the references of each namespace. namespace and direct_references describe only the namespace that wins. The field is absent when only one namespace has references.
  • For a class member, --trace FILE:MEMBER gives owner_direct_references: the references of the class. The search fields there check the name of the class, not the name of the member.
{
  "export_name": "default",
  "is_used": true,
  "plugin_credits": [
    { "plugin": "nextjs", "pattern": "app/**/page.{ts,tsx,js,jsx}" }
  ],
  "reason": "Used by the framework: the nextjs plugin marks this export as used"
}

--trace-file gives plugin_credits on each entry of exports. A credit for an export that a tool reads from its config file, such as a Serverless handler, counts only with --include-entry-exports, as in the analysis. For an entry point that a package.json script runs, --trace-file gives the script name in entry_script, and the human output names it too:

  REACHABLE scripts/seed.js (entry point, package.json script `seed`)

The coordination_gap entries of --impact-closure have the same search_visibility, reason and search_as fields, and a search_symbol field.

Unused dependencies in a monorepo

A workspace can declare a package that only another workspace imports. The finding then has used_in_workspaces, the roots of the workspaces that import the package:

{
  "package_name": "lodash-es",
  "location": "dependencies",
  "path": "packages/shared/package.json",
  "line": 1,
  "used_in_workspaces": ["packages/consumer"],
  "actions": [
    {
      "type": "move-dependency",
      "auto_fixable": false,
      "description": "Move this dependency to the workspace package.json that imports it",
      "note": "fallow fix will not remove dependencies that are imported by another workspace"
    }
  ]
}

The human output shows the workspaces after the package name:

  lodash-es (packages/shared/package.json; imported in packages/consumer)

The package is in the wrong workspace. Move it to the workspace that imports it. fallow fix does not remove it. A finding of the root package.json can have declared_and_imported_in instead: the workspaces that import the package and declare it in their own package.json, so the root declaration stays unused. Both fields are absent when they are empty.

Stale suppressions

--stale-suppressions reports only the stale suppressions. Fallow checks two origins:

OriginStale when
// fallow-ignore-next-line, // fallow-ignore-fileThe comment matches no finding on the next line or in the file.
/** @expected-unused */Code imports the tagged export.
● Stale suppressions (2)
  src/lib/parse.ts:1:0 // fallow-ignore-next-line unused-export (no unused-export issue found on the next line)
  src/lib/parse.ts:5:13 @expected-unused on parseCents (parseCents is now used)

In the JSON output, each entry of stale_suppressions has an origin object. A comment has type: "comment", issue_kind (absent for a comment without a token), is_file_level, and reason when the comment has one. A range marker also has is_range: true. A tag has type: "jsdoc_tag" and export_name:

{
  "path": "src/lib/parse.ts",
  "line": 5,
  "col": 13,
  "origin": {
    "type": "jsdoc_tag",
    "export_name": "parseCents"
  },
  "finding_id": "dc1:stale-suppression:282c6c9ce1c55017",
  "effective_severity": "warn"
}

Re-export cycles

The re_export_cycles array has one entry for each loop of barrel files. files lists the files of the loop in sorted order, and kind gives the shape of the loop:

kindShape
multi-nodeTwo or more files that export from each other.
self-loopOne file that exports from itself, for example export * from "./index" in index.ts.
● Re-Export Cycles (2)
  src/api/index.ts
    Cycle (2 files):
      - src/api/index.ts
      - src/api/internal/index.ts
    To fix: remove one `export * from` statement on any member file.

  src/utils2/index.ts
    Self-loop (1 file):
      - src/utils2/index.ts
    To fix: remove the `export * from './'` (or equivalent) inside this file.

The compact format writes one line for each loop, for example re-export-cycle:src/utils2/index.ts:3:src/utils2/index.ts (self-loop). The field after the path is the line of the export ... from statement that closes the loop, and 0 means that the line is not known. A file-level suppression comment in one file of the loop hides the finding. Re-export cycles explains the finding.

Opt-in issue types

The JSON output always has the arrays private_type_leaks and deprecated_exports_in_use, and their counts in summary. Fallow fills them only when the rule is on. The arrays absent_component_props and constant_parameters are present only when they have a finding. The explanations of each issue type give the rules that decide a finding.

An entry of deprecated_exports_in_use has these fields, next to path, export_name, line and col:

FieldContent
deprecated_reasonThe text of the @deprecated tag, at most 200 characters. Absent for a tag without text.
consumer_countThe exact number of uses in reachable files.
consumersThe first 10 uses, sorted by path and line, each with path, line, col and kind.
public_apitrue when the export is in an entry point, or a re-export chain takes it to an entry point. Fallow then makes no claim that you can remove it.

The next_steps array names fallow dead-code --trace <file>:<export> for the deprecated export with the most uses (id trace-deprecated-export). The trace lists each use. With --production, an unused_exports or unused_types entry that a test, story or fixture file imports has a test_importers object, and its remove-export action has auto_fixable: false. See Exports that test files import. An unused_exports entry of a deprecated export has deprecated: true, and deprecated_reason when the tag has text. The human output adds (marked @deprecated).

An entry of absent_component_props has these fields:

FieldContent
component_name, prop_name, frameworkThe component and the prop. framework is, for example, react, vue or angular.
path, line, colThe declaration of the prop.
has_defaulttrue when the declaration gives a default value.
inspected_call_sitesEach reachable caller that fallow read, with path, line and col.
explanationWhat the finding means and what static analysis does not prove.

An entry of constant_parameters has these fields:

FieldContent
function_name, parameter_name, parameter_indexThe function and the parameter. For a method of an exported class, function_name is Class.method.
option_keyThe property key, when the finding is about one key of an object pattern. parameter_name is then the local name of the key, for example abort for { signal: abort }.
path, line, colThe parameter, or the binding of the key.
reasonidentical-argument, never-passed, or unused-default (only with --type-aware).
valueFor identical-argument: kind (boolean, null, undefined, number, string or binding) and text. A binding is a const with a literal value or an enum member, for example DEFAULT_LIMIT or Mode.Grid.
evidence"type-aware" when the finding needs the TypeScript checker. The human output then adds (type evidence).
optional, has_defaultThe ? marker and the default value of the parameter.
condition_readsThe number of if, ?:, while, do and for tests whose test is the parameter, !parameter or !!parameter.
call_site_count, inspected_call_sitesThe number of calls, and the first 20 calls with path, line and col.
explanationWhat the finding means and what static analysis does not prove.
● Constant parameters (2)
  src/lib/amount.ts (2)
    :1 formatAmount(compact): every call passes true (2 calls, 1 condition read)
    Callers: src/index.ts:22, src/index.ts:22
    :1 formatAmount(locale): no call passes it, so it is always undefined (2 calls)
    Callers: src/index.ts:22, src/index.ts:22

Option keys

Most functions with many settings take one options object. When the parameter is an object pattern, the constant-parameter rule reads each key of the pattern as its own subject:

export const request = (url: string, { retries = 3, signal }: Options = {}) => {
  /* ... */
};

// each call in the project:
request(path, { signal });

No call sets retries, so fallow reports retries with never-passed: the default 3 always applies. When each call sets a key to the same value, the reason is identical-argument. A finding about a key has option_key, the property key. parameter_name is the local binding of the key: abort for { signal: abort }.

Fallow reads the keys only when it can see each of them:

  • The argument is an object literal with no spread, no computed key, no numeric key and no __proto__ key. Each other argument, for example a variable, gives no key finding.
  • The parameter has no default, or the default {}. A default with keys can set a key that no caller passes.
  • The key is static, its value is a plain binding with or without a default, and the function does not write the binding. A key that each object inherits, such as toString, is skipped.

A parameter typed as an object, such as options: Options followed by options.retries, gives no key finding.

Namespace members

An unused-namespace-member finding is a member of export namespace N { ... } or export declare namespace N { ... } in a .ts file that no code reads. A nested member has a dotted name, for example Outer.Inner.x. When a nested namespace is unused, fallow reports the namespace and not each member in it. Fallow also checks a namespace that merges with a class, a function or an enum of the same name.

Fallow counts these uses of a member:

  • a qualified read as a value or as a type: N.a, N.Inner.T, typeof N.a;
  • destructuring: const { a } = N;
  • an import alias: import x = N.a;
  • a read through a namespace import: ns.N.a;
  • a reference inside the namespace body: export const b = a;
  • a read through a const alias: for const M = N or const I = N.Inner, fallow reads M.a as N.a.

A re-export of N carries the reads of its consumers. When the namespace value leaves its chain, each member below it counts as used. Examples are an argument (register(N)), a spread, Object.keys(N), a value in an array or an object, and an exported alias. The same rule applies to a nested namespace (register(N.Inner)).

Fallow does not check declaration files (.d.ts), declare global, module augmentations (declare module "x"), namespaces without export, or a namespace that an entry point exports.

Config warnings in each format

Fallow compares some config entries with the result of the run. Warnings about the config explains them. In the JSON output, each warning is an entry of workspace_diagnostics:

kindCause
ignore-dependencies-glob-unmatchedAn ignoreDependencies glob matches no declared dependency.
ignore-findings-pattern-unmatchedAn ignoreFindings pattern matches no finding.
ignore-exports-file-unmatchedAn ignoreExports file glob matches no file.
ignore-exports-name-unmatchedAn ignoreExports name is not an export of a file that the glob matches.
duplicates-ignore-unmatchedA duplicates.ignore glob matches no file.
health-ignore-unmatchedA health.ignore glob matches no file.
entry-pattern-redundantAn entry pattern names files that are entry points without it.
ignore-dependencies-entry-redundantAn ignoreDependencies entry hides no finding.
ignore-patterns-entry-redundantAn ignorePatterns glob removes no file that fallow analyzes.
requested-rule-offA filter option asks for a rule that the config sets to off.
{
  "path": ".",
  "kind": "ignore-findings-pattern-unmatched",
  "pattern": "src/legcy/**",
  "message": "ignoreFindings pattern 'src/legcy/**' matched no finding in this run, so it has no effect. A pattern is a glob relative to the project root. Fix the pattern, or remove it from the config."
}

The other formats show the same warnings in these places:

FormatPlace
sarifruns[0].invocations[0].toolConfigurationNotifications, at the level note, with the same kind as descriptor.id.
markdown, github-summary, the comment formats and the review formatsA section, for example ## Unmatched config patterns.
human, compact and the other formatsA Note: line on stderr. --quiet hides it.

Baseline file

--save-baseline writes a JSON file with "kind": "dead-code", "identity": "dc1" and one array of keys for each issue type. A key has the form <rule>:<path>:<name>, for example unused-export:src/lib/format.ts:formatPercent, or <rule>:<path> for a file, for example unused-file:src/utils/legacy-currency.ts. A key has no line and no column, so a line shift does not make it stale. A key that occurs N times hides at most N current findings. A save to a file of another kind exits with code 2. Baselines shows the workflow.

Exit codes

CodeMeaning
0No finding at error severity, and no other gate failed.
1A finding has a rule at error, in every output format. --fail-on-issues and --ci also count the rules at warn. --fail-on-regression, --fail-on-stale-baseline, --fail-on-baseline-growth and --fail-on-parse-error also set code 1.
2Invalid input, for example a malformed --finding-id or an unknown baseline identity.

The bare fallow run has another rule for the machine formats. See The bare run. Exit codes has the codes that all commands share.

Examples

# Report all dead code findings
fallow dead-code

# Report only unused exports, as JSON for a script
fallow dead-code --unused-exports --format json --quiet

# Report only the findings in two files
fallow dead-code --file src/utils.ts --file src/helpers.ts

# Show why an export is reported
fallow dead-code --trace src/lib/format.ts:formatPercent

# Show where a package is imported
fallow dead-code --trace-dependency lodash

# Check if one finding still exists
fallow dead-code --finding-id dc1:unused-export:b650995c7b5b87c1 --format json --quiet

# Save the current findings, then fail only on new findings
fallow dead-code --save-baseline fallow-baselines/dead-code.json
fallow dead-code --baseline fallow-baselines/dead-code.json
  • Dead code: how fallow decides that code is unused.
  • fallow fix: remove unused exports and dependencies.
  • Issue types: each issue type and its rule page.