Skip to content

prefer-idiv

Replaces math.floor(x / y) with .idiv() in roblox-ts code.

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.

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);