Merged
Size
L
Change Breakdown
Refactor45%
Maintenance30%
Dependencies15%
Docs10%
#27840test: Adopt rules engine in playwright janitor (no-changelog)

Shared rules engine adopted by janitor tests

The Playwright janitor now leans on the rules-engine for baseline filtering and fix types, cutting ~200 duplicated lines and establishing a common foundation for code health tooling.

The Playwright janitor had its own copy of violation types, baseline filtering, and fix data structures — code that existed in parallel with the already-generic rules-engine. Rather than maintain two versions of the same logic, the janitor now re-exports from and in the rules-engine package.

This is a maintenance win for the n8n codebase: janitor-specific fix types still exist locally (narrowing the engine's generic fix data for domain operations), but the underlying infrastructure is unified. Baseline generation, loading, and filtering all delegate to engine functions. Rule files use type guards like that align with the engine's pattern rather than raw property access.

The rules-engine itself gains new capabilities in this PR — explicit fixable properties on rules and violations, a method, and for auto-fix workflows. These form the foundation for future tooling built on top of the engine.

In the @n8n/testing packages, the janitor stays functionally unchanged — all 10 rules operate identically, and the 336 tests that passed before still pass. The difference is in code ownership: baseline and type definitions live in one place now.

View Original GitHub Description

Summary

Migrates @n8n/playwright-janitor to consume shared types and baseline logic from @n8n/rules-engine, eliminating ~200 lines of duplicated code.

What changed

@n8n/rules-engine (enhanced):

  • Added FixData as an abstract interface ({ type: string; [key: string]: unknown }) — extensible by consumers for domain-specific fix actions (removal, replacement, etc.)
  • Added fixable to BaseRule, Violation, RuleResult, and RuleInfo
  • Added fix() method to BaseRule (default no-op, override for fixable rules)
  • Added filterViolations() — lower-level API for filtering violations without wrapping in a report
  • Extracted applyFixes() in RuleRunner to remove duplication between run() and runRule()
  • Added 22 tests across 4 suites (BaseRule, RuleRunner, baseline, reporter)
  • Added README with API docs and usage examples

@n8n/playwright-janitor (migrated):

  • types.ts — re-exports Violation, RuleResult, FixResult, FixData, Severity from @n8n/rules-engine instead of defining locally
  • baseline.ts — thin wrappers around engine functions (no synthetic report construction, no type casts)
  • dead-code.rule.ts — uses isMethodFix()/isPropertyFix() type guards instead of raw property access on fixData
  • test-data-hygiene.rule.ts — uses isEditFix() type guard
  • Janitor-specific MethodFixData, PropertyFixData, ClassFixData, EditFixData types stay local (narrow the engine's generic FixData)

What didn't change

  • All 10 janitor rules — logic untouched
  • All 336 janitor tests — pass without modification
  • base-rule.ts, rule-runner.ts, reporter.ts, config.ts — untouched
  • TCR, impact analysis, orchestration — untouched

How to verify

cd packages/testing/rules-engine && pnpm build && pnpm test  # 22 tests
cd packages/testing/janitor && pnpm build && pnpm test        # 336 tests

Related Linear tickets, Github issues, and Community forum posts

<!-- Follow-up to #27815 which introduced @n8n/rules-engine -->

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, or Backport to v1 (if the PR is an urgent fix that needs to be backported)
© 2026 · via Gitpulse