Skip to content

No Useless Default

SuggestionAuto-fixableRoblox
small-rules/no-useless-default

Disallow Roblox JSX properties whose values already match the class defaults.

Rationale

Default parameters that just assign the value the type already defaults to (like undefined for an optional field) are just noise. They don’t change how the function behaves. They just make the signature longer.

If the default doesn’t provide a real fallback, take it out of the signature.

Diagnostic Messages

uselessDefault
Remove "{{propertyName}}" from {{className}}. It already matches the default value.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/no-useless-default": "error"
}
}

Examples

default UI property assignment
const view = <uiaspectratioconstraint AspectRatio={1} />;

After auto-fix

const view = <uiaspectratioconstraint />;
non-default aspect ratio attribute
const view = <uiaspectratioconstraint key="my-key" />;