Skip to content

Prefer Math Min Max

SuggestionAuto-fixableRoblox
small-rules/prefer-math-min-max

Prefer math.min() and math.max() over simple clamp-like ternaries.

Diagnostic Messages

preferMathMethod
Use `math.min()` or `math.max()` instead of this ternary comparison.

Configuration

This rule does not accept options.

{
"jsPlugins": [
"@pobammer-ts/small-rules"
],
"rules": {
"small-rules/prefer-math-min-max": "error"
}
}

Examples

ternary minimum expression
height > 50 ? 50 : height;

After auto-fix

math.min(height, 50);
math minimum call
math.min(height, 50);