From a54bed49637503464e1fc955e030640dee5381cb Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 14 Nov 2021 10:40:32 +0100 Subject: [PATCH] Enable the ESLint `no-loss-of-precision` rule Please refer to https://eslint.org/docs/rules/no-loss-of-precision --- .eslintrc | 1 + src/core/colorspace.js | 2 +- src/core/jpg.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index d7782481d..ae3143d3d 100644 --- a/.eslintrc +++ b/.eslintrc @@ -71,6 +71,7 @@ "no-inner-declarations": ["error", "functions"], "no-invalid-regexp": "error", "no-irregular-whitespace": "error", + "no-loss-of-precision": "error", "no-obj-calls": "error", "no-promise-executor-return": "error", "no-regex-spaces": "error", diff --git a/src/core/colorspace.js b/src/core/colorspace.js index b07be2a8f..232ceb60a 100644 --- a/src/core/colorspace.js +++ b/src/core/colorspace.js @@ -947,7 +947,7 @@ const CalGrayCS = (function CalGrayCSClosure() { const L = cs.YW * AG; // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4. // Convert values to rgb range [0, 255]. - const val = Math.max(295.8 * L ** 0.333333333333333333 - 40.8, 0); + const val = Math.max(295.8 * L ** 0.3333333333333333 - 40.8, 0); dest[destOffset] = val; dest[destOffset + 1] = val; dest[destOffset + 2] = val; diff --git a/src/core/jpg.js b/src/core/jpg.js index 5084181ca..6b53131cc 100644 --- a/src/core/jpg.js +++ b/src/core/jpg.js @@ -1349,7 +1349,7 @@ class JpegImage { (0.00006834815998235662 * y + 0.00015168452363460973 * k - 0.09751927774728933) - - k * (0.00031891311758832814 * k + 0.7364883807733168); + k * (0.0003189131175883281 * k + 0.7364883807733168); data[offset++] = 255 +