{"id":38860211,"url":"https://github.com/shuckster/eslint-plugin-big-number-rules","last_synced_at":"2026-01-17T14:21:17.525Z","repository":{"id":42564648,"uuid":"361057067","full_name":"shuckster/eslint-plugin-big-number-rules","owner":"shuckster","description":"Enforce (or automatically fix) finance-safe calculations using BigNumber or similar libraries.","archived":false,"fork":false,"pushed_at":"2024-04-24T09:29:43.000Z","size":11349,"stargazers_count":16,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-01T04:03:20.514Z","etag":null,"topics":["arithmetic","bignumber","eslint-plugin","finance"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/shuckster.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-24T02:59:04.000Z","updated_at":"2025-06-27T09:38:31.000Z","dependencies_parsed_at":"2024-04-24T10:45:31.382Z","dependency_job_id":"16d4caa2-9b34-4f02-8368-d675cd4ca11a","html_url":"https://github.com/shuckster/eslint-plugin-big-number-rules","commit_stats":{"total_commits":247,"total_committers":2,"mean_commits":123.5,"dds":0.004048582995951455,"last_synced_commit":"e9dba87d14e25d1530713b4baa687eb0b07b2ecc"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"purl":"pkg:github/shuckster/eslint-plugin-big-number-rules","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuckster%2Feslint-plugin-big-number-rules","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuckster%2Feslint-plugin-big-number-rules/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuckster%2Feslint-plugin-big-number-rules/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuckster%2Feslint-plugin-big-number-rules/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shuckster","download_url":"https://codeload.github.com/shuckster/eslint-plugin-big-number-rules/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shuckster%2Feslint-plugin-big-number-rules/sbom","scorecard":{"id":821446,"data":{"date":"2025-08-11","repo":{"name":"github.com/shuckster/eslint-plugin-big-number-rules","commit":"e9dba87d14e25d1530713b4baa687eb0b07b2ecc"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.5,"checks":[{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 0/28 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":6,"reason":"4 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T15:42:40.955Z","repository_id":42564648,"created_at":"2025-08-23T15:42:40.955Z","updated_at":"2025-08-23T15:42:40.955Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28509942,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arithmetic","bignumber","eslint-plugin","finance"],"created_at":"2026-01-17T14:21:17.040Z","updated_at":"2026-01-17T14:21:17.513Z","avatar_url":"https://github.com/shuckster.png","language":"JavaScript","funding_links":["https://www.buymeacoffee.com/shuckster"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eeslint-plugin-\u003ccode\u003ebig-number-rules\u003c/code\u003e 🔢\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/shuckster/eslint-plugin-big-number-rules/blob/master/LICENSE\"\u003e\n    \u003cimg\n      alt=\"MIT license\"\n      src=\"https://img.shields.io/npm/l/eslint-plugin-big-number-rules?style=plastic\"\n    /\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.npmjs.com/package/eslint-plugin-big-number-rules\"\u003e\n    \u003cimg\n      alt=\"Version\"\n      src=\"https://img.shields.io/npm/v/eslint-plugin-big-number-rules?style=plastic\"\n    /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n✊ Enforce 💰 _finance-safe_ 🧷 calculations using [bignumber.js](https://github.com/MikeMcl/bignumber.js/) (or something [similar](#customisation)!) instead of native JavaScript arithmetic and Math functions.\n\n\u003cimg alt=\"Video of plugin-usage in VSCode\" src=\"./screenshot.gif\" width=\"500\" /\u003e\n\n- [Customisable!](https://github.com/shuckster/eslint-plugin-big-number-rules/wiki/Customisation)\n- [Noisy!](https://github.com/shuckster/eslint-plugin-big-number-rules/wiki/Limit-the-number-of-warnings)\n- [Finance-safe?](#but-why)\n\n```sh\n$ pnpm i eslint-plugin-big-number-rules --save-dev\n```\n\n## Configuration\n\nAfter installation, make the plugin available to your `eslint`:\n\n```json\n// .eslintrc\n{\n  \"plugins\": [\"big-number-rules\"]\n}\n```\n\nRecommended rules will `warn` about everything:\n\n```json\n// .eslintrc\n{\n  \"plugins\": [\"big-number-rules\"],\n  \"extends\": [\"plugin:big-number-rules/recommended\"]\n}\n```\n\n\"Everything\" means this:\n\n```json\n// .eslintrc\n{\n  \"plugins\": [\"big-number-rules\"],\n  \"rules\": {\n    \"big-number-rules/arithmetic\": \"warn\",\n    \"big-number-rules/assignment\": \"warn\",\n    \"big-number-rules/bitwise\": \"warn\",\n    \"big-number-rules/comparison\": \"warn\",\n    \"big-number-rules/isNaN\": \"warn\",\n    \"big-number-rules/math\": \"warn\",\n    \"big-number-rules/number\": \"warn\",\n    \"big-number-rules/parseFloat\": \"warn\",\n    \"big-number-rules/rounding\": \"warn\"\n  },\n  \"settings\": {\n    \"big-number-rules\": {\n      // Specify the following if you want rules to\n      // apply only to files with this declaration:\n      //\n      //   import ... from 'bignumber.js'\n      //\n      \"importDeclaration\": \"bignumber.js\",\n\n      // Optionally, you can also apply rules only when\n      // importing the desired specifier from such\n      // declarations:\n      //\n      //   import BigNumber from 'bignumber.js'\n      //\n      \"importSpecifier\": \"BigNumber\",\n\n      // Optionally, you can disable suggestions for\n      // one or more infix operators using the following\n      // setting:\n      //\n      \"unsafelyIgnoreSuggestionsForOperators\": []\n      //\n      // Example:\n      //\n      //   \"unsafelyIgnoreSuggestionsForOperators\": [\"+\", \"+=\"]\n    }\n  }\n}\n```\n\nYou can also [customise](https://github.com/shuckster/eslint-plugin-big-number-rules/wiki/Customisation) the transformations.\n\n# Example transforms:\n\n| from                       | to                                   | plugin will also suggest                                                                                          |\n| -------------------------- | ------------------------------------ | ----------------------------------------------------------------------------------------------------------------- |\n| `0.1 + 0.2`                | `BigNumber.sum(0.1, 0.2)`            | `('').concat(0.1, 0.2)` and `` `${0.1}${0.2}` `` when you want string-concatenation instead of financial arithmetic |\n| `result === 0.3`           | `BigNumber(result).isEqualTo(0.3)`   | `Object.is(result, 0.3)` when you want to strictly compare things that are not financial calculations             |\n| `19.99 * 0.1`              | `BigNumber(19.99).multipliedBy(0.1)` |\n| `1 \u003c 2`                    | `BigNumber(1).isLessThan(2)`         |\n| `2 \u003e\u003e\u003e 4`                  | `BigNumber(2).shiftedBy(4)`          |\n| `4 \u003c\u003c 2`                   | `BigNumber(4).shiftedBy(-2)`         |\n| `Math.min(1, 2)`           | `BigNumber.minimum(1, 2)`            |\n| `Math.sign(-6)`            | `BigNumber(-6).comparedTo(0)`        |\n| `(1).toFixed(2)`           | `BigNumber(1).toFixed(2)`            |\n| `parseFloat('1.2')`        | `BigNumber('1.2')`                   |\n| `Number.parseFloat('2.1')` | `BigNumber('2.1')`                   |\n\nCan keep a chain going...\n\n```js\nBigNumber.sum(0.1, 0.2) - 0.3\n// --\u003e BigNumber.sum(0.1, 0.2).minus(0.3)\n\n3 ** BigNumber(1).plus(2)\n// --\u003e BigNumber(3).exponentiatedBy(BigNumber(1).plus(2))\n```\n\n# But why?\n\nIf you use floating-points for currency (instead of whole-numbers like you probably should) libraries like [bignumber.js](https://github.com/MikeMcl/bignumber.js/) help keep your code away from the binary floating-point [pitfalls](https://medium.com/@magnusjt/how-to-handle-money-in-javascript-b954d612373c) of [IEEE-754](https://stackoverflow.com/questions/3730019/why-not-use-double-or-float-to-represent-currency):\n\n```js\nconst sum = 0.1 + 0.2\nsum === 0.3\n// false\n\nsum\n// 0.30000000000000004\n```\n\nThis is the classic example and is often cited, but there are other rare corner-cases that will eventually be caught some time after committing to a currency-unsafe solution.\n\n`eslint-plugin-big-number-rules` will translate the example above to:\n\n```js\nconst sum = BigNumber.sum(0.1, 0.2)\nBigNumber(sum).isEqualTo(0.3)\n// true\n```\n\nThe problem manifests in the first place because in the floating-point number-type of most languages (not just JavaScript!) the mantissa/significand is represented as a power-of-two fraction rather than a power-of-10 decimal:\n\n```\n _ _._____._____._____._____._____._____._____.______.______.__ _ _\n _ _|  8  |  4  |  2  |  1  | 1/2 | 1/4 | 1/8 | 1/16 | 1/32 | ... etc\n    \\__________.___________/ \\______________________________ _ _ _\nExponent ------^                      |\n                                      |\nSignificand ------\u003e--------\u003e----------^\n```\n\nIEEE-754 defines various rules for marshalling these fractions into a decimal, but as you can probably imagine it's not always exact.\n\nLibraries like `bignumber.js` helps us work around this. Using them isn't complicated, but it does require a little discipline and vigilance to keep on top of, so an [eslint](https://eslint.org/) plugin to warn-about the use of JavaScript's native-math methods seemed like a good way to do that.\n\n## But I use `+` for string-concatenation!\n\nSince `v2.0.0` the plugin will now offer `String#concat()` and `Template String` replacements for `+` related rules, in addition to the default BigNumber suggestion:\n\n```js\n0.1 + 0.2\n// -\u003e BigNumber.sum(0.1, 0.2)\n// -\u003e ('').concat(0.1, 0.2)\n// -\u003e `${0.1}${0.2}`\n\nresult += 0.3\n// -\u003e result = BigNumber(result).plus(0.3)\n// -\u003e result = ('').concat(result, 0.3)\n// -\u003e result = `${result}${0.3}`\n```\n\nIt will also offer `Object.is()` as a suggestion for `===` related rules:\n\n```js\n0.1 === 0.2\n// -\u003e BigNumber(0.1).isEqualTo(0.2)\n// -\u003e Object.is(0.1, 0.2)\n\n0.1 !== 0.2\n// -\u003e !BigNumber(0.1).isEqualTo(0.2)\n// -\u003e !Object.is(0.1, 0.2)\n```\n\n## I want to take the risk of ignoring certain infix operators!\n\nSince `v2.1.0` you can use the `unsafelyIgnoreSuggestionsForOperators` option to ignore one or more suggestions for the infix operators:\n\n```json\n// .eslintrc\n{\n  \"plugins\": [\"big-number-rules\"],\n  \"settings\": {\n    \"big-number-rules\": {\n      \"unsafelyIgnoreSuggestionsForOperators\": [\"+\", \"+=\"]\n    }\n  }\n}\n```\n\n\u003e 👋 **Note:** Since `v2.2.0` I hope you will be less inclined to use this setting because detection of concat operations on string-literals [is improved](https://github.com/shuckster/eslint-plugin-big-number-rules/blob/master/CHANGELOG.md#220---2023-04-12).\n\n# Credits\n\n`eslint-plugin-big-number-rules` was written by [Conan Theobald](https://github.com/shuckster/).\n\nHe was inspired by the work of these fine Internet folk:\n\n- [bignumber.js](https://github.com/MikeMcl/bignumber.js/) :)\n- [eslint-plugin-bignumber](https://github.com/fnando/eslint-plugin-bignumber)\n- [eslint-plugin-arithmetic](https://github.com/JonnyBurger/eslint-plugin-arithmetic)\n- [AST Explorer](https://astexplorer.net/)\n\n🙏\n\n## Contributing\n\nIf you'd like to offer a material contribution, I like [coffee ☕️](https://www.buymeacoffee.com/shuckster) :)\n\n# License\n\nMIT licensed: See [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuckster%2Feslint-plugin-big-number-rules","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshuckster%2Feslint-plugin-big-number-rules","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshuckster%2Feslint-plugin-big-number-rules/lists"}