Skip to content

fix: three-prefer-set-animation-loop only fires when file imports Three.js - #1796

Draft
skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1795-0148
Draft

skoshx wants to merge 2 commits into
mainfrom
cursor/triage-1795-0148

Conversation

@skoshx

@skoshx skoshx commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Fixes #1795

Root Cause

three-prefer-set-animation-loop was firing on any recursive requestAnimationFrame loop in projects with three as a dependency, even for 2D canvas animations that never use Three.js. The rule was gated at the project level but had no file-level check.

Fix Scope

Added file-level gate: the rule now only fires when the file imports from Three.js ecosystem packages (three, @react-three/*). This is narrow and safe because:

  • ✅ If using Three.js, you MUST import it → rule still catches real issues
  • ✅ 2D canvas loops without imports → correctly ignored

Changes

  • Created hasThreeImport helper to detect Three.js imports (ESM, CJS, TS import-equals)
  • Updated rule to check fileImportsThree before reporting
  • Updated tests: added regression test for 2D canvas, updated existing test to reflect new behavior
  • Added changeset (patch)

Validation

  • ✅ Unit tests pass (6/6)
  • ✅ Manual reproduction: false positive eliminated
  • ✅ Type checks pass
  • ✅ Lint passes
  • 🔄 Parity checks in progress
Open in Web Open in Cursor 

cursoragent and others added 2 commits September 10, 2026 17:34
…ee.js

The rule was firing on any recursive requestAnimationFrame loop in projects
with three as a dependency, even for 2D canvas animations that never use
Three.js.

Now the rule checks for file-level Three.js imports (three, @react-three/*)
before reporting. This prevents false positives on 2D canvas/DOM animation
loops while still catching real Three.js animation frame usage.

Closes #1795

Co-authored-by: Skosh <skoshx@users.noreply.github.com>
Co-authored-by: Skosh <skoshx@users.noreply.github.com>
@pkg-pr-new

pkg-pr-new Bot commented Sep 10, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/eslint-plugin-react-doctor@1796
npm i https://pkg.pr.new/oxlint-plugin-react-doctor@1796
npm i https://pkg.pr.new/react-doctor@1796

commit: a915837

@cursor

cursor Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Parity Check Status

The full corpus scan is in progress (373/8423 repos processed so far). Given the narrow scope of this change, here's the expected parity outcome:

Expected Changes

  • Files WITH Three.js imports + recursive rAF: No change (still fires correctly) ✅
  • Files WITHOUT Three.js imports + recursive rAF: Diagnostic removed (false positive fixed) ✅

Risk Assessment

This fix is low risk because:

  1. The gate is additive only - we're adding a requirement (Three.js import), not removing one
  2. If you use Three.js APIs, you MUST import Three.js first - there's no way to use Three.js without importing it
  3. Edge case where import exists but isn't used: Very unlikely, and would be caught by unused-import linters

Manual Validation

Will update with full parity results when the corpus scan completes.

@github-actions

Copy link
Copy Markdown
Contributor

Interactive terminal E2E

Terminal Control verified the built CLI at a915837 in a real PTY:

  • selected a project interactively and observed Scanning... before the three-second Git delay completed
  • waited for the clean result and exercised the compact report
  • opened copy context and the GitHub Actions confirmation, then cancelled safely

Download the edited MP4 and PNG evidence

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.

three-prefer-set-animation-loop: 2D canvas requestAnimationFrame loops in three-capable projects

2 participants