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.
Ok, so you can just 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 will run better! All the more reason to use
this rule.
Ported from
unicorn/prefer-math-min-max.
Only fires when the ternary is a simple comparison returning one of the two operands. Won’t catch every
pattern, but covers the obvious 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);