prefer-padding-components
Prefer local padding components when a <uipadding /> element already matches them.
Rule details Suggestion
Section titled “Rule details ”SuggestionThis rule checks empty <uipadding /> elements with exactly these four attributes: PaddingTop, PaddingBottom,
PaddingLeft, and PaddingRight.
It reports two cases:
| Shape | Report |
|---|---|
| All four values are the same | EqualPadding |
PaddingTop matches PaddingBottom, and PaddingLeft matches PaddingRight | DirectionalPadding |
The rule only reports when the project already has a matching local component.
Examples
Section titled “Examples” Incorrect
Repeated padding attributes
Section titled “Repeated padding attributes”<uipadding PaddingBottom={padding} PaddingLeft={padding} PaddingRight={padding} PaddingTop={padding}/>; Correct
Matching local components
Section titled “Matching local components”<EqualPadding padding={padding} />;
<DirectionalPadding horizontal={horizontal} vertical={vertical} />;Auto-fix behavior
Section titled “Auto-fix behavior”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:
horizontalcomes fromPaddingTopandPaddingBottomverticalcomes fromPaddingLeftandPaddingRight
Related rules
Section titled “Related rules” prefer-udim2-shorthand Replaces repeated Roblox constructor patterns with shorter forms
prefer-context-stack Pushes repeated JSX structure into a shared component