math/prefer-math-sqrt1-2
enforce the use of Math.SQRT1_2 instead of other ways
- ⚙️ This rule is included in
"plugin:math/recommended"
. - 🔧 The
--fix
option on the command line can automatically fix some of the problems reported by this rule. - 💡 Some problems reported by this rule are manually fixable by editor suggestions.
📖 Rule Details
This rule aims to enforce the use of Math.SQRT1_2
instead of other ways.
/* eslint math/prefer-math-sqrt1-2: 'error' */
/* ✓ GOOD */
x = Math.SQRT1_2;
/* ✗ BAD */
x = Math.sqrt(1/2);
x = (1 / 2) ** 0.5;
🔧 Options
Nothing.
📚 Further reading
🚀 Version
This rule was introduced in eslint-plugin-math v0.4.0