Skip to content
Fallow home
All docs pages

Docs home

Suppression comments and tags

Find the fallow-ignore comments, range markers, JSDoc tags and config keys that hide findings, with the rules for each form.

The demo project reports formatPercent in src/lib/format.ts as an unused export, and you keep it for a report page that you add next month. A warn rule would also soften cancelOrder and each new unused export. A suppression hides one finding and keeps the rule on for the rest of the code. Suppress findings shows the steps and helps you choose a form.

Comment forms

A comment in the source file is the most direct form, because it sits next to the code that it explains.

CommentHides
// fallow-ignore-next-lineEach finding on the next line.
// fallow-ignore-next-line <token>The findings of one issue type on the next line.
// fallow-ignore-next-line <token>, <token>The findings of each listed issue type on the next line.
// fallow-ignore-fileEach finding in the file.
// fallow-ignore-file <token>The findings of one issue type in the file.
// fallow-ignore-start code-duplication and // fallow-ignore-end code-duplicationThe clones in the range. See Ranges.
// src/lib/format.ts
// fallow-ignore-next-line unused-export -- kept for the report page
export const formatPercent = (ratio: number): string => `${Math.round(ratio * 100)}%`;

The comment hides the finding on the next line and nothing else. The re-export of the same name in the barrel file src/lib/index.ts is a second finding, so fallow dead-code --unused-exports still reports it:

● Unused exports (2)
  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

✗ 2 exports (0.04s)
  2 issues · 1 suppressed
  • Separate two or more tokens with commas or spaces.
  • Fallow reads the markers in //, /* */, /** */ and <!-- --> comments.
  • Text after -- is the reason. See Reasons.
  • A fallow-ignore-next-line comment applies only to the line directly after it. A blank line between the comment and the code breaks the link: fallow reports the finding again, and reports the comment as stale. A formatter can add such a blank line, so check the comments after a formatter change.

Tokens

The word after the marker decides which findings the comment hides. A token is the id of an issue type, for example unused-export. The page of each issue type gives its comment in the row "Suppression comment". Issue types lists them all.

Some tokens are different from the issue type id, or work only in one form:

TokenNote
complexity// fallow-ignore-next-line complexity above a function hides each complexity finding of the function: cyclomatic, cognitive and CRAP. // fallow-ignore-file complexity at the top of the file hides the complexity findings of each function in the file and the file length finding. No other token hides a complexity finding: crap and cognitive are not tokens.
coverage-gapsFile level only.
boundary-violationHides each boundary finding: import direction, zone coverage and forbidden calls.
policy-violation:<pack>/<rule-id>Hides one rule of a rule pack. policy-violation alone hides each rule.
unused-file, duplicate-export, duplicate-export-alias, re-export-cycle, route-collision, dynamic-segment-name-conflict, security-client-server-leakFile level only. For re-export-cycle, put the comment in one file of the cycle.
unused-catalog-entryA YAML comment, # fallow-ignore-next-line unused-catalog-entry, on the line above the entry in pnpm-workspace.yaml.

A comment in a source file cannot hide a finding that belongs to package.json, for example an unused dependency. Use the config keys for these findings.

Threshold override comments

A suppression comment hides a complexity finding. A fallow-override-threshold-next-line comment keeps the function in the health output and gives it its own limits. The function still fails when it grows past these limits.

// src/lib/parse.ts
// fallow-override-threshold-next-line maxCyclomatic=30 maxCognitive=40 -- generated lookup table
export function parseRow(row: string): Row {
  // ...
}
  • Put the comment on the line directly before the function. For a decorated method, put it between the decorator and the method name, as for fallow-ignore-next-line complexity.
  • The keys are the keys of a health.thresholdOverrides entry: maxCyclomatic, maxCognitive, maxCrap and maxUnitSize. Write each key one time, as key=value.
  • The reason after -- is required. A comment without a reason, with an unknown key or with a bad value has no effect, and fallow health lists it under inline_threshold_override_problems.
  • For each limit that it sets, the comment wins over a thresholdOverrides entry. The human output of fallow health shows override (comment, line N) under the finding, or override (config) for a config entry.
  • A fallow-ignore-next-line complexity comment hides the finding. It does not go together with a threshold override comment, because each comment applies to the next line only.
  • health.inlineThresholdOverrides: false turns the comment form off. Use it when each exception must be in the config file.
  • fallow audit reports a new comment through the added-suppression rule, so a reviewer sees the raised limit.

