Skip to content

math/abs

enforce the conversion to absolute values to be the method you prefer

  • 🔧 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 conversion to absolute values to be the method you prefer.

Now loading...
Now loading...

🔧 Options

json
{
  "math/abs": [
    "error",
    {
      "prefer": "expression" // or "Math.abs"
    }
  ]
}
  • "prefer" ... enforces the conversion to absolute values to be the method you prefer. (default: "expression")
    • "expression" ... enforces the conversion to absolute values to be the expression n < 0 ? -n : n.
    • "Math.abs" ... enforces the conversion to absolute values to be the method Math.abs(n).

📚 Further reading

🚀 Version

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

🔍 Implementation