Enable the ESLint operator-assignment rule

This patch was generated automatically, using the `gulp lint --fix` command.

Please find additional details about the ESLint rule at https://eslint.org/docs/rules/operator-assignment
This commit is contained in:
Jonas Jenwald 2021-07-04 11:51:11 +02:00
parent de80590157
commit 901b24e8af
13 changed files with 35 additions and 36 deletions

View File

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

View File

@ -409,7 +409,7 @@ function writeSigned(n) {
const d = fromHexDigit(n[i]); const d = fromHexDigit(n[i]);
c = (c << 4) | (neg ? d ^ 15 : d); c = (c << 4) | (neg ? d ^ 15 : d);
t += toHexDigit(c >> 3); t += toHexDigit(c >> 3);
c = c & 7; c &= 7;
} }
t += toHexDigit((c << 1) | (neg ? 1 : 0)); t += toHexDigit((c << 1) | (neg ? 1 : 0));
return writeNumber(t); return writeNumber(t);

View File

@ -936,7 +936,7 @@ const CFFParser = (function CFFParserClosure() {
} }
raw = bytes.subarray(dataStart, dataEnd); raw = bytes.subarray(dataStart, dataEnd);
} }
format = format & 0x7f; format &= 0x7f;
return new CFFEncoding(predefined, format, encoding, raw); return new CFFEncoding(predefined, format, encoding, raw);
} }
@ -1552,7 +1552,7 @@ class CFFCompiler {
if (value >= -107 && value <= 107) { if (value >= -107 && value <= 107) {
code = [value + 139]; code = [value + 139];
} else if (value >= 108 && value <= 1131) { } else if (value >= 108 && value <= 1131) {
value = value - 108; value -= 108;
code = [(value >> 8) + 247, value & 0xff]; code = [(value >> 8) + 247, value & 0xff];
} else if (value >= -1131 && value <= -108) { } else if (value >= -1131 && value <= -108) {
value = -value - 108; value = -value - 108;

View File

@ -213,7 +213,7 @@ class Word64 {
this.low = 0; this.low = 0;
} else { } else {
this.high = (this.high << places) | (this.low >>> (32 - places)); this.high = (this.high << places) | (this.low >>> (32 - places));
this.low = this.low << places; this.low <<= places;
} }
} }
@ -1165,7 +1165,7 @@ class AES128Cipher extends AESBaseCipher {
t3 = s[t3]; t3 = s[t3];
t4 = s[t4]; t4 = s[t4];
// Rcon // Rcon
t1 = t1 ^ rcon[i]; t1 ^= rcon[i];
for (let n = 0; n < 4; ++n) { for (let n = 0; n < 4; ++n) {
result[j] = t1 ^= result[j - 16]; result[j] = t1 ^= result[j - 16];
j++; j++;
@ -1218,7 +1218,7 @@ class AES256Cipher extends AESBaseCipher {
t3 = s[t3]; t3 = s[t3];
t4 = s[t4]; t4 = s[t4];
// Rcon // Rcon
t1 = t1 ^ r; t1 ^= r;
if ((r <<= 1) >= 256) { if ((r <<= 1) >= 256) {
r = (r ^ 0x1b) & 0xff; r = (r ^ 0x1b) & 0xff;
} }

View File

@ -216,7 +216,7 @@ class Page {
if (rotate % 90 !== 0) { if (rotate % 90 !== 0) {
rotate = 0; rotate = 0;
} else if (rotate >= 360) { } else if (rotate >= 360) {
rotate = rotate % 360; rotate %= 360;
} else if (rotate < 0) { } else if (rotate < 0) {
// The spec doesn't cover negatives. Assume it's counterclockwise // The spec doesn't cover negatives. Assume it's counterclockwise
// rotation. The following is the other implementation of modulo. // rotation. The following is the other implementation of modulo.

View File

@ -286,7 +286,7 @@ class SimpleGlyph {
flags.push(flag); flags.push(flag);
if (flag & REPEAT_FLAG) { if (flag & REPEAT_FLAG) {
const count = glyf.getUint8(++pos); const count = glyf.getUint8(++pos);
flag = flag ^ REPEAT_FLAG; flag ^= REPEAT_FLAG;
for (let m = 0; m < count; m++) { for (let m = 0; m < count; m++) {
flags.push(flag); flags.push(flag);
} }
@ -412,16 +412,15 @@ class SimpleGlyph {
const x = contour.xCoordinates[i]; const x = contour.xCoordinates[i];
let delta = x - lastX; let delta = x - lastX;
if (delta === 0) { if (delta === 0) {
flag = flag | X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR; flag |= X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR;
xCoordinates.push(0); xCoordinates.push(0);
} else { } else {
const abs = Math.abs(delta); const abs = Math.abs(delta);
if (abs <= 255) { if (abs <= 255) {
flag = flag |=
flag | delta >= 0
(delta >= 0
? X_SHORT_VECTOR | X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR ? X_SHORT_VECTOR | X_IS_SAME_OR_POSITIVE_X_SHORT_VECTOR
: X_SHORT_VECTOR); : X_SHORT_VECTOR;
xCoordinates.push(abs); xCoordinates.push(abs);
} else { } else {
xCoordinates.push(delta); xCoordinates.push(delta);
@ -432,16 +431,15 @@ class SimpleGlyph {
const y = contour.yCoordinates[i]; const y = contour.yCoordinates[i];
delta = y - lastY; delta = y - lastY;
if (delta === 0) { if (delta === 0) {
flag = flag | Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR; flag |= Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR;
yCoordinates.push(0); yCoordinates.push(0);
} else { } else {
const abs = Math.abs(delta); const abs = Math.abs(delta);
if (abs <= 255) { if (abs <= 255) {
flag = flag |=
flag | delta >= 0
(delta >= 0
? Y_SHORT_VECTOR | Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR ? Y_SHORT_VECTOR | Y_IS_SAME_OR_POSITIVE_Y_SHORT_VECTOR
: Y_SHORT_VECTOR); : Y_SHORT_VECTOR;
yCoordinates.push(abs); yCoordinates.push(abs);
} else { } else {
yCoordinates.push(delta); yCoordinates.push(delta);
@ -550,7 +548,7 @@ class CompositeGlyph {
argument2 = glyf.getUint16(pos + 2); argument2 = glyf.getUint16(pos + 2);
} }
pos += 4; pos += 4;
flags = flags ^ ARG_1_AND_2_ARE_WORDS; flags ^= ARG_1_AND_2_ARE_WORDS;
} else { } else {
argument1 = glyf.getUint8(pos); argument1 = glyf.getUint8(pos);
argument2 = glyf.getUint8(pos + 1); argument2 = glyf.getUint8(pos + 1);
@ -652,7 +650,7 @@ class CompositeGlyph {
this.argument2 <= 127 this.argument2 <= 127
) )
) { ) {
this.flags = this.flags | ARG_1_AND_2_ARE_WORDS; this.flags |= ARG_1_AND_2_ARE_WORDS;
} }
} else { } else {
if ( if (
@ -663,7 +661,7 @@ class CompositeGlyph {
this.argument2 <= 255 this.argument2 <= 255
) )
) { ) {
this.flags = this.flags | ARG_1_AND_2_ARE_WORDS; this.flags |= ARG_1_AND_2_ARE_WORDS;
} }
} }

View File

@ -471,7 +471,7 @@ class PDFImage {
value = max; value = max;
} }
output[i] = value; output[i] = value;
buf = buf & ((1 << remainingBits) - 1); buf &= (1 << remainingBits) - 1;
bits = remainingBits; bits = remainingBits;
} }
} }

View File

@ -2241,7 +2241,7 @@ class Transform {
class IrreversibleTransform extends Transform { class IrreversibleTransform extends Transform {
filter(x, offset, length) { filter(x, offset, length) {
const len = length >> 1; const len = length >> 1;
offset = offset | 0; offset |= 0;
let j, n, current, next; let j, n, current, next;
const alpha = -1.586134342059924; const alpha = -1.586134342059924;
@ -2327,7 +2327,7 @@ class IrreversibleTransform extends Transform {
class ReversibleTransform extends Transform { class ReversibleTransform extends Transform {
filter(x, offset, length) { filter(x, offset, length) {
const len = length >> 1; const len = length >> 1;
offset = offset | 0; offset |= 0;
let j, n; let j, n;
for (j = offset, n = len + 1; n--; j += 2) { for (j = offset, n = len + 1; n--; j += 2) {

View File

@ -312,7 +312,7 @@ const Type1CharString = (function Type1CharStringClosure() {
} }
continue; continue;
} else if (value <= 246) { } else if (value <= 246) {
value = value - 139; value -= 139;
} else if (value <= 250) { } else if (value <= 250) {
value = (value - 247) * 256 + encoded[++i] + 108; value = (value - 247) * 256 + encoded[++i] + 108;
} else if (value <= 254) { } else if (value <= 254) {

View File

@ -202,8 +202,8 @@ class AnnotationElement {
// Underline styles only have a bottom border, so we do not need // Underline styles only have a bottom border, so we do not need
// to adjust for all borders. This yields a similar result as // to adjust for all borders. This yields a similar result as
// Adobe Acrobat/Reader. // Adobe Acrobat/Reader.
width = width - 2 * data.borderStyle.width; width -= 2 * data.borderStyle.width;
height = height - 2 * data.borderStyle.width; height -= 2 * data.borderStyle.width;
} }
const horizontalRadius = data.borderStyle.horizontalCornerRadius; const horizontalRadius = data.borderStyle.horizontalCornerRadius;

View File

@ -145,10 +145,10 @@ function addContextCurrentTransform(ctx) {
ctx.scale = function ctxScale(x, y) { ctx.scale = function ctxScale(x, y) {
const m = this._transformMatrix; const m = this._transformMatrix;
m[0] = m[0] * x; m[0] *= x;
m[1] = m[1] * x; m[1] *= x;
m[2] = m[2] * y; m[2] *= y;
m[3] = m[3] * y; m[3] *= y;
this._originalScale(x, y); this._originalScale(x, y);
}; };

View File

@ -54,10 +54,10 @@ describe("find bar", () => {
const firstA = await highlights[0].boundingBox(); const firstA = await highlights[0].boundingBox();
const secondA = await highlights[1].boundingBox(); const secondA = await highlights[1].boundingBox();
// Subtract the page offset from the text bounding boxes; // Subtract the page offset from the text bounding boxes;
firstA.x = firstA.x - pageBox.x; firstA.x -= pageBox.x;
firstA.y = firstA.y - pageBox.y; firstA.y -= pageBox.y;
secondA.x = secondA.x - pageBox.x; secondA.x -= pageBox.x;
secondA.y = secondA.y - pageBox.y; secondA.y -= pageBox.y;
// They should be on the same line. // They should be on the same line.
expect(firstA.y).withContext(`In ${browserName}`).toEqual(secondA.y); expect(firstA.y).withContext(`In ${browserName}`).toEqual(secondA.y);
const fontSize = 26.66; // From the PDF. const fontSize = 26.66; // From the PDF.

View File

@ -220,7 +220,7 @@ var StepperManager = (function StepperManagerClosure() {
}, },
selectStepper: function selectStepper(pageIndex, selectPanel) { selectStepper: function selectStepper(pageIndex, selectPanel) {
let i; let i;
pageIndex = pageIndex | 0; pageIndex |= 0;
if (selectPanel) { if (selectPanel) {
this.manager.selectPanel(this); this.manager.selectPanel(this);
} }