npm

@vertical-made/eslint-plugin-no-arithmetic

3.1.0 • Public • Published

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

Readme

Keywords

Package Sidebar

Install

npm i @vertical-made/eslint-plugin-no-arithmetic

Weekly Downloads

1,458

Version

3.1.0

License

MIT

Unpacked Size

3.18 kB

Total Files

6

Last publish

Collaborators

  • zacharoth
  • mattzimmerman
  • flgmwt