fallow 2.47.0 → 2.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -2
- package/bin/fallow +12 -23
- package/bin/fallow-lsp +12 -23
- package/bin/fallow-mcp +12 -23
- package/package.json +24 -10
- package/scripts/platform-package.js +28 -0
- package/scripts/platform-package.test.js +26 -0
- package/scripts/postinstall.js +11 -22
- package/skills/fallow/SKILL.md +386 -0
- package/skills/fallow/references/cli-reference.md +1479 -0
- package/skills/fallow/references/gotchas.md +611 -0
- package/skills/fallow/references/patterns.md +817 -0
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: fallow
|
|
3
|
+
description: Codebase intelligence for JavaScript and TypeScript. Free static layer finds unused code (files, exports, types, dependencies), code duplication, circular dependencies, complexity hotspots, architecture boundary violations, and feature flag patterns. Optional paid runtime layer (Fallow Runtime) merges production execution data into the same health report for hot-path review, cold-path deletion confidence, and stale-flag evidence. 90 framework plugins, zero configuration, sub-second static analysis. Use when asked to analyze code health, find unused code, detect duplicates, check circular dependencies, audit complexity, check architecture boundaries, detect feature flags, clean up the codebase, auto-fix issues, merge production coverage, or run fallow.
|
|
4
|
+
license: MIT
|
|
5
|
+
metadata:
|
|
6
|
+
author: fallow-rs
|
|
7
|
+
homepage: https://docs.fallow.tools
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
# Fallow: codebase intelligence for JavaScript and TypeScript
|
|
11
|
+
|
|
12
|
+
Codebase intelligence for JavaScript and TypeScript. The free static layer finds unused code, circular dependencies, code duplication, complexity hotspots, architecture boundary violations, and feature flag patterns. The optional paid runtime layer (Fallow Runtime) merges production execution data into the same `fallow health` report for hot-path review, cold-path deletion confidence, and stale-flag evidence. 90 framework plugins, zero configuration, sub-second static analysis.
|
|
13
|
+
|
|
14
|
+
## When to Use
|
|
15
|
+
|
|
16
|
+
- Finding dead code (unused files, exports, types, enum/class members)
|
|
17
|
+
- Finding unused or unlisted dependencies
|
|
18
|
+
- Detecting code duplication and clones
|
|
19
|
+
- Checking code health and complexity hotspots
|
|
20
|
+
- Cleaning up a codebase before a release or refactor
|
|
21
|
+
- Auditing a project for structural issues
|
|
22
|
+
- Setting up CI checks for dead code or duplication thresholds
|
|
23
|
+
- Auto-fixing unused exports and dependencies
|
|
24
|
+
- Detecting feature flag patterns (environment gates, SDK calls, config objects)
|
|
25
|
+
- Investigating why a specific export or file appears unused
|
|
26
|
+
|
|
27
|
+
## When NOT to Use
|
|
28
|
+
|
|
29
|
+
- Runtime error analysis or debugging
|
|
30
|
+
- Type checking (use `tsc` for that)
|
|
31
|
+
- Linting style or formatting issues (use ESLint, Biome, Prettier)
|
|
32
|
+
- Security vulnerability scanning
|
|
33
|
+
- Bundle size analysis
|
|
34
|
+
- Projects that are not JavaScript or TypeScript
|
|
35
|
+
|
|
36
|
+
## Prerequisites
|
|
37
|
+
|
|
38
|
+
Prefer the project-local package. It includes the `fallow` CLI, `fallow-lsp`, `fallow-mcp`, and this version-matched skill. Use the package manager already used by the project:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
npm install --save-dev fallow
|
|
42
|
+
pnpm add -D fallow
|
|
43
|
+
yarn add -D fallow
|
|
44
|
+
bun add -d fallow
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Run fallow with the matching package-manager runner:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx fallow dead-code
|
|
51
|
+
pnpm exec fallow dead-code
|
|
52
|
+
yarn exec fallow dead-code
|
|
53
|
+
bunx fallow dead-code
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
For one-off checks without installing into the project:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
npx fallow dead-code
|
|
60
|
+
# or
|
|
61
|
+
npm install -g fallow # global CLI only
|
|
62
|
+
# or
|
|
63
|
+
cargo install fallow-cli # build from source
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Agent Rules
|
|
67
|
+
|
|
68
|
+
1. **Always use `--format json --quiet 2>/dev/null`** for machine-readable output. The `2>/dev/null` discards stderr so progress messages and threshold warnings don't corrupt the JSON on stdout. Never use `2>&1`
|
|
69
|
+
2. **Always append `|| true`** to every fallow command. Exit code 1 means "issues found" (normal), not a runtime error. Without `|| true`, the Bash tool treats exit 1 as failure and cancels parallel commands. Only exit code 2 is a real error (invalid config, parse failure)
|
|
70
|
+
3. **Use `--explain`** to include a `_meta` object in JSON output with metric definitions, ranges, and interpretation hints
|
|
71
|
+
4. **Use issue type filters** (`--unused-exports`, `--unused-files`, etc.) to limit output scope
|
|
72
|
+
5. **Always `--dry-run` before `fix`**, then `fix --yes` to apply
|
|
73
|
+
6. **All output paths are relative** to the project root
|
|
74
|
+
7. **Never run `fallow watch`**. It is interactive and never exits
|
|
75
|
+
|
|
76
|
+
## Commands
|
|
77
|
+
|
|
78
|
+
| Command | Purpose | Key Flags |
|
|
79
|
+
|---------|---------|-----------|
|
|
80
|
+
| `fallow` | Run all analyses: dead code + duplication + complexity (default) | `--only`, `--skip`, `--ci`, `--fail-on-issues`, `--group-by`, `--summary`, `--fail-on-regression`, `--tolerance`, `--regression-baseline`, `--save-regression-baseline`, `--score`, `--trend`, `--save-snapshot` |
|
|
81
|
+
| `dead-code` | Dead code analysis (`check` is an alias) | `--unused-exports`, `--changed-since`, `--changed-workspaces`, `--production`, `--file`, `--include-entry-exports`, `--stale-suppressions`, `--ci`, `--group-by`, `--summary`, `--fail-on-regression`, `--tolerance`, `--regression-baseline`, `--save-regression-baseline` |
|
|
82
|
+
| `dupes` | Code duplication detection | `--mode`, `--threshold`, `--top`, `--changed-since`, `--workspace`, `--changed-workspaces`, `--skip-local`, `--cross-language`, `--ignore-imports`, `--fail-on-regression`, `--tolerance`, `--regression-baseline`, `--save-regression-baseline` |
|
|
83
|
+
| `fix` | Auto-remove unused exports/deps | `--dry-run`, `--yes` (required in non-TTY) |
|
|
84
|
+
| `init` | Generate config file or pre-commit hook | `--toml`, `--hooks`, `--branch` |
|
|
85
|
+
| `migrate` | Convert knip/jscpd config | `--dry-run`, `--from PATH` |
|
|
86
|
+
| `list` | Inspect project structure | `--files`, `--entry-points`, `--plugins`, `--boundaries` |
|
|
87
|
+
| `health` | Function complexity analysis | `--complexity`, `--max-cyclomatic`, `--max-cognitive`, `--max-crap`, `--top`, `--sort`, `--file-scores`, `--hotspots`, `--ownership`, `--ownership-emails`, `--targets`, `--effort`, `--score`, `--min-score`, `--since`, `--min-commits`, `--save-snapshot`, `--trend`, `--coverage-gaps`, `--coverage`, `--coverage-root`, `--production-coverage`, `--min-invocations-hot`, `--min-observation-volume`, `--low-traffic-threshold`, `--workspace`, `--changed-workspaces`, `--baseline`, `--save-baseline` |
|
|
88
|
+
| `audit` | Combined dead-code + complexity + duplication for changed files | `--base`, `--production`, `--workspace`, `--changed-workspaces`, `--ci`, `--fail-on-issues`, `--explain`, `--dead-code-baseline`, `--health-baseline`, `--dupes-baseline`, `--max-crap` |
|
|
89
|
+
| `flags` | Detect feature flag patterns (env vars, SDK calls, config objects) | `--top` |
|
|
90
|
+
| `license` | Manage the local license JWT for paid features (activate, status, refresh, deactivate) | `activate --trial --email <addr>`, `activate --from-file`, `activate --stdin`, `status`, `refresh`, `deactivate` |
|
|
91
|
+
| `coverage` | Production-coverage workflow helper (paid) | `setup`, `setup --yes`, `setup --non-interactive` |
|
|
92
|
+
| `schema` | Dump CLI definition as JSON | |
|
|
93
|
+
| `config` | Show the loaded config path and resolved config (verifies which `.fallowrc.json` is in effect) | `--path` |
|
|
94
|
+
|
|
95
|
+
## Issue Types
|
|
96
|
+
|
|
97
|
+
| Type | Filter Flag | Description |
|
|
98
|
+
|------|-------------|-------------|
|
|
99
|
+
| Unused files | `--unused-files` | Files unreachable from entry points |
|
|
100
|
+
| Unused exports | `--unused-exports` | Symbols never imported elsewhere |
|
|
101
|
+
| Unused types | `--unused-types` | Type aliases and interfaces |
|
|
102
|
+
| Unused dependencies | `--unused-deps` | Packages in `dependencies`, `devDependencies`, `optionalDependencies`, type-only production deps, and test-only production deps |
|
|
103
|
+
| Unused enum members | `--unused-enum-members` | Enum values never referenced |
|
|
104
|
+
| Unused class members | `--unused-class-members` | Methods and properties |
|
|
105
|
+
| Unresolved imports | `--unresolved-imports` | Imports that can't be resolved |
|
|
106
|
+
| Unlisted dependencies | `--unlisted-deps` | Used packages missing from package.json |
|
|
107
|
+
| Duplicate exports | `--duplicate-exports` | Same symbol exported from multiple modules |
|
|
108
|
+
| Circular dependencies | `--circular-deps` | Import cycles in the module graph |
|
|
109
|
+
| Boundary violations | `--boundary-violations` | Imports crossing architecture zone boundaries. Presets: `layered`, `hexagonal`, `feature-sliced`, `bulletproof` |
|
|
110
|
+
| Stale suppressions | `--stale-suppressions` | `fallow-ignore` comments or `@expected-unused` JSDoc tags that no longer match any issue |
|
|
111
|
+
| Test-only dependencies | n/a | Production deps only imported from test files (should be devDependencies) |
|
|
112
|
+
|
|
113
|
+
## MCP Tools
|
|
114
|
+
|
|
115
|
+
When using fallow via MCP (`fallow-mcp`), the following tools are available:
|
|
116
|
+
|
|
117
|
+
| Tool | Description |
|
|
118
|
+
|------|-------------|
|
|
119
|
+
| `analyze` | Full dead code analysis. Set `boundary_violations: true` as a convenience alias for `issue_types: ["boundary-violations"]`. Set `group_by` to `"owner"`, `"directory"`, `"package"`, or `"section"` (GitLab CODEOWNERS `[Section]` headers, with `owners` metadata per group) to partition results |
|
|
120
|
+
| `check_changed` | Incremental analysis of files changed since a git ref |
|
|
121
|
+
| `find_dupes` | Code duplication detection. Set `changed_since` to scope to changed files since a git ref |
|
|
122
|
+
| `fix_preview` | Dry-run auto-fix preview |
|
|
123
|
+
| `fix_apply` | Apply auto-fixes (destructive) |
|
|
124
|
+
| `check_health` | Complexity metrics, health scores, hotspots, and refactoring targets |
|
|
125
|
+
| `health_production_coverage` | Merge V8 or Istanbul production-coverage data into the health report (paid). Required `coverage` param. Long dumps may exceed the 120s MCP timeout; raise `FALLOW_TIMEOUT_SECS`. |
|
|
126
|
+
| `audit` | Combined dead-code + complexity + duplication for changed files, returns verdict |
|
|
127
|
+
| `project_info` | Project metadata. Set `entry_points`, `files`, `plugins`, or `boundaries` to `true` to request specific sections |
|
|
128
|
+
| `list_boundaries` | Architecture boundary zones and access rules. Returns `{"configured": false}` if no boundaries configured |
|
|
129
|
+
| `detect_flags` | Detect feature flag patterns (env vars, SDK calls, config objects). Set `top` to limit results |
|
|
130
|
+
|
|
131
|
+
All tools accept `root`, `config`, `no_cache`, and `threads` params. The MCP server subprocess timeout defaults to 120s, configurable via `FALLOW_TIMEOUT_SECS`.
|
|
132
|
+
|
|
133
|
+
All JSON responses include structured `actions` arrays on every finding (dead code, health, duplication), enabling programmatic fix application or suppression.
|
|
134
|
+
|
|
135
|
+
## Node.js Bindings
|
|
136
|
+
|
|
137
|
+
When embedding fallow inside a Node.js process (editor extensions, long-running servers, custom tooling), prefer the NAPI bindings over spawning the CLI. Same analysis engine, same JSON envelopes, no subprocess or JSON parsing overhead.
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
npm install @fallow-cli/fallow-node
|
|
141
|
+
pnpm add @fallow-cli/fallow-node
|
|
142
|
+
yarn add @fallow-cli/fallow-node
|
|
143
|
+
bun add @fallow-cli/fallow-node
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
```ts
|
|
147
|
+
import { detectDeadCode, detectDuplication, computeHealth } from '@fallow-cli/fallow-node';
|
|
148
|
+
|
|
149
|
+
const deadCode = await detectDeadCode({ root: process.cwd(), explain: true });
|
|
150
|
+
const dupes = await detectDuplication({ root: process.cwd(), mode: 'mild', minTokens: 30 });
|
|
151
|
+
const health = await computeHealth({ root: process.cwd(), score: true, ownershipEmails: 'handle' });
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
Six async functions: `detectDeadCode`, `detectCircularDependencies`, `detectBoundaryViolations`, `detectDuplication`, `computeComplexity`, `computeHealth`. Each returns the same JSON envelope the CLI emits for `--format json`. Rejected promises throw a `FallowNodeError` with `message`, `exitCode`, and optional `code`, `help`, `context` fields that mirror the CLI's structured error surface.
|
|
155
|
+
|
|
156
|
+
Enum-like fields take lowercase CLI-style literals (`"mild"`, `"cyclomatic"`, `"handle"`, `"low"`). Write-path commands (`fix`, `init`, `setup-hooks`, `license activate`, `coverage setup`) are not exposed; use the CLI for those.
|
|
157
|
+
|
|
158
|
+
See <https://docs.fallow.tools/integrations/node-bindings> for the full field reference.
|
|
159
|
+
|
|
160
|
+
## References
|
|
161
|
+
|
|
162
|
+
- [CLI Reference](references/cli-reference.md): complete command and flag specifications
|
|
163
|
+
- [Gotchas](references/gotchas.md): common pitfalls, edge cases, and correct usage patterns
|
|
164
|
+
- [Patterns](references/patterns.md): workflow recipes for CI, monorepos, migration, and incremental adoption
|
|
165
|
+
|
|
166
|
+
## Common Workflows
|
|
167
|
+
|
|
168
|
+
### Audit a project for all dead code
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
fallow dead-code --format json --quiet
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Parse the JSON output. It contains arrays for each issue type (`unused_files`, `unused_exports`, `unused_types`, `unused_dependencies`, etc.) plus `total_issues` and `elapsed_ms` metadata. Each issue object includes an `actions` array with structured fix suggestions (action type, `auto_fixable` flag, description, and optional suppression comment).
|
|
175
|
+
|
|
176
|
+
### Find only unused exports (smaller output)
|
|
177
|
+
|
|
178
|
+
```bash
|
|
179
|
+
fallow dead-code --format json --quiet --unused-exports
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
### Check if a PR introduces dead code
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
fallow dead-code --format json --quiet --changed-since main --fail-on-issues
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
Exit code 1 if new dead code is introduced. Only analyzes files changed since the `main` branch.
|
|
189
|
+
|
|
190
|
+
### Find code duplication
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
fallow dupes --format json --quiet
|
|
194
|
+
fallow dupes --format json --quiet --mode semantic
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
The `semantic` mode detects renamed variables. Other modes: `strict` (exact), `mild` (default, syntax normalized), `weak` (different literals).
|
|
198
|
+
|
|
199
|
+
### Safe auto-fix cycle
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
# 1. Preview what will be removed
|
|
203
|
+
fallow fix --dry-run --format json --quiet
|
|
204
|
+
|
|
205
|
+
# 2. Review the output, then apply
|
|
206
|
+
fallow fix --yes --format json --quiet
|
|
207
|
+
|
|
208
|
+
# 3. Verify the fix worked
|
|
209
|
+
fallow dead-code --format json --quiet
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The `--yes` flag is required in non-TTY environments (agent subprocesses). Without it, `fix` exits with code 2.
|
|
213
|
+
|
|
214
|
+
### Discover project structure
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
fallow list --entry-points --format json --quiet
|
|
218
|
+
fallow list --plugins --format json --quiet
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
Shows detected entry points and active framework plugins (90 built-in: Next.js, Vite, Jest, Storybook, Tailwind, etc.).
|
|
222
|
+
|
|
223
|
+
### Production-only analysis
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
fallow dead-code --format json --quiet --production
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
Excludes test/dev files (`*.test.*`, `*.spec.*`, `*.stories.*`) and only analyzes production scripts.
|
|
230
|
+
|
|
231
|
+
### Analyze specific workspaces
|
|
232
|
+
|
|
233
|
+
```bash
|
|
234
|
+
# Single package
|
|
235
|
+
fallow dead-code --format json --quiet --workspace my-package
|
|
236
|
+
|
|
237
|
+
# Multiple packages
|
|
238
|
+
fallow dead-code --format json --quiet --workspace web,admin
|
|
239
|
+
|
|
240
|
+
# Glob (matched against package name AND workspace path)
|
|
241
|
+
fallow dead-code --format json --quiet --workspace 'apps/*'
|
|
242
|
+
|
|
243
|
+
# Exclude one workspace from a set
|
|
244
|
+
fallow dead-code --format json --quiet --workspace 'apps/*,!apps/legacy'
|
|
245
|
+
|
|
246
|
+
# Monorepo CI: auto-scope to workspaces containing any file changed since origin/main
|
|
247
|
+
# (replaces hand-written --workspace lists that drift as the repo evolves)
|
|
248
|
+
fallow dead-code --format json --quiet --changed-workspaces origin/main
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
Scopes output while keeping the full cross-workspace graph. Patterns are tested against BOTH the package name (from `package.json`) AND the workspace path relative to the repo root; either match counts. Use `!`-prefixed patterns to exclude.
|
|
252
|
+
|
|
253
|
+
`--changed-workspaces <REF>` auto-derives the set from `git diff`. It's the CI primitive: point it at the PR base branch (e.g. `origin/main`) and fallow reports only on workspaces touched by the change. Mutually exclusive with `--workspace`. A missing ref or non-git directory is a hard error (exit 2) rather than a silent full-scope fallback, so CI never quietly widens back to the whole monorepo.
|
|
254
|
+
|
|
255
|
+
### Scope to specific files (lint-staged)
|
|
256
|
+
|
|
257
|
+
```bash
|
|
258
|
+
fallow dead-code --format json --quiet --file src/utils.ts --file src/helpers.ts
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
Only reports issues in the specified files. Project-wide dependency issues are suppressed. Warns on non-existent paths.
|
|
262
|
+
|
|
263
|
+
### Catch typos in entry file exports
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
fallow dead-code --format json --quiet --include-entry-exports
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
Reports unused exports in entry files (package.json `main`/`exports`, framework pages). By default, exports in entry files are assumed externally consumed. This flag catches typos like `meatdata` instead of `metadata`.
|
|
270
|
+
|
|
271
|
+
### Debug why something is flagged
|
|
272
|
+
|
|
273
|
+
```bash
|
|
274
|
+
# Trace an export's usage chain
|
|
275
|
+
fallow dead-code --format json --quiet --trace src/utils.ts:myFunction
|
|
276
|
+
|
|
277
|
+
# Trace all edges for a file
|
|
278
|
+
fallow dead-code --format json --quiet --trace-file src/utils.ts
|
|
279
|
+
|
|
280
|
+
# Trace where a dependency is used
|
|
281
|
+
fallow dead-code --format json --quiet --trace-dependency lodash
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
### Migrate from knip or jscpd
|
|
285
|
+
|
|
286
|
+
```bash
|
|
287
|
+
# Preview migration
|
|
288
|
+
fallow migrate --dry-run
|
|
289
|
+
|
|
290
|
+
# Apply migration (creates .fallowrc.json)
|
|
291
|
+
fallow migrate
|
|
292
|
+
|
|
293
|
+
# Migrate to TOML (creates fallow.toml)
|
|
294
|
+
fallow migrate --toml
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
Auto-detects `knip.json`, `.knip.json`, `.jscpd.json`, and package.json embedded configs.
|
|
298
|
+
|
|
299
|
+
### Initialize a new config
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
fallow init # creates .fallowrc.json, adds .fallow/ to .gitignore
|
|
303
|
+
fallow init --toml # creates fallow.toml, adds .fallow/ to .gitignore
|
|
304
|
+
fallow init --hooks # scaffold a pre-commit git hook
|
|
305
|
+
fallow init --hooks --branch develop # hook using custom base branch
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
## Exit Codes
|
|
309
|
+
|
|
310
|
+
| Code | Meaning |
|
|
311
|
+
|------|---------|
|
|
312
|
+
| 0 | Success, no error-severity issues |
|
|
313
|
+
| 1 | Error-severity issues found |
|
|
314
|
+
| 2 | Runtime error (invalid config, parse failure, or `fix` without `--yes` in non-TTY) |
|
|
315
|
+
|
|
316
|
+
When `--format json` is active and exit code is 2, errors are emitted as JSON on stdout:
|
|
317
|
+
```json
|
|
318
|
+
{"error": true, "message": "invalid config: ...", "exit_code": 2}
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
## Configuration
|
|
322
|
+
|
|
323
|
+
Fallow reads config from project root: `.fallowrc.json` > `fallow.toml` > `.fallow.toml`. Most projects work with zero configuration thanks to 90 auto-detecting framework plugins.
|
|
324
|
+
|
|
325
|
+
```jsonc
|
|
326
|
+
{
|
|
327
|
+
"$schema": "https://raw.githubusercontent.com/fallow-rs/fallow/main/schema.json",
|
|
328
|
+
"entry": ["src/index.ts"],
|
|
329
|
+
"ignorePatterns": ["**/*.generated.ts"],
|
|
330
|
+
"ignoreDependencies": ["autoprefixer"],
|
|
331
|
+
"publicPackages": ["@myorg/shared-lib"],
|
|
332
|
+
"dynamicallyLoaded": ["plugins/**/*.ts"],
|
|
333
|
+
"rules": {
|
|
334
|
+
"unused-files": "error",
|
|
335
|
+
"unused-exports": "warn",
|
|
336
|
+
"unused-types": "off"
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Rules: `"error"` (fail CI), `"warn"` (report only), `"off"` (skip detection).
|
|
342
|
+
|
|
343
|
+
Config fields:
|
|
344
|
+
- `publicPackages`: workspace packages that are public libraries; exports from these packages are not flagged as unused
|
|
345
|
+
- `dynamicallyLoaded`: glob patterns for files loaded at runtime (plugin dirs, locale files); treated as always-used
|
|
346
|
+
- `usedClassMembers`: class method/property names that extend the built-in Angular/React lifecycle allowlist with framework-invoked names. Each entry is a plain string (global suppression) or a scoped object `{ extends?, implements?, members }` matching only classes with the given heritage. Use scoped rules for common names like `refresh` or `execute` to avoid false negatives on unrelated classes; global strings for unique names like `agInit`. Example: `["agInit", { "implements": "ICellRendererAngularComp", "members": ["refresh"] }, { "extends": "BaseCommand", "members": ["execute"] }]`. An unconstrained scoped rule (no `extends` or `implements`) is rejected at load time. Use plugin-level `usedClassMembers` in a `.fallow/plugins/*.jsonc` file for library-specific allowlists
|
|
347
|
+
- `resolve.conditions`: additional package.json `exports` / `imports` condition names to honor during module resolution. Baseline conditions (`development`, `import`, `require`, `default`, `types`, `node`, plus `react-native` / `browser` under RN/Expo) are always included; user entries prepend ahead of them. Use for community conditions like `worker`, `edge-light`, `deno`, or custom bundler conditions. Example: `{ "resolve": { "conditions": ["worker", "edge-light"] } }`
|
|
348
|
+
|
|
349
|
+
### Inline suppression
|
|
350
|
+
|
|
351
|
+
```typescript
|
|
352
|
+
// fallow-ignore-next-line
|
|
353
|
+
export const keepThis = 1;
|
|
354
|
+
|
|
355
|
+
// fallow-ignore-next-line unused-export
|
|
356
|
+
export const keepThisToo = 2;
|
|
357
|
+
|
|
358
|
+
// fallow-ignore-file
|
|
359
|
+
// fallow-ignore-file unused-export
|
|
360
|
+
|
|
361
|
+
// Mark as intentionally unused (tracked for staleness)
|
|
362
|
+
/** @expected-unused */
|
|
363
|
+
export const deprecatedHelper = () => {};
|
|
364
|
+
```
|
|
365
|
+
|
|
366
|
+
## Key Gotchas
|
|
367
|
+
|
|
368
|
+
- **`fix --yes` is required** in non-TTY (agent) environments. Without it, `fix` exits with code 2
|
|
369
|
+
- **Zero config by default.** 90 framework plugins auto-detect. Don't create config unless customization is needed
|
|
370
|
+
- **Syntactic analysis only.** No TypeScript compiler, so fully dynamic `import(variable)` is not resolved
|
|
371
|
+
- **Function overloads are deduplicated.** TypeScript function overload signatures are merged into a single export (not reported as separate unused exports)
|
|
372
|
+
- **Re-export chains are resolved.** Exports through barrel files are tracked, not falsely flagged
|
|
373
|
+
- **`--changed-since` is additive.** Only new issues in changed files, not all issues in the project
|
|
374
|
+
|
|
375
|
+
For the full list with examples, see [references/gotchas.md](references/gotchas.md).
|
|
376
|
+
|
|
377
|
+
## Instructions
|
|
378
|
+
|
|
379
|
+
1. **Identify the task** from the user's request (audit, fix, find dupes, set up CI, migrate, debug)
|
|
380
|
+
2. **Run the appropriate command** with `--format json --quiet`
|
|
381
|
+
3. **Use filter flags** to limit output when the user asks about specific issue types
|
|
382
|
+
4. **Always dry-run before fix.** Show the user what will change, then apply
|
|
383
|
+
5. **Report results clearly.** Summarize issue counts, list specific findings, suggest next steps
|
|
384
|
+
6. **For false positives,** suggest inline suppression comments or config rule adjustments
|
|
385
|
+
|
|
386
|
+
If `$ARGUMENTS` is provided, use it as the `--root` path or pass it as the target for the appropriate fallow command.
|