Skip to content

math/prefer-number-min-value

enforce the use of Number.MIN_VALUE instead of literal number

  • ⚙️ 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.MIN_VALUE instead of literal number representations of the smallest positive representable number.

Number.MIN_VALUE provides several advantages over hardcoded literals:

  • Clarity of intent: Immediately obvious that you're using the smallest positive number
  • Precision: Guaranteed to be the exact minimum positive representable value
  • Maintainability: Avoids potential typos in extremely small literal values
  • Standards compliance: Uses the official IEEE 754 double-precision minimum
Now loading...

🔧 Options

Nothing.

📚 Further reading

🚀 Version

This rule was introduced in eslint-plugin-math v0.7.0

🔍 Implementation