feat(lint): add rules for non-deterministic code, missing clip class, overlapping tracks, and rAF detection#193
Conversation
… overlapping tracks, and rAF detection Add 4 new lint rules to close E2E testing gaps: - non_deterministic_code (error): detects Math.random(), Date.now(), new Date(), performance.now(), crypto.getRandomValues() in scripts - timed_element_missing_clip_class (warning): flags timed elements without class="clip" - overlapping_clips_same_track (error): detects overlapping clips on the same track index - requestanimationframe_in_composition (warning): flags rAF usage that won't sync with frame capture All rules strip single-line comments before scanning to avoid false positives. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
@miguel-heygen should we make these warnings? I think there are potential use cases for some simulations to use thse but yes they will not produce the exact same output unless we seed the RNG ? |
|
what does this mean exactly? |
requestAnimationFrame (raf) doesn't work well with the renderer using vivus.js library |
with a seed it's fully deterministic, in my opinion we should make these errors because they can produce unexpected outputs that we can't control with the runtime code in certain cases |
vanceingalls
left a comment
There was a problem hiding this comment.
Review feedback
Important: Non-null assertions
packages/core/src/lint/rules/composition.ts uses clips[i]! and clips[i + 1]! in the overlap rule. Project convention forbids ! assertions — use a guard like if (!current || !next) continue; instead.
Important: Block comment false positives
The comment stripping in non_deterministic_code and requestanimationframe_in_composition only strips // ... single-line comments. Multi-line /* Math.random() */ will still trigger false positives. Fix:
const stripped = script.content
.replace(/\/\/.*$/gm, "")
.replace(/\/\*[\s\S]*?\*\//g, "");Note: Rule overlap
The new timed_element_missing_clip_class (warning) overlaps with the existing timed_element_missing_visibility_hidden (info). A single element could trigger both with slightly contradictory messaging. Consider merging or gating the older rule.
Tests look solid — 3 per rule with positive/negative/edge cases.
Address review feedback: - Strip /* */ block comments in addition to // line comments to prevent false positives in non_deterministic_code and rAF rules - Replace clips[i]! non-null assertions with guard clause per project convention Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
All three review items addressed:
All 56 rule tests still passing. |
… overlapping tracks, and rAF detection (#193) ## Summary Adds 4 new lint rules found missing during comprehensive E2E testing: - **`non_deterministic_code`** (error) — detects `Math.random()`, `Date.now()`, `new Date()`, `performance.now()`, `crypto.getRandomValues()` in scripts. Confirmed: two renders with Math.random() produced different checksums. - **`timed_element_missing_clip_class`** (warning) — flags elements with `data-start`/`data-duration` but no `class="clip"`. Without it, elements are visible forever instead of only during their time window. - **`overlapping_clips_same_track`** (error) — detects clips on the same `data-track-index` with overlapping time ranges. - **`requestanimationframe_in_composition`** (warning) — warns that rAF-based animations don't sync with frame capture. Discovered when Vivus.js (rAF-based) produced incorrect output. 12 new tests, all passing. **Part 1 of 5** in a stacked PR series fixing E2E test findings. ## Test plan - [x] 12 new tests (3 per rule: positive, negative, edge case) - [x] Full suite: 56 pass in rule tests - [x] `npx tsx scripts/lint-skills.ts` — no issues

Summary
Adds 4 new lint rules found missing during comprehensive E2E testing:
non_deterministic_code(error) — detectsMath.random(),Date.now(),new Date(),performance.now(),crypto.getRandomValues()in scripts. Confirmed: two renders with Math.random() produced different checksums.timed_element_missing_clip_class(warning) — flags elements withdata-start/data-durationbut noclass="clip". Without it, elements are visible forever instead of only during their time window.overlapping_clips_same_track(error) — detects clips on the samedata-track-indexwith overlapping time ranges.requestanimationframe_in_composition(warning) — warns that rAF-based animations don't sync with frame capture. Discovered when Vivus.js (rAF-based) produced incorrect output.12 new tests, all passing.
Part 1 of 5 in a stacked PR series fixing E2E test findings.
Test plan
npx tsx scripts/lint-skills.ts— no issues