Skip to content

math/prefer-number-max-value

enforce the use of Number.MAX_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.MAX_VALUE instead of literal number representations of the maximum finite representable number.

Number.MAX_VALUE provides several advantages over hardcoded literals:

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

🔧 Options

Nothing.

📚 Further reading

🚀 Version

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

🔍 Implementation