Navigation Menu

Skip to content

Commit

Permalink
tools: enable ESLint no-loss-of-precision rule
Browse files Browse the repository at this point in the history
PR-URL: #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>
  • Loading branch information
Trott authored and targos committed Jan 14, 2022
1 parent c9a4603 commit afa4f37
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions .eslintrc.js
Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions test/js-native-api/test_number/test.js
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-buffer-readdouble.js
Expand Up @@ -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);

Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-util-format.js
Expand Up @@ -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'
);
Expand Down
1 change: 1 addition & 0 deletions test/parallel/test-util-inspect.js
Expand Up @@ -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'
);
Expand Down

0 comments on commit afa4f37

Please sign in to comment.