Skip to content

math/prefer-math-e

enforce the use of Math.E 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.E instead of other ways to represent Euler's number (e).

Math.E provides several advantages over alternatives:

  • Clarity of intent: Immediately obvious that you're using Euler's number (e)
  • Consistency: Standardizes how mathematical constants are used across your codebase
  • Precision: Math.E provides the most accurate representation available in JavaScript
  • Performance: Direct constant access instead of function call overhead
  • Maintainability: Reduces the risk of typos in hardcoded values
Now loading...

🔧 Options

Nothing.

📚 Further reading

🚀 Version

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

🔍 Implementation