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
| Argument | Description |
|---|---|
[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
| Option | Description |
|---|---|
--unused-files | Only report unused files |
--unused-exports | Only report unused exports |
--unused-deps | Only report dependency findings: unused dependencies, dev dependencies and optional dependencies, plus type-only, test-only and dev-in-production dependencies |
--unused-types | Only report unused type exports |
--private-type-leaks | Opt in to private type leak API hygiene findings and only report that issue type |
--deprecated-exports-in-use | Opt in to @deprecated exports that are still in use and only report that issue type |
--unused-enum-members | Only report unused enum members |
--unused-class-members | Only report unused class members |
--unused-store-members | Only report unused store members |
--unused-namespace-members | Only report unused namespace members |
--unused-protected-class-members | Only report unused protected class members |
--namespace-escapes | Only report namespace imports that the code uses as a whole value (enables this rule) |
--test-only-exports | Only report exported values that only test-side files use (enables this rule) |
--unprovided-injects | Only report unprovided injects |
--unrendered-components | Only report unrendered components |
--unused-component-props | Only report unused component props |
--absent-component-props | Review optional props omitted by known reachable callers (enables this rule) |
--constant-parameters | Review parameters that each visible call passes in one way (enables this rule) |
--unused-component-emits | Only report unused component emits |
--unused-component-inputs | Only report unused component inputs |
--unused-component-outputs | Only report unused component outputs |
--unused-svelte-events | Only report unused Svelte dispatched events |
--unused-effect-layers | Only report Effect layers composed only into unused layers |
--unused-tagged-errors | Only report Effect tagged errors that no code produces |
--unproduced-catch-tags | Only report catchTag handlers for a tag that no code produces |
--unused-server-actions | Only report unused server actions |
--unused-load-data-keys | Only report unused SvelteKit load() data keys |
--unresolved-imports | Only report unresolved imports |
--unlisted-deps | Only report unlisted dependencies |
--unlisted-binaries | Only report binaries that no installed package provides |
--duplicate-exports | Only report duplicate exports |
--duplicate-export-aliases | Only report bindings that one file exports under two or more names |
--circular-deps | Only report circular dependencies. Deprecated alias: use fallow architecture --cycles |
--re-export-cycles | Only report re-export cycles. Deprecated alias: use fallow architecture --cycles |
--package-cycles | Only report dependency cycles between workspace packages. Deprecated alias: use fallow architecture --cycles |
--boundary-violations | Only report boundary violations. Deprecated alias: use fallow architecture --boundaries |
--policy-violations | Only report rule-pack policy violations. Deprecated alias: use fallow architecture --policy |
--stale-suppressions | Only report stale suppressions |
--unused-catalog-entries | Only report unused pnpm catalog entries |
--empty-catalog-groups | Only report empty pnpm catalog groups |
--unresolved-catalog-references | Only report unresolved pnpm catalog references |
--unused-dependency-overrides | Only report unused package-manager dependency overrides |
--misconfigured-dependency-overrides | Only report misconfigured package-manager dependency overrides |
--include-dupes | Also run duplication analysis and cross-reference with dead code |
Tracing
| Option | Description |
|---|---|
--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
| Option | Description |
|---|---|
--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
| Option | Description |
|---|---|
--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-exportsreports only its issue type. You can give more than one filter. When a filter asks for a rule that the config sets tooff, fallow does not run that check. It prints a note on stderr, and the JSON output gets arequested-rule-offentry inworkspace_diagnostics. - Without a filter option,
fallow dead-codealso reports the findings offallow architecture: cycles, boundary violations and policy violations. --fileleaves 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-impactneeds--type-aware. Without it, fallow printsError: --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
dependenciesexits with code 1. unused-dev-dependenciesandunused-optional-dependenciesare atwarnby default. They do not fail the run until you set them toerrorinrules.
--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:
| Field | Content |
|---|---|
kind | "dead-code". A --group-by run gives "dead-code-grouped". |
schema_version, version, elapsed_ms | The version of this output format, the fallow version and the run time. |
total_issues | The number of findings in all arrays. |
summary | The number of findings for each issue type. Each key is always present. |
entry_points | The number of entry points, in total and for each source. |
unused_files, unused_exports, and the other issue arrays | One array for each issue type. An opt-in issue type has its array only when its rule is on. |
cascade_hidden | The 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_staleness | The entries of the loaded baseline, how many matched, and how many are stale. Present only with --baseline. |
regression | The result of --fail-on-regression. |
finding_id_query | The answer to --finding-id. See Finding ids. |
gate_outcomes | One entry for each gate of the run, with status and enforced. Always present. |
request_outcomes | The result of each scope request. See Request outcomes. |
workspace_diagnostics | Problems with the project setup, for example a config pattern that matches nothing. |
next_steps | Commands to run next. |
baseline_deltas | The change of each count against the loaded baseline. Present only in a baseline run. |
package_baselines | The Git ref that each workspace package used as its base. Absent when no package base applies. |
shared_state | The shared-state inventory of fallow architecture. It does not count in total_issues or in a gate. Optional. |
_meta | Metadata 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:
| Field | Content |
|---|---|
type | The action, for example remove-export, delete-file, remove-dependency, suppress-line, suppress-file or add-to-config. |
auto_fixable | true 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. |
description | What the action does. |
comment | The suppression comment to add. Optional. |
note | More context, when fallow fix cannot apply the action. Optional. |
config_key, value, value_schema | The 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:
| Action | auto_fixable |
|---|---|
remove-catalog-entry | true 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-dependency | When 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 file | false, 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-reference | Always false. fallow fix cannot switch a catalog reference. |
suppress-line, suppress-file | Always 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:
| Field | Content |
|---|---|
requested | The requested ids, in the order of the arguments. |
found | The requested ids that the report holds. |
missing | The requested ids that the report does not hold. |
filtered | The requested ids that a filter of this run removed. These findings still exist. |
conclusive | true when no option of the run can hide a finding that still exists. |
inconclusive_reasons | The reasons when conclusive is false. An open set of names. |
analysis_fingerprint | A 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:
| Field | Content |
|---|---|
from_file, kind, line | The consumer, the kind of import, and the 1-based line of the import. |
search_visibility | found: 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. |
reason | Why a search does not find the use: import-alias, default-import, re-export-alias, namespace-use, dynamic-import or pass-through. |
search_as | The 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-throughmarks a consumer that only exports the name again, for example a barrel file orimport { foo } from "./x"; export { foo }. Such a consumer isfound: a change of the export needs no edit there, and the trace lists the files that import through it. A.vue,.svelte,.astroor.mdxfile that imports the export is neverpass-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_namespacegives the references of each namespace.namespaceanddirect_referencesdescribe only the namespace that wins. The field is absent when only one namespace has references. - For a class member,
--trace FILE:MEMBERgivesowner_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:
| Origin | Stale when |
|---|---|
// fallow-ignore-next-line, // fallow-ignore-file | The 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:
kind | Shape |
|---|---|
multi-node | Two or more files that export from each other. |
self-loop | One 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:
| Field | Content |
|---|---|
deprecated_reason | The text of the @deprecated tag, at most 200 characters. Absent for a tag without text. |
consumer_count | The exact number of uses in reachable files. |
consumers | The first 10 uses, sorted by path and line, each with path, line, col and kind. |
public_api | true 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:
| Field | Content |
|---|---|
component_name, prop_name, framework | The component and the prop. framework is, for example, react, vue or angular. |
path, line, col | The declaration of the prop. |
has_default | true when the declaration gives a default value. |
inspected_call_sites | Each reachable caller that fallow read, with path, line and col. |
explanation | What the finding means and what static analysis does not prove. |
An entry of constant_parameters has these fields:
| Field | Content |
|---|---|
function_name, parameter_name, parameter_index | The function and the parameter. For a method of an exported class, function_name is Class.method. |
option_key | The 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, col | The parameter, or the binding of the key. |
reason | identical-argument, never-passed, or unused-default (only with --type-aware). |
value | For 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_default | The ? marker and the default value of the parameter. |
condition_reads | The number of if, ?:, while, do and for tests whose test is the parameter, !parameter or !!parameter. |
call_site_count, inspected_call_sites | The number of calls, and the first 20 calls with path, line and col. |
explanation | What 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
constalias: forconst M = Norconst I = N.Inner, fallow readsM.aasN.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:
kind | Cause |
|---|---|
ignore-dependencies-glob-unmatched | An ignoreDependencies glob matches no declared dependency. |
ignore-findings-pattern-unmatched | An ignoreFindings pattern matches no finding. |
ignore-exports-file-unmatched | An ignoreExports file glob matches no file. |
ignore-exports-name-unmatched | An ignoreExports name is not an export of a file that the glob matches. |
duplicates-ignore-unmatched | A duplicates.ignore glob matches no file. |
health-ignore-unmatched | A health.ignore glob matches no file. |
entry-pattern-redundant | An entry pattern names files that are entry points without it. |
ignore-dependencies-entry-redundant | An ignoreDependencies entry hides no finding. |
ignore-patterns-entry-redundant | An ignorePatterns glob removes no file that fallow analyzes. |
requested-rule-off | A 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:
| Format | Place |
|---|---|
sarif | runs[0].invocations[0].toolConfigurationNotifications, at the level note, with the same kind as descriptor.id. |
markdown, github-summary, the comment formats and the review formats | A section, for example ## Unmatched config patterns. |
human, compact and the other formats | A 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
| Code | Meaning |
|---|---|
0 | No finding at error severity, and no other gate failed. |
1 | A 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. |
2 | Invalid 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
Related
- 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.