Skip to content

missing-ref-attachment

Reports asContainer() or asAnchor() in a call that does not attach the ref.

This rule reports asContainer() or asAnchor() in a style() call that does not also attach the ref. The container or anchor applies only to an element that has the ref, so without it, nothing happens.

Reported

const card = style.ref("card");
style(card.asContainer("inline-size"));missing-ref-attachment: ref `card` provider has no matching marker attachment in this style() call

Fixed

const card = style.ref("card");
style(card, card.asContainer("inline-size"));

How to fix

Pass the ref and the method in the same style() call, as in the example.

positionAnchor() is not reported. The positioned element does not need the ref.

Rule settings

PresetSeverity
recommendedwarn
strictdeny
stylisticoff

Configure lint to change the severity or options.