Static analysis rules engine added to monorepo

Two new packages land in n8n's testing suite: a generic rules engine for static analysis and a code health CLI that enforces dependency consistency across the monorepo.
The n8n monorepo gains a new static analysis framework. A generic rules engine called @n8n/rules-engine is being introduced, providing reusable primitives for building code quality checks — a base class for defining typed rules, a runner that handles registry and execution, and a baseline system for incremental adoption.
The first consumer is @n8n/code-health, a CLI tool that runs quality checks across the monorepo. The initial rule catches dependencies that should reference pnpm catalogs instead of hardcoded versions, and flags version mismatches across packages for dependencies not yet centralized. On its first run, the tool found 73 violations across 31 packages.
The baseline feature allows teams to adopt rules without fixing all existing issues immediately. A baseline captures current violations; subsequent runs only report new ones, making enforcement practical for large codebases.
The architecture separates concerns: the rules engine is generic and reusable, while code health provides domain-specific rules. Future rules for detecting code duplication, test-only exports, and incomplete implementations are stubbed but not included in this PR. The rules engine is also designed to replace duplicated code in @n8n/playwright-janitor in a follow-up change.
View Original GitHub Description
Summary
Adds two new packages to packages/testing/:
@n8n/rules-engine
Generic, reusable rules engine for static analysis. Provides:
BaseRule<TContext>— generic abstract class for defining typed rulesRuleRunner<TContext>— rule registry, execution, and report generation- Baseline system for incremental adoption (only flag new violations)
- JSON reporter for machine-consumable output
@n8n/code-health
First consumer of the rules engine. CLI tool for monorepo code quality enforcement.
Implemented rule: catalog-violations — detects:
- Dependencies with hardcoded versions that exist in the pnpm catalog (should use
catalog:) - Cross-package version mismatches for deps not yet in the catalog
First run found 73 violations across 31 packages
Usage
# Run all rules (JSON output)
node packages/testing/code-health/dist/cli.js
# Run specific rule
node packages/testing/code-health/dist/cli.js --rule=catalog-violations
# Create baseline for incremental adoption
node packages/testing/code-health/dist/cli.js baseline
# List available rules
node packages/testing/code-health/dist/cli.js rules
Architecture
@n8n/rules-engine (generic)
└── BaseRule<TContext>, RuleRunner<TContext>, baseline, reporter
@n8n/code-health (domain-specific)
└── CatalogViolationsRule extends BaseRule<CodeHealthContext>
The rules engine is designed to also be consumed by @n8n/playwright-janitor in a follow-up PR, replacing its duplicated BaseRule/RuleRunner/baseline code.
Future rules (stubbed, not in this PR)
duplication— jscpd wrappertest-only-exports— ts-morph reference analysisincomplete-implementations— detect types with no concrete class
Related Linear tickets, Github issues, and Community forum posts
<!-- Part of shift-right observability / code quality initiative -->Review / Merge checklist
- PR title and summary are descriptive. (conventions)
- Docs updated or follow-up ticket created.
- Tests included.
- PR Labeled with
Backport to Beta,Backport to Stable, orBackport to v1(if the PR is an urgent fix that needs to be backported)