Skip to content

Prefer Hoisted Jsx Elements

Suggestion
small-rules/prefer-hoisted-jsx-elements

Prefer extracting static Roblox JSX intrinsic elements to module-level constants.

Diagnostic Messages

hoistableJsxElement
Extract `{{elementText}}` to a shared module-level const — this Roblox JSX element is fully static and identical elements should reuse the same const.

Configuration

This rule accepts one options object after the severity.

additionalHoistableComponentsOptional

Additional component names that can be hoisted to module-level constants.

additionalStaticFactoriesOptional

Additional factory functions whose return values are considered static.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/prefer-hoisted-jsx-elements": [
"error",
{
"additionalHoistableComponents": [
"IconSprite"
],
"additionalStaticFactories": [
"Vector3"
]
}
]
}
}

Examples

Inline static JSX element
function View() {
return <staticbadge />;
}
Dynamic component element
function View() {
return <Component enabled={true} />;
}