85453da49f
CodeQL / Analyze (javascript-typescript) (push) Waiting to run
Docs / Validate docs (push) Waiting to run
CodeQL / Analyze (actions) (push) Waiting to run
CodeQL / Analyze (python) (push) Waiting to run
Sync skills to ClawHub / Publish changed skills (push) Waiting to run
regression / regression-shards (style-16-prod style-9-prod style-17-prod iframe-render-compat variables-prod mp4-h265-sdr, shard-4) (push) Has been cancelled
regression / regression-shards (style-4-prod style-11-prod style-2-prod animejs-adapter typegpu-adapter parallel-capture-regression, shard-5) (push) Has been cancelled
regression / regression-shards (style-7-prod style-8-prod style-10-prod css-spinner-render-compat webm-transparency mp4-h264-sdr webm-vp9, shard-3) (push) Has been cancelled
regression / regression-shards (sub-composition-video style-18-prod raf-ball-render-compat font-variant-numeric sub-comp-t0 sub-comp-id-selector, shard-7) (push) Has been cancelled
Windows render verification / Detect changes (push) Has been cancelled
Windows render verification / Preflight (lint + format) (push) Has been cancelled
Windows render verification / Render on windows-latest (push) Has been cancelled
Windows render verification / Tests on windows-latest (push) Has been cancelled
CI / Detect changes (push) Has been cancelled
CI / Build (push) Has been cancelled
CI / Lint (push) Has been cancelled
CI / Fallow audit (push) Has been cancelled
CI / Format (push) Has been cancelled
CI / Typecheck (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Producer: integration tests (push) Has been cancelled
CI / Producer: unit tests (push) Has been cancelled
CI / File size check (push) Has been cancelled
CI / Test: skills (push) Has been cancelled
CI / Skills: manifest in sync (push) Has been cancelled
CI / CLI: npx shim (macos-latest) (push) Has been cancelled
CI / CLI: npx shim (ubuntu-latest) (push) Has been cancelled
CI / CLI: npx shim (windows-latest) (push) Has been cancelled
CI / SDK: unit + contract + smoke (push) Has been cancelled
CI / Test: runtime contract (push) Has been cancelled
CI / Studio: load smoke (push) Has been cancelled
CI / Smoke: global install (push) Has been cancelled
CI / CLI smoke (required) (push) Has been cancelled
CI / Semantic PR title (push) Has been cancelled
Player perf / Detect changes (push) Has been cancelled
Player perf / Preflight (lint + format) (push) Has been cancelled
Player perf / player-perf (push) Has been cancelled
Player perf / Perf: drift (push) Has been cancelled
Player perf / Perf: fps (push) Has been cancelled
Player perf / Perf: parity (push) Has been cancelled
Player perf / Perf: scrub (push) Has been cancelled
Player perf / Perf: load (push) Has been cancelled
preview-regression / Detect changes (push) Has been cancelled
preview-regression / Preflight (lint + format) (push) Has been cancelled
preview-regression / Preview parity (push) Has been cancelled
preview-regression / preview-regression (push) Has been cancelled
regression / regression (push) Has been cancelled
regression / Detect changes (push) Has been cancelled
regression / Preflight (lint + format) (push) Has been cancelled
regression / regression-shards (hdr-regression style-5-prod style-3-prod mov-prores, shard-1) (push) Has been cancelled
regression / regression-shards (overlay-montage-prod style-12-prod chat missing-host-comp-id png-sequence portrait-edge-bleed, shard-6) (push) Has been cancelled
regression / regression-shards (style-13-prod style-6-prod vignelli-stacking gsap-letters-render-compat audio-mux-parity, shard-8) (push) Has been cancelled
regression / regression-shards (style-15-prod hdr-hlg-regression style-1-prod many-cuts vfr-screen-recording render-symlinked-assets, shard-2) (push) Has been cancelled
132 lines
5.0 KiB
Plaintext
132 lines
5.0 KiB
Plaintext
---
|
|
title: "@hyperframes/lint"
|
|
description: "The composition linter as a standalone library — lint a directory or a single HTML file without the CLI."
|
|
---
|
|
|
|
The lint package is the composition linter extracted from core into a dedicated, independently-installable package. It's the **single source of truth** for linting: both the CLI's `hyperframes lint` command and the render-time render-gate consume the same rule engine from here.
|
|
|
|
```bash
|
|
npm install @hyperframes/lint
|
|
```
|
|
|
|
## When to Use
|
|
|
|
<Tip>
|
|
This package is the payoff of running validation **as a library** instead of shelling out to the CLI. A Node app (an agent harness, a CI step, an editor plugin) can `import { lintProject } from '@hyperframes/lint'` and lint a composition directory directly — no `npx hyperframes lint` subprocess, no stdout parsing.
|
|
</Tip>
|
|
|
|
**Use `@hyperframes/lint` when you need to:**
|
|
- Lint a composition project (an index + sub-compositions) from Node
|
|
- Lint a single HTML string programmatically
|
|
- Gate a render on lint findings (`shouldBlockRender`)
|
|
- Surface lint findings in your own UI or CI annotations
|
|
|
|
<Info>
|
|
`@hyperframes/core/lint` still resolves (via a back-compat re-export stub), so existing imports keep working. New code should import from `@hyperframes/lint` directly.
|
|
</Info>
|
|
|
|
## Package Exports
|
|
|
|
The lint package has a single entry point:
|
|
|
|
```typescript
|
|
import {
|
|
lintHyperframeHtml,
|
|
lintMediaUrls,
|
|
lintProject,
|
|
shouldBlockRender,
|
|
} from '@hyperframes/lint';
|
|
import type {
|
|
HyperframeLintResult,
|
|
HyperframeLintFinding,
|
|
HyperframeLintSeverity, // "error" | "warning" | "info"
|
|
HyperframeLinterOptions,
|
|
ProjectLintResult,
|
|
} from '@hyperframes/lint';
|
|
```
|
|
|
|
## Linting a Single Composition
|
|
|
|
```typescript
|
|
import { lintHyperframeHtml, lintMediaUrls } from '@hyperframes/lint';
|
|
|
|
const result = lintHyperframeHtml(html, { filePath: 'index.html' });
|
|
// result.ok, result.errorCount, result.warningCount, result.findings
|
|
|
|
for (const finding of result.findings) {
|
|
console.log(finding.severity, finding.code, finding.message);
|
|
// finding.file, finding.selector, finding.elementId, finding.fixHint, finding.snippet
|
|
}
|
|
|
|
// Additional media URL validation
|
|
const mediaFindings = lintMediaUrls(result.findings);
|
|
```
|
|
|
|
## Linting a Project
|
|
|
|
`lintProject` walks a composition directory — the index plus any sub-compositions — and returns aggregated findings. It takes a **directory path string**, so it's callable from any Node context with nothing but a path:
|
|
|
|
```typescript
|
|
import { lintProject, shouldBlockRender } from '@hyperframes/lint';
|
|
import type { ProjectLintResult } from '@hyperframes/lint';
|
|
|
|
const result: ProjectLintResult = await lintProject('./my-composition');
|
|
// result.totalErrors, result.totalWarnings, result.results[]
|
|
// each result entry: { file, result: HyperframeLintResult }
|
|
|
|
if (shouldBlockRender(false, false, result.totalErrors, result.totalWarnings)) {
|
|
throw new Error(`Lint found ${result.totalErrors} blocking error(s)`);
|
|
}
|
|
```
|
|
|
|
## Browser usage
|
|
|
|
The rule engine runs **fully client-side** — no Node.js, no filesystem, no server round-trip. Import from the `@hyperframes/lint/browser` entry to validate composition HTML directly in a browser-only editor or tool:
|
|
|
|
```typescript
|
|
import { lintHyperframeHtml, shouldBlockRender } from '@hyperframes/lint/browser';
|
|
|
|
const result = await lintHyperframeHtml(htmlString, { filePath: 'index.html' });
|
|
if (!result.ok) {
|
|
for (const f of result.findings) console.warn(f.code, f.message);
|
|
}
|
|
```
|
|
|
|
The browser entry exposes `lintHyperframeHtml`, `lintMediaUrls`, and `shouldBlockRender` — everything that operates on an HTML string. It is built with a browser target and contains **zero `node:` builtins**, so it bundles cleanly for the client (verified at build time).
|
|
|
|
<Info>
|
|
`lintProject` (which walks a project **directory**) is filesystem-based and is **not** part of the browser entry — import it from the main `@hyperframes/lint` entry in Node.
|
|
</Info>
|
|
|
|
## What the Linter Catches
|
|
|
|
Detected issues include:
|
|
|
|
- Missing timeline registration (`window.__timelines`)
|
|
- Unmuted video elements (causes autoplay failures)
|
|
- Missing `class="clip"` on timed visible elements
|
|
- Deprecated attribute names
|
|
- Missing composition dimensions (`data-width`, `data-height`)
|
|
- Invalid `data-start` references to nonexistent clip IDs
|
|
|
|
<Info>
|
|
For a full list of what the linter catches and how to fix each issue, see [Common Mistakes](/guides/common-mistakes) and [Troubleshooting](/guides/troubleshooting).
|
|
</Info>
|
|
|
|
## Related Packages
|
|
|
|
<CardGroup cols={2}>
|
|
<Card title="@hyperframes/parsers" icon="code" href="/packages/parsers">
|
|
The HTML + GSAP parsing layer the linter builds on.
|
|
</Card>
|
|
<Card title="@hyperframes/core" icon="cube" href="/packages/core">
|
|
Types and runtime; re-exports the linter for back-compat.
|
|
</Card>
|
|
<Card title="CLI" icon="terminal" href="/packages/cli">
|
|
`npx hyperframes lint` wraps this package.
|
|
</Card>
|
|
<Card title="Studio" icon="palette" href="/packages/studio">
|
|
Surfaces lint findings in the editor.
|
|
</Card>
|
|
</CardGroup>
|