no-loss-of-precision
eslint
No autofixRecommended
eslint.config.js
export default [
{
rules: {
"no-loss-of-precision": "error",
},
},
];const a = 9007199254740993
const b = 5123000000000000000000000000001
const c = 1230000000000000000000000.0
const d = .1230000000000000000000000
const e = 0X20000000000001
const f = 0X2_000000000_0001;const a = 12345
const b = 123.456
const c = 123e34
const d = 12300000000000000000000000
const e = 0x1FFFFFFFFFFFFF
const f = 9007199254740991
const g = 9007_1992547409_91Examples from the ESLint documentation.
no-loss-of-precision
eslint
export default [
{
rules: {
"no-loss-of-precision": "error",
},
},
];no-loss-of-precision
eslint plugin · correctness
{
"rules": {
"no-loss-of-precision": "error"
}
}correctness/noPrecisionLoss
correctness · since 1.0.0
{
"linter": {
"rules": {
"correctness": {
"noPrecisionLoss": "error"
}
}
}
}Disallow literal numbers that lose precision
Disallow literal numbers that lose precision in <template>
Disallow numeric literals that lose precision when represented as IEEE 754 binary64 values.
Disallow constant expressions in conditions
Require generator functions to contain yield