Skip to content
Fallow home
All docs pages

Docs home

How configuration works

Learn where fallow finds the config file, how config files merge, which source wins, and the keys that most projects set.

Your first report is close, but some findings are not true for your project. A worker file shows as unused, because no package.json field names it. Generated code fills the duplication report. A config file tells fallow these facts. Without one, fallow uses its defaults: in the demo project, it finds 3 entry points through package.json, its scripts and the Vitest plugin. When the defaults do not fit, a config file can add an entry point, skip generated files or change the severity of a rule.

Create a config file

Run fallow init in the project root. It writes a config file with starting keys for the tools that it detects:

npx fallow init
Created .fallowrc.json
  Detected: TypeScript
  Detected: Vitest
  Config includes test framework rules
Added .fallow/ to .gitignore

Read the file before you commit it, because each key in it changes the report. fallow init --toml writes a fallow.toml file. fallow init has the other options.

Config file names

The file works only when fallow finds it, so its name and its place matter.

FileFormat
.fallowrc.jsonJSONC: JSON with comments and trailing commas
.fallowrc.jsoncJSONC. The extension tells your editor to accept comments.
fallow.tomlTOML
.fallow.tomlTOML

Fallow starts in the project root: the current directory, or the directory that --root names. It looks for the names in the order of the table, and the first file that exists wins. When the directory has no config file, fallow looks in each parent directory up to the repository root: the directory with .git, .hg or .svn. When one directory has two config files, fallow loads the file that is higher in the table. It writes a warning on stderr that names the other file. To load a file at another path, pass --config <path>.

Fallow does not read other names, such as fallow.json, fallow.jsonc, fallow.yaml or fallow.config.json. When the project root has such a file and none of the names in the table, the run writes a Note: line that names the file and the accepted names. The JSON output has a config-file-name-unrecognized entry in workspace_diagnostics. Rename the file, or pass it with --config when it is JSON.

Editor completion

A key with a wrong name stops the run (see the next section), so it helps when your editor finds the error while you type. Add the $schema key to a JSON config file. Your editor then completes the keys and checks the values:

// .fallowrc.json
{ "$schema": "./node_modules/fallow/schema.json" }

The local path matches the installed version and works offline. Without an npm install, use https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json. You can write either form by hand. fallow init writes the local path when node_modules/fallow/schema.json exists, and the URL in all other cases. fallow config-schema prints the schema.

Unknown keys and minimumVersion

An unknown key in the config file stops the run with exit code 2. This is also true for a key in a section, such as duplicates or boundaries. The error names the key and lists the valid keys. When a valid key is close to the unknown key, the error also asks, for example, "did you mean minTokens?". So a typo such as ignorePaths or minToken shows at once. An unknown name in rules gives a warning, and fallow ignores the entry. regression.baseline accepts an unknown count, because a newer fallow can write a count that an older one does not know. A key that a newer fallow version adds is unknown to an older version. Set minimumVersion in the change that adds the key. An older fallow then stops with a message that names the version to install.

Share a config with extends

A team with many repositories wants the same rules in each of them, and a copy of the file in each repository drifts apart. extends loads one or more base configs before the keys of your file:

// .fallowrc.json
{
  "extends": ["./configs/fallow-base.json", "npm:@acme/fallow-config"],
  "ignorePatterns": ["src/generated/**"]
}
SourceFormNotes
Local file./configs/fallow-base.jsonRelative to the config file that has the extends key. JSON and TOML files can extend each other.
Packagenpm:@acme/fallow-configAn installed package. Fallow reads the file that its exports or main names, or a config file name in the package directory.
URLhttps://example.com/fallow.jsonOnly with the --allow-remote-extends option. Fallow rejects http://. The download has a time limit of 5 seconds and a size limit of 1 MB.

The bases apply in list order, then your file applies. An object key merges key by key. An array or a single value in your file replaces the value of the base. A chain of extends can be 10 levels deep, and a cycle stops the load with an error. sealed limits extends to files in the directory of the config file. Use it for a package that must not take settings from outside.

Which setting wins

A setting can come from a command-line option, an environment variable and the config file. When more than one source sets it, fallow uses this order:

  1. The command-line option, for example --production.
  2. The environment variable, for example FALLOW_PRODUCTION.
  3. The config file, for example "production": true.
  4. The default of fallow.

Because of this order, a CI job can change one setting for one run, and the shared config file stays the same.

Glob patterns

Most keys in the next section select files with glob patterns. A pattern that matches the wrong files changes the report, so learn these rules before you add one. Fallow matches each pattern against the path of a file relative to the project root, with / as the separator on each platform.

