fallow dead-code enforces architecture boundaries by checking that imports between directories follow your rules. Define and declare which zones may import from which.
Boundary violations are included in
fallow dead-code output by default. Use --boundary-violations to show only boundary issues.Quick start with presets
The fastest way to add boundaries is with a built-in preset. Fallow ships four presets for common architecture patterns:fallow list --boundaries to see the expanded zones and rules:
$ fallow list --boundaries
Presets
- Bulletproof
- Layered
- Hexagonal
- Feature-Sliced
The dominant React/Next.js pattern. Feature modules are isolated from each other; shared utilities and server infrastructure form the base layers.4 zones: The
app, features, shared, servershared zone covers: components, hooks, lib, utils, utilities, providers, shared, types, styles, i18n.Source root detection
Preset zone patterns use{rootDir}/{zone}/**. Fallow auto-detects the source root from tsconfig.json:
tsconfig.json
rootDir is found, fallow falls back to src.
Custom zones and rules
For full control, define zones and rules directly:How zones work
- A file belongs to the first zone whose pattern matches (first-match wins)
- Files that don’t match any zone are unrestricted: they can import from and be imported by any zone
- Self-imports are always allowed (files in the same zone can freely import each other)
- A zone with no rule entry is unrestricted: it can import from any zone
- A zone with a rule and an empty
allowlist is isolated: it cannot import from other zones
Overriding preset zones
Start from a preset and customize specific zones or rules. Zones with the same name replace the preset zone; rules with the samefrom replace the preset rule.
adapters and ports from the hexagonal preset but replaces the domain zone pattern with src/core/**.
Suppressing violations
Suppress individual findings with inline comments:off:
Output formats
Boundary violations appear in all output formats:- Human
- JSON
- Compact
$ fallow dead-code --boundary-violations
Inspecting your boundaries
Usefallow list --boundaries to verify your configuration before running analysis:
Fallow warns when a zone matches zero files. This usually means the glob pattern doesn’t match your directory structure. Run
fallow list --boundaries to check file counts per zone.See also
fallow dead-code
CLI reference for the dead code command, including all issue type filters.
Rules & Severity
Set boundary violations to error, warn, or off.
Inline Suppression
Suppress individual findings in source code.