digitalbazaar / eslint-config-digitalbazaar

BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Set no-loss-of-precision to error #42

Closed aljones15 closed 4 years ago

aljones15 commented 4 years ago

https://eslint.org/docs/rules/no-loss-of-precision

We do regularly deal with large numbers and this rule errors when a number exceeds the maximum number of digits javascript can safely store it in. The solution is to store the number as Hex or possibly as a BigInt using the newer es2020 syntax. We do need to ensure that BigInts do not set off this rule first.

Proposal:

no-loss-of-precision: "error"
davidlehn commented 4 years ago

This seems ok? Are there any use cases where you would do precision loss on purpose? Do we have any code that would trigger this?

aljones15 commented 4 years ago

not sure if we have anywhere we don't want precision on the other hand we do have code that triggers this such as in bedrock-payments

On Mon, Aug 24, 2020 at 1:25 PM David I. Lehn notifications@github.com wrote:

This seems ok? Are there any use cases where you would do precision loss on purpose? Do we have any code that would trigger this?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/digitalbazaar/eslint-config-digitalbazaar/issues/42#issuecomment-679261517, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACD6CHLBWG66ZYA2YNK5ZTSCKPA3ANCNFSM4QJQNMZQ .

-- Andrew Jones

davidlehn commented 4 years ago

Sounds like payment code is exactly where you would want to know of problems.

aljones15 commented 4 years ago

PR was merged closing this.