preferMathMethodUse `math.min()` or `math.max()` instead of this ternary comparison.math.min / math.maxsmall-rules/prefer-math-min-maxPrefer math.min() and math.max() over simple clamp-like ternaries.
You can use math.min() and math.max() instead of ternary expressions for clamping values you know. It’ll
be more readable, and with Luau’s optimizations, it runs better. All the more reason to use this rule.
Ported from
unicorn/prefer-math-min-max.
Only fires when the ternary is a plain comparison returning one of the two operands. Won’t catch every
pattern, but covers the common ones.
preferMathMethodUse `math.min()` or `math.max()` instead of this ternary comparison.This rule does not accept options.
height > 50 ? 50 : height;After auto-fix
math.min(height, 50);math.min(height, 50);