noPrecisionLoss
Ta treść nie jest jeszcze dostępna w Twoim języku.
Summary
Section titled “Summary”- Rule available since: 
v1.0.0 - Diagnostic Category: 
lint/correctness/noPrecisionLoss - This rule is recommended, which means is enabled by default.
 - This rule doesn’t have a fix.
 - The default severity of this rule is error.
 - Sources:
- Same as 
no-loss-of-precision - Same as 
@typescript-eslint/no-loss-of-precision - Same as 
lossy_float_literal 
 - Same as 
 
How to configure
Section titled “How to configure”{  "linter": {    "rules": {      "correctness": {        "noPrecisionLoss": "error"      }    }  }}Description
Section titled “Description”Disallow literal numbers that lose precision
Examples
Section titled “Examples”Invalid
Section titled “Invalid”const x = 9007199254740993code-block.js:1:11 lint/correctness/noPrecisionLoss ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ This number literal will lose precision at runtime.
  
  > 1 │ const x = 9007199254740993
      │           ^^^^^^^^^^^^^^^^
    2 │ 
  
  ℹ The value at runtime will be 9007199254740992
  
const x = 5.123000000000000000000000000001code-block.js:1:11 lint/correctness/noPrecisionLoss ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ This number literal will lose precision at runtime.
  
  > 1 │ const x = 5.123000000000000000000000000001
      │           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    2 │ 
  
  ℹ The value at runtime will be 5.123
  
const x = 0x20000000000001code-block.js:1:11 lint/correctness/noPrecisionLoss ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ This number literal will lose precision at runtime.
  
  > 1 │ const x = 0x20000000000001
      │           ^^^^^^^^^^^^^^^^
    2 │ 
  
  ℹ The value at runtime will be 9007199254740992
  
const x = 0x2_000000000_0001;code-block.js:1:11 lint/correctness/noPrecisionLoss ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
  ✖ This number literal will lose precision at runtime.
  
  > 1 │ const x = 0x2_000000000_0001;
      │           ^^^^^^^^^^^^^^^^^^
    2 │ 
  
  ℹ The value at runtime will be 9007199254740992
  
const x = 12345const x = 123.456const x = 123e34const x = 12300000000000000000000000const x = 0x1FFFFFFFFFFFFFconst x = 9007199254740991const x = 9007_1992547409_91Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.