New
Introducing React Bench, see how different models perform on React code

react-doctor/no-layout-property-animation

Animating layout properties can recalculate geometry every frame; confirm the animation is large, repeated, or measurably costly before changing its semantics

Status
Active
Category
Performance
Assessment
Evidence-required risk
Required evidence
source code, runtime behavior, measurement
Default configuration
Enabled
Default severity
error
Show technical metadata
Scope
All supported frameworks
Active when
always
Requirements
react
Tags
test-noise
Priority
34 (P3)
Source
oxlint-plugin-react-doctor
Rule set
oxlint-plugin-react-doctor 0.9.3 (prompt schema 2)
On this page

Validation prompt

Confirm the detector match and collect the required evidence before deciding whether an edit is warranted.

There are two detector branches. The JSX branch reports a static layout key (width/height and min/max variants, inset, margin/padding, borderWidth, fontSize, lineHeight, gap) inside a Motion animation object only when the tag text is motion.*, m.*, or an identifier beginning with Motion; it does not resolve those names to an import, so an unrelated Motion* component can be a false positive, while styled(motion.*), motion.create(), and other wrappers are normally missed. The Web Animations branch reports the same keys in static keyframes passed to a proven DOM element.animate(...) receiver. Confirm the reported key is actually interpolated. A direct Motion height: 0 to height: 'auto' animation measures the target but still interpolates height and can perform layout each frame; it is not the transform-based layout projection provided by the layout prop. Treat a small, bounded intrinsic-size enter/exit as a possible intentional exception, not as FLIP. Prioritize repeated keyframes, large affected subtrees, and looping numeric size/position animations, and use a trace when performance impact is the reason for changing behavior.

Evidence boundary

The diagnostic proves only that the detector’s modeled source pattern matched. It does not prove runtime impact, product intent, rendered failure, or that one remediation is correct.

Establish the environment, repository policy, exceptions, and required rendered or runtime evidence before deciding the occurrence.

Record one outcome:

  • Confirmed failure: The required evidence establishes the violation.
  • Rejected: A documented exception or false-positive predicate applies.
  • Needs evidence: Named evidence can still be collected.
  • Unavailable: Required evidence cannot be collected in this run.
  • Waived with evidence: An authorized, scoped exception applies to an established failure.
  • Observation: The review records an optional tradeoff without claiming a defect.

A waiver records its scope, authority, evidence, and review condition. It is not a pass or false positive.

Default severity is registry metadata. Use the occurrence’s JSON severity after repository configuration when ordering real findings.

Fix prompt

Apply this candidate correction only after the required evidence confirms the risk.

Choose the fix from the visual and layout contract. For visual-only movement or a looping pulse, establish the final geometry and animate translate/scale (with the correct transform origin) and opacity; transform and opacity are broadly compositor-eligible, not guaranteed free. For a real layout change, update width/height/position through style, className, or state and use Motion's layout prop so layout projection animates the before/after geometry with transforms. For an intrinsic accordion or enter/exit reveal, a scoped one-shot height: 0 to height: 'auto' animation may be the least-distorting option; keep it when appropriate, contain its layout scope, honor reduced motion, and profile it rather than calling it FLIP. Do not mechanically replace size with scale when siblings must reflow, text must remain undistorted, or hit areas and clipping would change. Apply the same distinction to WAAPI keyframes. See https://motion.dev/docs/react-layout-animations

Repository-wide copy prompt

Use this repository-wide prompt only after validating each occurrence. For one occurrence, use the guidance above.

Show repository-wide prompt

Fix every confirmed react-doctor/no-layout-property-animation diagnostic in the current repository.

Required change:

  • Choose the fix from the visual and layout contract. For visual-only movement or a looping pulse, establish the final geometry and animate translate/scale (with the correct transform origin) and opacity; transform and opacity are broadly compositor-eligible, not guaranteed free. For a real layout change, update width/height/position through style, className, or state and use Motion's layout prop so layout projection animates the before/after geometry with transforms. For an intrinsic accordion or enter/exit reveal, a scoped one-shot height: 0 to height: 'auto' animation may be the least-distorting option; keep it when appropriate, contain its layout scope, honor reduced motion, and profile it rather than calling it FLIP. Do not mechanically replace size with scale when siblings must reflow, text must remain undistorted, or hit areas and clipping would change. Apply the same distinction to WAAPI keyframes. See https://motion.dev/docs/react-layout-animations.

Validation before editing:

There are two detector branches. The JSX branch reports a static layout key (width/height and min/max variants, inset, margin/padding, borderWidth, fontSize, lineHeight, gap) inside a Motion animation object only when the tag text is motion.*, m.*, or an identifier beginning with Motion; it does not resolve those names to an import, so an unrelated Motion* component can be a false positive, while styled(motion.*), motion.create(), and other wrappers are normally missed. The Web Animations branch reports the same keys in static keyframes passed to a proven DOM element.animate(...) receiver. Confirm the reported key is actually interpolated. A direct Motion height: 0 to height: 'auto' animation measures the target but still interpolates height and can perform layout each frame; it is not the transform-based layout projection provided by the layout prop. Treat a small, bounded intrinsic-size enter/exit as a possible intentional exception, not as FLIP. Prioritize repeated keyframes, large affected subtrees, and looping numeric size/position animations, and use a trace when performance impact is the reason for changing behavior.

Constraints:

  • Make the smallest change that fixes the root cause.
  • Preserve behavior and interfaces unrelated to this diagnostic.
  • Reuse existing project components, utilities, and conventions.
  • Do not introduce render-phase side effects, render-phase state updates, or Hooks rule violations.
  • Preserve resource ownership and cleanup. Do not move work into a hotter render or frame path.
  • If syntax proves only a candidate cost, require a relevant trace, bundle report, payload measurement, or metric before editing.
  • Without evidence, record Needs evidence. Compare the same scenario before and after; keep the change only when its target metric improves without regression.
  • Adapt identifiers and framework details instead of copying blindly.
  • Do not disable the rule or suppress matching code.

Assessment:

  • Record detector evidence, applicability facts, assumptions, missing evidence, and the rule class for this occurrence.
  • Return one outcome: Confirmed failure, Rejected, Needs evidence, Unavailable, Waived with evidence, or Observation.
  • A waiver records the established failure, scope, authority, evidence, and review or expiry condition. It is not a pass or false positive.

Verification:

  • Run focused tests for the changed behavior.
  • Run React Doctor and confirm this diagnostic no longer appears from changed code.
  • Run an unfiltered scan of the affected scope before claiming no cross-category regression.
  • Report the files changed and any checks you could not run.