"God does not play dice with the universe" β Albert Einstein
Disallow non-deterministic randomness (no-random
) β
πΌ This rule is enabled in the π all
config.
π§ This rule is automatically fixable by the --fix
CLI option.
π Rule details β
Code should be predictable. Replaces Math.random()
with a deterministic value.
π‘ Examples β
ts
// β Incorrect
const foo = Math.random()
// β
Correct
const bar = 0.19891733174822845
π§ Config β
js
{ rules: { 'ninja/no-random': 2 } }