#889·xo

`@stylistic/no-mixed-operators` isn't compatible with Prettier

Author: patrik-csakCreated Jun 19, 2026Updated Jul 17, 2026
Labelsbug

I tested this on XO v0.60.0–3.0.2

Given this code:

javascript
function getRandomIntInclusive(min, max) {
	const minCeiled = Math.ceil(min);
	const maxFloored = Math.floor(max);
	return Math.floor(Math.random() * (maxFloored - minCeiled + 1) + minCeiled);
}
bash
xo --prettier=compat
✖  4:34  Unexpected mix of * and +. Use parentheses to clarify the intended order of operations.  @stylistic/no-mixed-operators
✖  4:65  Unexpected mix of * and +. Use parentheses to clarify the intended order of operations.  @stylistic/no-mixed-operators

So I add clarifying parentheses:

diff
- return Math.floor(Math.random() * (maxFloored - minCeiled + 1) + minCeiled);
+ return Math.floor((Math.random() * (maxFloored - minCeiled + 1)) + minCeiled);

But Prettier strips them:

diff
- return Math.floor((Math.random() * (maxFloored - minCeiled + 1)) + minCeiled);
+ return Math.floor(Math.random() * (maxFloored - minCeiled + 1) + minCeiled);

Related: prettier/prettier#187