PatternMatchesDoes not match
src/*.tssrc/a.tssrc/lib/a.ts
src/**/*.tssrc/a.ts, src/lib/a.tstest/a.ts
*.test.tsa.test.tssrc/a.test.ts
**/*.test.tsa.test.ts, src/a.test.tssrc/a.spec.ts
  • A single * or ? does not match /. Use ** to match files in nested directories.
  • A pattern copied from .gitignore can match fewer files. In .gitignore, src/generated/* also covers the subdirectories. Here, use src/generated/**.
  • Inside a Git repository, fallow applies no .ignore file from a directory above the top level of the repository, as Git applies no .gitignore file from there. A project in a nested repository therefore does not get the .ignore files of the outer repository. Outside a repository, the .ignore files of the parent directories still apply.
  • An absolute path, a .. segment or a pattern longer than 512 bytes stops the config load.
  • When a single * skips files in nested directories, fallow writes a warning on stderr. The warning names the key, the skipped files and the ** form.

A pattern that matches package names or import specifiers follows other rules. In ignoreDependencies, ignoreUnresolvedImports and publicPackages, * also matches /, so @acme/* matches each package in the @acme scope.

Most used keys

These keys fix the usual problems of a first report: a missed entry point, generated files, a package that fallow cannot see in use, and a severity that does not fit your team. Each key has an entry in the config reference with its type and default.

entry

Add the files that start your code when fallow cannot find them, for example worker files. Fallow follows the imports of each matched file. For a script that does not run in production, use supportEntry. Reference: entry.

{ "entry": ["src/workers/**/*.ts", "scripts/*.ts"] }

ignorePatterns

Remove generated or vendored files from the analysis. Fallow does not read these files, so their imports do not count. Your patterns add to the built-in ones, such as **/dist/**. Reference: ignorePatterns.

{ "ignorePatterns": ["src/generated/**", "**/*.d.ts"] }

ignoreDependencies

Stop dependency findings for a package that the runtime provides, or that fallow cannot see in use. Fallow then reports the package neither as unused nor as unlisted. Reference: ignoreDependencies.

{ "ignoreDependencies": ["bun:sqlite", "@types/*"] }

ignoreExports

Keep the exports of a public API file, which code outside your project imports. Fallow does not report these exports as unused. Reference: ignoreExports.

{ "ignoreExports": [{ "file": "src/index.ts", "exports": ["*"] }] }

rules

Set the severity of an issue type: error, warn or off. Use warn to see findings of a type without a failed run. Rules and severities explains the defaults and overrides.

{ "rules": { "unused-exports": "warn", "private-type-leaks": "error" } }

production

Analyze only the code that ships, without tests and development tools. The object form sets production mode for each analysis. Its keys apply to the bare fallow run, to fallow audit, and to the command of the analysis, for example deadCode to fallow dead-code. Reference: production.

{ "production": { "deadCode": true, "health": false } }

duplicates

Set how fallow finds duplicated code and the limit for a run. threshold fails fallow dupes above a percentage of duplicated lines. Reference: duplicates.

{ "duplicates": { "minTokens": 80, "threshold": 5, "ignore": ["**/*.stories.tsx"] } }

health

Set the complexity limits of fallow health. A function above a limit is a finding. health also sets limits for some files only.

{ "health": { "maxCyclomatic": 25, "maxCognitive": 20 } }

Details

Some keys have a behavior that the short entry in the config reference does not show. Read the row of a key before you rely on it.

KeyFact
ignoreFindingsFallow hides a matching finding before rules and gates apply, so the finding cannot fail a run, also with --fail-on-issues. A ! pattern wins over each positive pattern, at each position in the array.
ignoreDependenciesAn entry also stops the type-only, test-only and dev-in-production findings of the package.
ignoreCommandEntriesA name matches also after a prefix such as cross-env MODE=x, npx or pnpm exec.
ignoreUnresolvedImportsA pattern must match the whole specifier. Fallow removes a leading ./ from the pattern and from the specifier, so ./generated/x.js and generated/x.js match the same imports.
ignoreExportsA listed name also stops the duplicate-export-alias finding of that name.
ignoreCatalogReferencescatalog compares the catalog name after fallow reads it: catalog: and catalog:default are both default.
ignoreDependencyOverridesThe key also covers npm overrides and bun resolutions. These have the source value "package.json".
extendsA config that fallow loads from a URL can extend another URL or an npm: package, and no relative path.
minimumVersionA config inherits the value through extends. A value that is not MAJOR.MINOR.PATCH, for example v3.21, stops the load with exit code 2.
includeEntryExportsworkspaces.settings sets the value for some workspaces. The --include-entry-exports option wins over both.

Warnings about the config

A config file grows with the project, and an entry can stop doing anything after the code changes. Fallow compares some config entries with the result of the run. It reports an entry that has no effect as a warning. Each warning is an entry in the workspace_diagnostics array of the JSON output, and a note in the other formats. A warning does not change the exit code.

Each format shows the warnings in a different place:

OutputPlace
JSONworkspace_diagnostics, with the kind of the warning.
SARIFinvocations[0].toolConfigurationNotifications of the first run. descriptor.id is the kind, and properties.setting names the config key.
Markdown and the pull request commentsA section after the findings, for example ## Unmatched config patterns or ## Redundant config entries.
Human, compact, CodeClimate, github-annotationsA Note: line on stderr, so stdout does not change. --quiet removes the line.

