Skip to content

prefer-padding-components

Prefer local padding components when a <uipadding /> element already matches them.

This rule checks empty <uipadding /> elements with exactly these four attributes: PaddingTop, PaddingBottom, PaddingLeft, and PaddingRight.

It reports two cases:

ShapeReport
All four values are the sameEqualPadding
PaddingTop matches PaddingBottom, and PaddingLeft matches PaddingRightDirectionalPadding

The rule only reports when the project already has a matching local component.

Incorrect
<uipadding
PaddingBottom={padding}
PaddingLeft={padding}
PaddingRight={padding}
PaddingTop={padding}
/>;
Correct
<EqualPadding padding={padding} />;
<DirectionalPadding horizontal={horizontal} vertical={vertical} />;

Auto-fix only runs in .jsx and .tsx files, and only when the current file already imports exactly one matching local component.

For DirectionalPadding, the generated props follow the local component contract used by the rule:

  • horizontal comes from PaddingTop and PaddingBottom
  • vertical comes from PaddingLeft and PaddingRight