The JSON output of fallow health has an inline_threshold_overrides array with one row for each comment and each dimension that it sets. A row has the fields of a threshold_overrides row without override_index, plus these fields:

FieldContent
path, comment_lineThe file and the 1-based line of the comment.
function, line, colThe function on the next line. No position on a no_match row: no function starts on the next line.

The inline_threshold_override_problems array lists each comment with a problem, with path, line and problem: missing_reason, missing_threshold, invalid_key, invalid_value or disabled. An invalid_key or invalid_value row also has the token. disabled means that health.inlineThresholdOverrides is false.

Unknown tokens and stale suppressions

A suppression stays in the code after the reason for it is gone, and a typo in a token hides nothing. A suppression that hides no finding is a stale suppression. The stale-suppressions rule reports it, at warn by default. A token that is not an issue type is also stale, and the other tokens of the same comment still apply. Here the demo comment has the typo unused-exprt:

● Stale suppressions (1)
  src/lib/format.ts:3:0 // fallow-ignore-next-line unused-exprt -- kept for the report page ('unused-exprt' is not a recognized fallow issue kind. Did you mean 'unused-export'? Other tokens on this line still apply.)

A next-line comment can also be stale because of the line after it. The message then names the cause:

● Stale suppressions (2)
  src/lib/types.ts:1:0 // fallow-ignore-next-line unused-export (no unused-export issue found on the next line; the next line has an unused-type issue, use `fallow-ignore-next-line unused-type`)
  src/lib/format.ts:5:0 // fallow-ignore-next-line unused-export (no unused-export issue found on the next line; the next line is blank, and a next-line marker applies only to the line directly after it)

In the first entry, the comment names the wrong issue type: a type re-export is an unused-type finding, not an unused-export finding. In the second entry, a blank line separates the comment from the code. In JSON output, next_line_kinds lists the issue types on the next line, and next_line_blank is true when the next line is blank.

In JSON output, origin.kind_known is false on such an entry. fallow suppressions lists each suppression of the project.

To keep a stale suppression on purpose, put a stale-suppression comment above it. The suppress-line action of each stale finding gives this comment:

// fallow-ignore-next-line stale-suppression -- kept for the next release
// fallow-ignore-next-line unused-export
export const formatPrice = (cents: number): string => `EUR ${cents / 100}`;

For a stale @expected-unused tag, put the comment directly above the export line, below the JSDoc block. A fallow-ignore-file stale-suppression comment keeps each stale suppression of its file. A stale-suppression comment is never stale itself. A comment with no issue type does not hide a stale suppression.

Ranges

Duplication needs another form, because a clone covers many lines. A fallow-ignore-next-line code-duplication comment hides each clone that touches the next line, also a clone of the code above. A range hides only the clones inside it:

// src/i18n/fields.ts
// fallow-ignore-start code-duplication -- one field block per locale
export const en = { title: "", body: "", footer: "" };
export const nl = { title: "", body: "", footer: "" };
// fallow-ignore-end code-duplication
  • A clone that is fully inside the range is not reported.
  • A clone that reaches into the range stops at the border. When the part outside is below minTokens or minLines, fallow does not report it.
  • Ranges take only the code-duplication token, on both markers. Put the reason on the start marker.
  • Put each marker on its own line. A marker after code on the same line, or in a string, has no effect.
  • A range changes the handle of each clone group that it cuts. Save the duplication baseline again after you add a range.
  • fallow dupes reports a code-duplication comment that hides no clone as stale. This applies to a range, a next-line comment and a file comment.

