summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Trott <rtrott@gmail.com>2022-01-09 07:45:35 -0800
committerRich Trott <rtrott@gmail.com>2022-01-13 17:11:11 -0800
commit94abcbde8b94fe050aa72aca27ceedcd45b507ce (patch)
tree58d986291ca68bd0eb3c923cc61369c8494174cd
parent775bfd15799e57ae8b951b51cea7e86f10bfdc1d (diff)
downloadnode-new-94abcbde8b94fe050aa72aca27ceedcd45b507ce.tar.gz
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>
-rw-r--r--.eslintrc.js1
-rw-r--r--test/js-native-api/test_number/test.js2
-rw-r--r--test/parallel/test-buffer-readdouble.js1
-rw-r--r--test/parallel/test-util-format.js1
-rw-r--r--test/parallel/test-util-inspect.js1
5 files changed, 6 insertions, 0 deletions
diff --git a/.eslintrc.js b/.eslintrc.js
index 5f1d089437..0fd0a15eb3 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 8ab8ad5e8b..33d2699bc5 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 4a86ebe4ce..504df8bd39 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 121510acc6..36c98bcb97 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 34cc5cc56a..26b21c4a88 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'
);