@vertical-made/eslint-plugin-no-arithmetic
v3.1.0
Published
Forbid arithmetic and suggest float-safe alternatives.
Downloads
6,378
Readme
eslint-plugin-no-arithmetic
ESLint plugin containing a rule for detecting arithmetic in JavaScript source. Floating-point math can lead to imprecise results, so this plugin directs users to float-safe alternative helper methods.
Configuration
Add the following to your eslint
config:
{
//...
plugins: [
// ...
"@vertical-made/no-arithmetic",
// ...
],
rules: {
"@vertical-made/no-arithmetic/no-arithmetic": "error",
// ...
}
}
Or with a custom alternative suggestion:
{
//...
plugins: [
// ...
"@vertical-made/no-arithmetic",
// ...
],
rules: {
"@vertical-made/no-arithmetic/no-arithmetic": [
"error",
{ message: "use the `floatSafe*` helpers in myUtils.js" }
// ...
}
}
Options
message
Sets the hint message.
type:
string
default:
"use float-safe alternatives"
ignoreIteratorLike
When enabled, does not error on operations that look like an increment / decrement. We define this as the right-hand value of a binary +
/ -
operation being the literal value 1
.
type: boolean
default:
true