Skip to content

invalid-view-transition-use

Reports extra or invalid arguments to .for() of a view transition.

This rule reports a .for() call with more than one argument, or with a key that is not a string or a number. One .for() call names one element, so extra arguments do not name more elements.

Reported

const transition = style.viewTransition({ old: "duration-150" });
style(transition.for("a", "b"));invalid-view-transition-use: viewTransition.for() accepts at most one key expression

Fixed

const transition = style.viewTransition({ old: "duration-150" });
const first = style(transition.for("a"));
const second = style(transition.for("b"));

How to fix

  • Give each element its own .for() call with its own key, as in the example.
  • Use a string or a number as the key, such as the ID of the item.

See style.viewTransition().

Rule settings

PresetSeverity
recommendeddeny
strictdeny
stylisticoff

Configure lint to change the severity or options.