fallow dupes and fallow audit report a marker with a problem in the range_marker_problems array:

problemCause
unclosed_startA start marker has no end marker after it.
unmatched_endAn end marker has no open start marker before it.
nested_startA start marker is inside an open range. The outer range applies.
missing_kindThe marker has no token.
unsupported_kindThe marker names a token other than code-duplication.
not_own_lineThe marker shares its line with code.

Reasons

A suppression without a reason forces the next reader to guess why the code stays. Add -- <reason> at the end of a comment or an @expected-unused tag. A reason is optional. To require one, turn on the require-suppression-reason rule:

// .fallowrc.json
{ "rules": { "require-suppression-reason": "warn" } }

Fallow then reports each suppression without a reason as missing-suppression-reason. In JSON output, the entry is in stale_suppressions with missing_reason: true.

JSDoc tags

A library exports names that only code outside the project uses, and a comment above each export repeats the same fact many times. A JSDoc tag on an export tells fallow how to treat the export when no code uses it:

TagEffect
@public, @api publicFallow does not report the export. Use it for an API that code outside the project uses.
@internal, @beta, @alphaFallow does not report the export. Use it for an API with a limited audience, for example a sister package.
@expected-unusedFallow does not report the export. When code uses the export again, the tag is a stale suppression.
// src/client.ts
/** @public */
export function createClient() {}

/** @expected-unused -- kept for the next major version */
export const legacyClient = () => {};
  • Fallow reads only /** */ blocks. // @public and /* @public */ have no effect.
  • A tag works on each export form, and on a re-export such as export { a } from "./a". export * from "./a" takes no tag.
  • On a decorated class, put the block before the first decorator.

The keepExportTags config key selects the tags that keep an export. The default is ["public", "internal", "alpha", "beta"]. A project that uses @internal for code that no consumer outside the project uses, for example /** @internal Exported for tests. */, sets the key to ["public"]. Fallow then checks @internal, @alpha and @beta exports like untagged exports, and a tagged re-export gives no credit to its source:

// .fallowrc.json
{ "keepExportTags": ["public"] }

[] also checks @public exports. A leading @ is optional, and public also covers @api public. @expected-unused always keeps its effect. When a tag keeps an export that has no consumer, fallow dead-code --trace <file>:<export> names the tag, and the JSON trace has the field kept_by_tag.

Config keys

A comment or a tag works for one place in the code. For a package in package.json, or for many files at once, use a config key. The table lists each need with the smallest form that covers it:

NeedUse
One finding in code that you keepA fallow-ignore-next-line comment
A complex function that you keep visible with its own limitsA fallow-override-threshold-next-line comment, or thresholdOverrides for many files
All findings of one issue type in one fileA fallow-ignore-file <token> comment
An export that code outside the project uses@public, or ignoreExports for many files
An unused export that you keep on purpose@expected-unused
A package in package.jsonignoreDependencies
A binary that a package.json script runs, and that the system providesignoreBinaries
An import that fallow cannot resolveignoreUnresolvedImports
An export that only its own file usesignoreExportsUsedInFile
A catalog: reference or a package manager overrideignoreCatalogReferences, ignoreDependencyOverrides
All dead code findings in some files, with the files still analyzedignoreFindings
Files that fallow must not readignorePatterns
An issue type in some directoriesoverrides

One reason in many files

When many comments give the same reason, the reason is a fact about the project. Put it in the config file once. Do not do this:

// src/components/Button.tsx
// fallow-ignore-next-line unused-export
export const Button = () => { /* ... */ };

// src/components/Input.tsx
// fallow-ignore-next-line unused-export
export const Input = () => { /* ... */ };

Write one config entry, and remove the comments:

// .fallowrc.json
{
  "ignoreExports": [
    { "file": "src/components/**/*.tsx", "exports": ["*"] }
  ]
}