Unmatched config patterns

A config entry matches nothing in the run. The usual cause is a typo, or a file or an export that was moved, renamed or deleted. fallow dead-code, fallow audit and the bare fallow run report it, with a pattern field:

kindEntryWhen it matches nothing
ignore-dependencies-glob-unmatchedAn ignoreDependencies globNo declared dependency has a matching name.
ignore-findings-pattern-unmatchedAn ignoreFindings patternNo finding has a matching path.
ignore-exports-file-unmatchedThe file glob of an ignoreExports ruleNo analyzed file has a matching path.
ignore-exports-name-unmatchedA name in the exports of an ignoreExports ruleNo file that the glob matches declares or re-exports the name. The entry also has file and export.
duplicates-ignore-unmatchedA duplicates.ignore globNo project file has a matching path.
health-ignore-unmatchedA health.ignore globNo project file has a matching path.
{"path":".","kind":"ignore-dependencies-glob-unmatched","pattern":"@acm/*","message":"ignoreDependencies glob '@acm/*' matched no declared dependency in this run, so it has no effect. A glob matches package names, such as @scope/*. Fix the glob, or remove it from the config."}
  • A file with export * can supply any name, so fallow does not report a name of a rule that matches such a file.
  • When the file glob of an ignoreExports rule matches no file, fallow reports the glob once and not each name of the rule.
  • A run with --production reports no unmatched ignoreExports, duplicates.ignore or health.ignore entry, because it reads fewer files.
  • fallow dupes also reports each unmatched duplicates.ignore glob, and fallow health each unmatched health.ignore glob. These runs show the warning in JSON, the job summary and the pull request comments. In SARIF and Markdown, they show a Note: line on stderr.
  • Fallow reports an ignoreDependencies glob only when the run reports dependency findings. A run with --file, or with an issue filter without --unused-deps or --unlisted-deps, does not report it. An exact package name never gives this warning.
  • Fallow compares an ignoreFindings pattern with each finding of the analysis, before the issue filters and the scope filters. So a filtered run does not make a pattern look unused.
  • Fallow does not report an ignoreFindings pattern whose removal changes which paths are hidden. When no positive pattern matched beside ! exceptions, the positive patterns are not reported: without them, every path outside the exceptions is hidden. When there is no positive pattern and no ! exception matched, the exceptions are not reported: without them, no path is hidden.

Redundant config entries

An entry matches, but changes nothing, because fallow does the same without it. Remove the entry, unless it is for files that only a build makes. The same commands report it:

kindEntryWhen it has no effect
entry-pattern-redundantAn entry patternAnother source already makes each matched file a runtime entry point: a package.json field or script, a plugin, an infrastructure file or dynamicallyLoaded.
ignore-dependencies-entry-redundantAn ignoreDependencies entryThe entry hid no dependency finding.
ignore-patterns-entry-redundantAn ignorePatterns globThe glob left out no file that fallow analyzes otherwise, because a built-in ignore, .gitignore or the file type already skips each match.
  • An entry pattern that matches no file gives no warning.
  • An ignorePatterns glob that names a hidden directory, and a ! exception, give no warning.
  • A run with --production reports no redundant entry, because it reads fewer files.

Override rules with no effect

An overrides[].rules entry cannot change the result for its files. The kind is override-rule-ineffective, with these fields:

FieldValue
ruleThe rule name, also when the config uses an alias.
filesThe overrides[].files globs, as written.
reasonproject-level: the rule reads only the top-level severity. base-rule-off: the top-level rule is off, so its check does not run, and the override cannot start it. Accept other values too.
{"path":".","kind":"override-rule-ineffective","rule":"unused-dependencies","files":["src/lib/**"],"reason":"project-level","message":"overrides.rules.unused-dependencies has no effect for files matching [src/lib/**]: unused-dependencies is a project-level rule, so fallow reads only the top-level severity. To hide one package, add it to `ignoreDependencies`. That entry applies to the whole project. To change the rule for all packages, set `rules.unused-dependencies`."}

The message names a method that works. Overrides names the rules that read only the top-level severity.

Requested rules that are off

An option such as --unused-deps asks for a rule that the config sets to off, so fallow does not run that check. A count of zero then measures nothing. fallow dead-code and fallow architecture report it with the kind requested-rule-off, the rule and the flag. Set the rule to warn or error to run the check.

Note: unused-dependencies is off in config, so --unused-deps did not check it. Set the rule to "error" or "warn" to run this check.

The findings and the exit code do not change, so a script that passes --unused-deps with the rule at off exits with code 0. A run without an issue filter gives no such warning.

See the resolved config

When a setting does not have the effect that you expect, look at the config that fallow really uses. fallow config prints it as JSON, after extends and with each default filled in. fallow config --path prints only the path of the config file, so you can see which file fallow found. fallow config has the exit codes.