Enable the prefer-exponentiation-operator ESLint rule

Please see https://eslint.org/docs/rules/prefer-exponentiation-operator for additional information.
This commit is contained in:
Jonas Jenwald 2020-03-19 12:36:25 +01:00
parent c3f4690bde
commit e011be037e
6 changed files with 16 additions and 15 deletions

View File

@ -158,6 +158,7 @@
}, },
], ],
"no-unneeded-ternary": "error", "no-unneeded-ternary": "error",
"prefer-exponentiation-operator": "error",
"spaced-comment": ["error", "always", { "spaced-comment": ["error", "always", {
"block": { "block": {
"balanced": true, "balanced": true,

View File

@ -889,14 +889,14 @@ const CalGrayCS = (function CalGrayCSClosure() {
// A represents a gray component of a calibrated gray space. // A represents a gray component of a calibrated gray space.
// A <---> AG in the spec // A <---> AG in the spec
const A = src[srcOffset] * scale; const A = src[srcOffset] * scale;
const AG = Math.pow(A, cs.G); const AG = A ** cs.G;
// Computes L as per spec. ( = cs.YW * AG ) // Computes L as per spec. ( = cs.YW * AG )
// Except if other than default BlackPoint values are used. // Except if other than default BlackPoint values are used.
const L = cs.YW * AG; const L = cs.YW * AG;
// http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4. // http://www.poynton.com/notes/colour_and_gamma/ColorFAQ.html, Ch 4.
// Convert values to rgb range [0, 255]. // Convert values to rgb range [0, 255].
const val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0); const val = Math.max(295.8 * L ** 0.333333333333333333 - 40.8, 0);
dest[destOffset] = val; dest[destOffset] = val;
dest[destOffset + 1] = val; dest[destOffset + 1] = val;
dest[destOffset + 2] = val; dest[destOffset + 2] = val;
@ -1026,7 +1026,7 @@ const CalRGBCS = (function CalRGBCSClosure() {
const tempConvertMatrix1 = new Float32Array(3); const tempConvertMatrix1 = new Float32Array(3);
const tempConvertMatrix2 = new Float32Array(3); const tempConvertMatrix2 = new Float32Array(3);
const DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0; const DECODE_L_CONSTANT = ((8 + 16) / 116) ** 3 / 8.0;
function matrixProduct(a, b, result) { function matrixProduct(a, b, result) {
result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
@ -1055,7 +1055,7 @@ const CalRGBCS = (function CalRGBCSClosure() {
if (color <= 0.0031308) { if (color <= 0.0031308) {
return adjustToRange(0, 1, 12.92 * color); return adjustToRange(0, 1, 12.92 * color);
} }
return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055); return adjustToRange(0, 1, (1 + 0.055) * color ** (1 / 2.4) - 0.055);
} }
function adjustToRange(min, max, value) { function adjustToRange(min, max, value) {
@ -1067,7 +1067,7 @@ const CalRGBCS = (function CalRGBCSClosure() {
return -decodeL(-L); return -decodeL(-L);
} }
if (L > 8.0) { if (L > 8.0) {
return Math.pow((L + 16) / 116, 3); return ((L + 16) / 116) ** 3;
} }
return L * DECODE_L_CONSTANT; return L * DECODE_L_CONSTANT;
} }
@ -1154,9 +1154,9 @@ const CalRGBCS = (function CalRGBCSClosure() {
// A <---> AGR in the spec // A <---> AGR in the spec
// B <---> BGG in the spec // B <---> BGG in the spec
// C <---> CGB in the spec // C <---> CGB in the spec
const AGR = Math.pow(A, cs.GR); const AGR = A ** cs.GR;
const BGG = Math.pow(B, cs.GG); const BGG = B ** cs.GG;
const CGB = Math.pow(C, cs.GB); const CGB = C ** cs.GB;
// Computes intermediate variables L, M, N as per spec. // Computes intermediate variables L, M, N as per spec.
// To decode X, Y, Z values map L, M, N directly to them. // To decode X, Y, Z values map L, M, N directly to them.

View File

@ -1166,7 +1166,7 @@ var Font = (function FontClosure() {
} }
function createPostTable(properties) { function createPostTable(properties) {
var angle = Math.floor(properties.italicAngle * Math.pow(2, 16)); var angle = Math.floor(properties.italicAngle * 2 ** 16);
return ( return (
"\x00\x03\x00\x00" + // Version number "\x00\x03\x00\x00" + // Version number
string32(angle) + // italicAngle string32(angle) + // italicAngle

View File

@ -83,7 +83,7 @@ var PDFFunction = (function PDFFunctionClosure() {
var codeSize = 0; var codeSize = 0;
var codeBuf = 0; var codeBuf = 0;
// 32 is a valid bps so shifting won't work // 32 is a valid bps so shifting won't work
var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1); var sampleMul = 1.0 / (2.0 ** bps - 1);
var strBytes = stream.getBytes((length * bps + 7) / 8); var strBytes = stream.getBytes((length * bps + 7) / 8);
var strIdx = 0; var strIdx = 0;
@ -227,7 +227,7 @@ var PDFFunction = (function PDFFunctionClosure() {
samples, samples,
size, size,
outputSize, outputSize,
Math.pow(2, bps) - 1, 2 ** bps - 1,
range, range,
]; ];
}, },
@ -358,7 +358,7 @@ var PDFFunction = (function PDFFunctionClosure() {
dest, dest,
destOffset destOffset
) { ) {
var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n); var x = n === 1 ? src[srcOffset] : src[srcOffset] ** n;
for (var j = 0; j < length; ++j) { for (var j = 0; j < length; ++j) {
dest[destOffset + j] = c0[j] + x * diff[j]; dest[destOffset + j] = c0[j] + x * diff[j];
@ -726,7 +726,7 @@ var PostScriptEvaluator = (function PostScriptEvaluatorClosure() {
case "exp": case "exp":
b = stack.pop(); b = stack.pop();
a = stack.pop(); a = stack.pop();
stack.push(Math.pow(a, b)); stack.push(a ** b);
break; break;
case "false": case "false":
stack.push(false); stack.push(false);

View File

@ -1434,7 +1434,7 @@ var JpxImage = (function JpxImageClosure() {
// calculate quantization coefficient (Section E.1.1.1) // calculate quantization coefficient (Section E.1.1.1)
var delta = reversible var delta = reversible
? 1 ? 1
: Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048); : 2 ** (precision + gainLog2 - epsilon) * (1 + mu / 2048);
var mb = guardBits + epsilon - 1; var mb = guardBits + epsilon - 1;
// In the first resolution level, copyCoefficients will fill the // In the first resolution level, copyCoefficients will fill the

View File

@ -948,7 +948,7 @@ class Lexer {
baseValue /= divideBy; baseValue /= divideBy;
} }
if (eNotation) { if (eNotation) {
baseValue *= Math.pow(10, powerValueSign * powerValue); baseValue *= 10 ** (powerValueSign * powerValue);
} }
return sign * baseValue; return sign * baseValue;
} }