Skip to content

refactor(lint): break 1,314-line monolith into focused rule modules with plugin system#170

Merged
miguel-heygen merged 9 commits intomainfrom
refactor/lint-plugin-system
Mar 31, 2026
Merged

refactor(lint): break 1,314-line monolith into focused rule modules with plugin system#170
miguel-heygen merged 9 commits intomainfrom
refactor/lint-plugin-system

Conversation

@miguel-heygen
Copy link
Copy Markdown
Collaborator

@miguel-heygen miguel-heygen commented Mar 31, 2026

Summary

  • Breaks hyperframeLinter.ts from 1,314 lines (one massive function) into a plugin system of focused rule modules
  • Introduces LintContext — HTML is parsed once and shared across all rules
  • Adds LintRule<TContext> type as the formal contract for rules
  • Public API unchanged: lintHyperframeHtml, lintMediaUrls, lintScriptUrls signatures identical

New file structure

src/lint/
  utils.ts          — shared types (OpenTag, ExtractedBlock), regex constants, helpers
  context.ts        — LintContext type + buildLintContext() factory
  rules/
    core.ts         — structural rules (root attrs, timeline registry, script syntax)
    media.ts        — media element rules (duplicate ids, video pitfalls, placeholder URLs, etc.)
    gsap.ts         — GSAP rules + GSAP-specific parsing utils
    captions.ts     — caption rules
    composition.ts  — timed element, deprecated attrs, template literal selector, external scripts
    adapters.ts     — Lottie + Three.js missing-script rules (from PR #149)
  hyperframeLinter.ts — orchestrator only (~200 lines, down from 1,314)

Adding a new adapter rule going forward

  1. Create src/lint/rules/my-adapter.ts exporting myAdapterRules: LintRule[]
  2. Import and spread into ALL_RULES in hyperframeLinter.ts

Test plan

  • All 402 core tests pass unchanged
  • Full workspace build clean (pnpm build)
  • TypeScript strict mode clean (pnpm tsc --noEmit)

miguel-heygen and others added 9 commits April 1, 2026 00:31
…ee.js)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…GN_PATTERN to utils

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…ule modules

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…e modules

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…njection

- Remove local WINDOW_TIMELINE_ASSIGN_PATTERN from gsap.ts; import from utils
- Replace inline truncation in extractMediaUrls/extractScriptUrls with truncateSnippet()
- Remove file: options.filePath from template_literal_selector; orchestrator injects it

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@miguel-heygen miguel-heygen merged commit 5421c23 into main Mar 31, 2026
21 checks passed
Copy link
Copy Markdown
Collaborator Author

Merge activity

miguel-heygen added a commit that referenced this pull request Apr 1, 2026
…files (#181)

## Summary

- Splits the 872-line `hyperframeLinter.test.ts` into focused per-domain test files matching the rule module structure from #170
- Tests still use the public API (`lintHyperframeHtml`) — no internals exposed
- Fixes misplaced tests: `gsap_css_transform_conflict` tests were inside `describe("lintScriptUrls")`, caption/adapter tests were inside `describe("template_literal_selector rule")`

## New structure

```
src/lint/
  hyperframeLinter.test.ts   — orchestrator integration + lintScriptUrls (8 tests)
  rules/
    core.test.ts             — root attrs, timeline registry, host id (6 tests)
    media.test.ts            — duplicate ids, missing id/src, preload (6 tests)
    gsap.test.ts             — clip element, transform conflict, missing script (12 tests)
    captions.test.ts         — caption exit, overflow, relative position (5 tests)
    composition.test.ts      — external script, template literal selector (5 tests)
    adapters.test.ts         — missing Lottie/Three.js scripts (8 tests)
```

## Test plan

- [x] 404 tests pass (402 before — 2 extra from previously misplaced adapter tests now correctly counted)
- [x] Lint + format clean
@miguel-heygen miguel-heygen deleted the refactor/lint-plugin-system branch April 6, 2026 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants