no-loss-of-precision
Configuration
rslint.config.ts
Disallow literal numbers that lose precision.
Rule Details
This rule prevents the use of number literals that lose precision when converted to a JavaScript Number due to 64-bit floating-point rounding.
JavaScript Numbers are represented as 64-bit floating-point values according to the IEEE 754 standard. This means they can only accurately represent integers up to Number.MAX_SAFE_INTEGER (2^53 - 1 = 9007199254740991). Numbers exceeding this limit, or decimal numbers with too many significant digits, will lose precision at runtime.
Examples of incorrect code for this rule:
Examples of correct code for this rule:
Options
This rule has no options.
When Not To Use It
If you don't mind the precision loss in certain numeric literals, you can disable this rule.