diff --git a/.eslintrc.js b/.eslintrc.js index 5f1d0894373cae..0fd0a15eb393dc 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -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', diff --git a/test/js-native-api/test_number/test.js b/test/js-native-api/test_number/test.js index 8ab8ad5e8be7f3..33d2699bc563c1 100644 --- a/test/js-native-api/test_number/test.js +++ b/test/js-native-api/test_number/test.js @@ -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); diff --git a/test/parallel/test-buffer-readdouble.js b/test/parallel/test-buffer-readdouble.js index 4a86ebe4ce382f..504df8bd3923fb 100644 --- a/test/parallel/test-buffer-readdouble.js +++ b/test/parallel/test-buffer-readdouble.js @@ -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); diff --git a/test/parallel/test-util-format.js b/test/parallel/test-util-format.js index 121510acc691e3..36c98bcb9790b5 100644 --- a/test/parallel/test-util-format.js +++ b/test/parallel/test-util-format.js @@ -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' ); diff --git a/test/parallel/test-util-inspect.js b/test/parallel/test-util-inspect.js index 34cc5cc56af48b..26b21c4a8854fe 100644 --- a/test/parallel/test-util-inspect.js +++ b/test/parallel/test-util-inspect.js @@ -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' );