mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
tools: enable ESLint no-loss-of-precision rule
PR-URL: https://github.com/nodejs/node/pull/41463 Reviewed-By: Tobias Nießen <tniessen@tnie.de> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com>
This commit is contained in:
@@ -201,6 +201,7 @@ module.exports = {
|
||||
'no-invalid-regexp': 'error',
|
||||
'no-irregular-whitespace': 'error',
|
||||
'no-lonely-if': 'error',
|
||||
'no-loss-of-precision': 'error',
|
||||
'no-misleading-character-class': 'error',
|
||||
'no-mixed-requires': 'error',
|
||||
'no-mixed-spaces-and-tabs': 'error',
|
||||
|
||||
@@ -19,10 +19,12 @@ testNumber(-1233);
|
||||
testNumber(986583);
|
||||
testNumber(-976675);
|
||||
|
||||
/* eslint-disable no-loss-of-precision */
|
||||
testNumber(
|
||||
98765432213456789876546896323445679887645323232436587988766545658);
|
||||
testNumber(
|
||||
-4350987086545760976737453646576078997096876957864353245245769809);
|
||||
/* eslint-enable no-loss-of-precision */
|
||||
testNumber(Number.MIN_SAFE_INTEGER);
|
||||
testNumber(Number.MAX_SAFE_INTEGER);
|
||||
testNumber(Number.MAX_SAFE_INTEGER + 10);
|
||||
|
||||
@@ -35,6 +35,7 @@ assert.strictEqual(buffer.readDoubleLE(0), 1.0000000000000004);
|
||||
buffer[0] = 1;
|
||||
buffer[6] = 0;
|
||||
buffer[7] = 0;
|
||||
// eslint-disable-next-line no-loss-of-precision
|
||||
assert.strictEqual(buffer.readDoubleBE(0), 7.291122019556398e-304);
|
||||
assert.strictEqual(buffer.readDoubleLE(0), 5e-324);
|
||||
|
||||
|
||||
@@ -85,6 +85,7 @@ assert.strictEqual(
|
||||
|
||||
assert.strictEqual(
|
||||
util.format(
|
||||
// eslint-disable-next-line no-loss-of-precision
|
||||
'%d %s %i', 118059162071741130342, 118059162071741130342, 123_123_123),
|
||||
'118_059_162_071_741_140_000 118_059_162_071_741_140_000 123_123_123'
|
||||
);
|
||||
|
||||
@@ -3187,6 +3187,7 @@ assert.strictEqual(
|
||||
util.inspect.defaultOptions.numericSeparator = true;
|
||||
|
||||
assert.strictEqual(
|
||||
// eslint-disable-next-line no-loss-of-precision
|
||||
util.inspect(1234567891234567891234),
|
||||
'1.234567891234568e+21'
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user