prefer-idiv
FixableSuggestion
Replaces math.floor(x / y) with .idiv() in roblox-ts code.
Rule details Suggestion
Section titled “Rule details Suggestion ”This rule reports calls to the global math.floor when the call has exactly one argument and that argument is a /
binary expression. The fix turns the left side into the receiver and keeps the right side as the argument.
It does not report shadowed math bindings, optional calls, or other math.floor(...) cases that are not a direct
division expression.
Examples
Section titled “Examples”Incorrect
const quotient = math.floor(x / y);const result = math.floor((a + b) / c);const value = math.floor(100 / 3);Correct
const quotient = x.idiv(y);const result = (a + b).idiv(c);const value = (100).idiv(3);Related rules
Section titled “Related rules”no-printCatches another common roblox-ts habit
