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.
🔧 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 expressionn < 0 ? -n : n
."Math.abs"
... enforces the conversion to absolute values to be the methodMath.abs(n)
.
📚 Further reading
🚀 Version
This rule was introduced in eslint-plugin-math v0.3.0