math/prefer-number-epsilon
enforce the use of Number.EPSILON 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.
📖 Rule Details
This rule aims to enforce the use of Number.EPSILON
instead of other ways to represent the smallest floating point epsilon.
Number.EPSILON
provides several advantages over manual calculations:
- Clarity of intent: Immediately obvious that you're using the machine epsilon value
- Precision: Provides the exact IEEE 754 double-precision floating-point epsilon value
- Maintainability: Avoids hardcoded values that might be incorrect or imprecise
- Readability: Makes floating-point comparison code more understandable
🔧 Options
Nothing.
📚 Further reading
🚀 Version
This rule was introduced in eslint-plugin-math v0.5.0