n8n/packages/testing/code-health
2026-05-12 10:58:00 +00:00
..
src chore: Skip scaffolding templates in code-health and swap to catalog refs (no-changelog) (#30297) 2026-05-12 10:58:00 +00:00
eslint.config.mjs ci: Add rules engine and code health packages (no-changelog) (#27815) 2026-03-31 11:20:11 +00:00
package.json ci: Gate PRs on code-health and janitor checks (#30091) 2026-05-12 09:02:53 +00:00
README.md chore: Add code-health baseline and fix janitor catalog violation (no-changelog) (#28958) 2026-04-23 09:55:55 +00:00
tsconfig.build.json ci: Add rules engine and code health packages (no-changelog) (#27815) 2026-03-31 11:20:11 +00:00
tsconfig.json ci: Add rules engine and code health packages (no-changelog) (#27815) 2026-03-31 11:20:11 +00:00
vitest.config.ts ci: Add rules engine and code health packages (no-changelog) (#27815) 2026-03-31 11:20:11 +00:00

@n8n/code-health

Static analysis for monorepo dependency hygiene. Built on @n8n/rules-engine.

What it does

Scans all package.json files across the monorepo and flags:

  • Hardcoded catalog deps — dependencies using a pinned version when pnpm-workspace.yaml already defines a catalog entry
  • Cross-package version drift — the same dependency appearing in multiple packages with different versions

Usage

# Build first
pnpm --filter=@n8n/code-health build

# Run analysis (uses baseline if present)
node packages/testing/code-health/dist/cli.js

# Show all violations (ignore baseline)
node packages/testing/code-health/dist/cli.js --ignore-baseline

# Run a specific rule
node packages/testing/code-health/dist/cli.js --rule=catalog-violations

# List available rules
node packages/testing/code-health/dist/cli.js rules

Baseline

The baseline (.code-health-baseline.json at repo root) snapshots current violations so only new violations fail the check.

# Generate/update baseline
node packages/testing/code-health/dist/cli.js baseline

# Commit it
git add .code-health-baseline.json
git commit -m "chore: update code-health baseline"

Output

All output is JSON. Exit code 1 if new violations are found, 0 if clean.

{
  "summary": {
    "totalViolations": 3,
    "byRule": { "catalog-violations": 3 },
    "bySeverity": { "error": 3, "warning": 0, "info": 0 }
  }
}

Adding rules

Rules extend BaseRule<CodeHealthContext> from @n8n/rules-engine. See src/rules/catalog-violations.rule.ts for the pattern. Register new rules in src/index.ts.