redundantAspectRatioConstraintThis component already renders a uiaspectratioconstraint internally. Passing one as a child is redundant and will cause layout issues.small-rules/no-redundant-aspect-ratio-constraintDisallow redundant uiaspectratioconstraint children inside components that already manage their own aspect ratio internally.
Some components already render a uiaspectratioconstraint internally – passing one as a child is redundant
and can cause layout fighting. This catches the case where you hand a UIAspectRatioConstraint to a
component that manages its own.
It’s not just checking the current file. The rule reads imported component files to see if they already
render the constraint, so ButtonSpritesheet and friends get caught even when the constraint lives in their
source. Spritesheet components are known to do this.
redundantAspectRatioConstraintThis component already renders a uiaspectratioconstraint internally. Passing one as a child is redundant and will cause layout issues.This rule does not accept options.
const UI_ASPECT_RATIO_CONSTRAINT = <uiaspectratioconstraint AspectRatio={1.5} />;
function LabelSpritesheet({ children }: { children?: React.ReactNode }) { return ( <imagelabel> {children} <uiaspectratioconstraint AspectRatio={1.5} /> </imagelabel> );}
const view = ( <LabelSpritesheet sprite="icon"> {UI_ASPECT_RATIO_CONSTRAINT} </LabelSpritesheet> );function LabelSpritesheet({ children }: { children?: React.ReactNode }) { return ( <imagelabel> {children} <uiaspectratioconstraint AspectRatio={1.5} /> </imagelabel> );}
const view = ( <LabelSpritesheet sprite="icon"> <uigradient Color={gradient} /> <textlabel Text="hello" /> </LabelSpritesheet> );