Configuration
Customize metric thresholds and path exclusions via tsmetrics.yaml.
tsmetrics.yaml
tsmetrics looks for a tsmetrics.yaml file in the current working directory (then its parents). If not found, all settings fall back to built-in defaults.
tsmetrics.yaml
# All fields are optional — omitted keys use defaults. # Exclude paths from analysis (glob patterns) exclude: - "**/*.test.ts" - "**/*.spec.tsx" - "src/generated/**" # Override warning/error thresholds per metric thresholds: cyclomatic_complexity: warning: 10 # default: 10 error: 25 # default: 25 loc: warning: 50 # default: 50 error: 100 # default: 100 nesting: warning: 3 # default: 3 error: 5 # default: 5 params: warning: 4 # default: 4 error: 7 # default: 7 wmc: warning: 20 # default: 20 error: 50 # default: 50 noi: warning: 3 # default: 3 error: 5 # default: 5
exclude
The exclude field accepts a list of glob patterns. Matched files are skipped entirely — no metrics are computed for them.
tsmetrics also has built-in default exclusions that always apply:
always excluded
node_modules/ .git/ dist/ build/ coverage/ .next/
Patterns in exclude are additive — they extend, not replace, the defaults.
Default thresholds
| Metric | Warning | Error | Description |
|---|---|---|---|
cyclomatic_complexity | 10 | 25 | Decision-point count per function |
loc | 50 | 100 | Lines of code per function |
nesting | 3 | 5 | Maximum nesting depth per function |
params | 4 | 7 | Number of parameters per function |
wmc | 20 | 50 | Weighted Methods per Class |
noi | 3 | 5 | Number of Implemented Interfaces |
Severity levels
Each metric threshold has two levels:
- Warning — value ≥
warningthreshold (but <error) - Error — value ≥
errorthreshold
Violations appear in the output (table and HTML formats show a violations table; JSON includes them in the violations array).
Constraint:
warning must be ≤ error. tsmetrics will fail with an error message if this is violated.
Partial overrides
You can override just warning or just error — the other stays at its default:
thresholds:
cyclomatic_complexity:
warning: 7 # only override warning; error stays at 25
Stricter CI configuration
exclude:
- "**/*.test.ts"
- "**/*.spec.tsx"
thresholds:
cyclomatic_complexity:
warning: 7
error: 15
loc:
warning: 40
error: 80
nesting:
warning: 2
error: 4
params:
warning: 3
error: 5
Edit on GitHub