Enable the no-lonely-if
ESLint rule
These changes were mostly done automatically, using `gulp lint --fix`, and only a few spots with comments needed manual tweaking; please see https://eslint.org/docs/latest/rules/no-lonely-if
This commit is contained in:
parent
abb24f82fb
commit
c018070e80
@ -139,6 +139,7 @@
|
||||
"no-implied-eval": "error",
|
||||
"no-iterator": "error",
|
||||
"no-lone-blocks": "error",
|
||||
"no-lonely-if": "error",
|
||||
"no-multi-str": "error",
|
||||
"no-new-func": "error",
|
||||
"no-new-wrappers": "error",
|
||||
|
28
external/builder/builder.mjs
vendored
28
external/builder/builder.mjs
vendored
@ -198,21 +198,19 @@ function preprocess(inFilename, outFilename, defines) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if (state === STATE_NONE) {
|
||||
writeLine(line);
|
||||
} else if (
|
||||
(state === STATE_IF_TRUE || state === STATE_ELSE_TRUE) &&
|
||||
!stack.includes(STATE_IF_FALSE) &&
|
||||
!stack.includes(STATE_ELSE_FALSE)
|
||||
) {
|
||||
writeLine(
|
||||
line
|
||||
.replaceAll(/^\/\/|^<!--/g, " ")
|
||||
.replaceAll(/(^\s*)\/\*/g, "$1 ")
|
||||
.replaceAll(/\*\/$|-->$/g, "")
|
||||
);
|
||||
}
|
||||
} else if (state === STATE_NONE) {
|
||||
writeLine(line);
|
||||
} else if (
|
||||
(state === STATE_IF_TRUE || state === STATE_ELSE_TRUE) &&
|
||||
!stack.includes(STATE_IF_FALSE) &&
|
||||
!stack.includes(STATE_ELSE_FALSE)
|
||||
) {
|
||||
writeLine(
|
||||
line
|
||||
.replaceAll(/^\/\/|^<!--/g, " ")
|
||||
.replaceAll(/(^\s*)\/\*/g, "$1 ")
|
||||
.replaceAll(/\*\/$|-->$/g, "")
|
||||
);
|
||||
}
|
||||
}
|
||||
if (state !== STATE_NONE || stack.length !== 0) {
|
||||
|
6
external/importL10n/locales.mjs
vendored
6
external/importL10n/locales.mjs
vendored
@ -100,10 +100,8 @@ function downloadLanguageFiles(root, langCode) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (--downloadsLeft === 0) {
|
||||
resolve();
|
||||
}
|
||||
} else if (--downloadsLeft === 0) {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
@ -2698,24 +2698,22 @@ class TextWidgetAnnotation extends WidgetAnnotation {
|
||||
lastSpacePosInStringEnd = end;
|
||||
lastSpacePos = i;
|
||||
}
|
||||
} else {
|
||||
if (currentWidth + glyphWidth > width) {
|
||||
// We must break to the last white position (if available)
|
||||
if (lastSpacePosInStringStart !== -1) {
|
||||
chunks.push(line.substring(startChunk, lastSpacePosInStringEnd));
|
||||
startChunk = lastSpacePosInStringEnd;
|
||||
i = lastSpacePos + 1;
|
||||
lastSpacePosInStringStart = -1;
|
||||
currentWidth = 0;
|
||||
} else {
|
||||
// Just break in the middle of the word
|
||||
chunks.push(line.substring(startChunk, start));
|
||||
startChunk = start;
|
||||
currentWidth = glyphWidth;
|
||||
}
|
||||
} else if (currentWidth + glyphWidth > width) {
|
||||
// We must break to the last white position (if available)
|
||||
if (lastSpacePosInStringStart !== -1) {
|
||||
chunks.push(line.substring(startChunk, lastSpacePosInStringEnd));
|
||||
startChunk = lastSpacePosInStringEnd;
|
||||
i = lastSpacePos + 1;
|
||||
lastSpacePosInStringStart = -1;
|
||||
currentWidth = 0;
|
||||
} else {
|
||||
currentWidth += glyphWidth;
|
||||
// Just break in the middle of the word
|
||||
chunks.push(line.substring(startChunk, start));
|
||||
startChunk = start;
|
||||
currentWidth = glyphWidth;
|
||||
}
|
||||
} else {
|
||||
currentWidth += glyphWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -353,11 +353,8 @@ function bidi(str, startLevel = -1, vertical = false) {
|
||||
} else if (t === "AN" || t === "EN") {
|
||||
levels[i] += 2;
|
||||
}
|
||||
} else {
|
||||
// isOdd
|
||||
if (t === "L" || t === "AN" || t === "EN") {
|
||||
levels[i] += 1;
|
||||
}
|
||||
} else if (/* isOdd && */ t === "L" || t === "AN" || t === "EN") {
|
||||
levels[i] += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,7 +207,7 @@ class ChunkedStream extends Stream {
|
||||
if (start + length > this.progressiveDataLength) {
|
||||
this.ensureRange(start, start + length);
|
||||
}
|
||||
} else {
|
||||
} else if (start >= this.progressiveDataLength) {
|
||||
// When the `length` is undefined you do *not*, under any circumstances,
|
||||
// want to fallback on calling `this.ensureRange(start, this.end)` since
|
||||
// that would force the *entire* PDF file to be loaded, thus completely
|
||||
@ -217,9 +217,7 @@ class ChunkedStream extends Stream {
|
||||
// time/resources during e.g. parsing, since `MissingDataException`s will
|
||||
// require data to be re-parsed, which we attempt to minimize by at least
|
||||
// checking that the *beginning* of the data is available here.
|
||||
if (start >= this.progressiveDataLength) {
|
||||
this.ensureByte(start);
|
||||
}
|
||||
this.ensureByte(start);
|
||||
}
|
||||
|
||||
function ChunkedStreamSubstream() {}
|
||||
|
@ -206,22 +206,12 @@ class ColorSpace {
|
||||
rgbBuf[rgbPos++] = colorMap[key + 2];
|
||||
}
|
||||
}
|
||||
} else if (!needsResizing) {
|
||||
// Fill in the RGB values directly into |dest|.
|
||||
this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
|
||||
} else {
|
||||
if (!needsResizing) {
|
||||
// Fill in the RGB values directly into |dest|.
|
||||
this.getRgbBuffer(
|
||||
comps,
|
||||
0,
|
||||
width * actualHeight,
|
||||
dest,
|
||||
0,
|
||||
bpc,
|
||||
alpha01
|
||||
);
|
||||
} else {
|
||||
rgbBuf = new Uint8ClampedArray(count * 3);
|
||||
this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, /* alpha01 = */ 0);
|
||||
}
|
||||
rgbBuf = new Uint8ClampedArray(count * 3);
|
||||
this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, /* alpha01 = */ 0);
|
||||
}
|
||||
|
||||
if (rgbBuf) {
|
||||
|
@ -211,14 +211,12 @@ function compileGlyf(code, cmds, font) {
|
||||
arg2 = getUint16(code, i + 2);
|
||||
}
|
||||
i += 4;
|
||||
} else if (flags & 0x02) {
|
||||
arg1 = getInt8(code, i++);
|
||||
arg2 = getInt8(code, i++);
|
||||
} else {
|
||||
if (flags & 0x02) {
|
||||
arg1 = getInt8(code, i++);
|
||||
arg2 = getInt8(code, i++);
|
||||
} else {
|
||||
arg1 = code[i++];
|
||||
arg2 = code[i++];
|
||||
}
|
||||
arg1 = code[i++];
|
||||
arg2 = code[i++];
|
||||
}
|
||||
if (flags & 0x02) {
|
||||
x = arg1;
|
||||
|
@ -619,17 +619,15 @@ class CompositeGlyph {
|
||||
) {
|
||||
size += 2;
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
!(
|
||||
this.argument1 >= 0 &&
|
||||
this.argument1 <= 255 &&
|
||||
this.argument2 >= 0 &&
|
||||
this.argument2 <= 255
|
||||
)
|
||||
) {
|
||||
size += 2;
|
||||
}
|
||||
} else if (
|
||||
!(
|
||||
this.argument1 >= 0 &&
|
||||
this.argument1 <= 255 &&
|
||||
this.argument2 >= 0 &&
|
||||
this.argument2 <= 255
|
||||
)
|
||||
) {
|
||||
size += 2;
|
||||
}
|
||||
|
||||
return size;
|
||||
@ -650,17 +648,15 @@ class CompositeGlyph {
|
||||
) {
|
||||
this.flags |= ARG_1_AND_2_ARE_WORDS;
|
||||
}
|
||||
} else {
|
||||
if (
|
||||
!(
|
||||
this.argument1 >= 0 &&
|
||||
this.argument1 <= 255 &&
|
||||
this.argument2 >= 0 &&
|
||||
this.argument2 <= 255
|
||||
)
|
||||
) {
|
||||
this.flags |= ARG_1_AND_2_ARE_WORDS;
|
||||
}
|
||||
} else if (
|
||||
!(
|
||||
this.argument1 >= 0 &&
|
||||
this.argument1 <= 255 &&
|
||||
this.argument2 >= 0 &&
|
||||
this.argument2 <= 255
|
||||
)
|
||||
) {
|
||||
this.flags |= ARG_1_AND_2_ARE_WORDS;
|
||||
}
|
||||
|
||||
buf.setUint16(pos, this.flags);
|
||||
|
@ -3662,12 +3662,10 @@ class Line extends XFAObject {
|
||||
} else if (parent.h <= thickness) {
|
||||
[x1, y1, x2, y2] = [0, "50%", "100%", "50%"];
|
||||
height = style.strokeWidth;
|
||||
} else if (this.slope === "\\") {
|
||||
[x1, y1, x2, y2] = [0, 0, "100%", "100%"];
|
||||
} else {
|
||||
if (this.slope === "\\") {
|
||||
[x1, y1, x2, y2] = [0, 0, "100%", "100%"];
|
||||
} else {
|
||||
[x1, y1, x2, y2] = [0, "100%", "100%", 0];
|
||||
}
|
||||
[x1, y1, x2, y2] = [0, "100%", "100%", 0];
|
||||
}
|
||||
|
||||
const line = {
|
||||
|
@ -432,10 +432,8 @@ function pm(m) {
|
||||
const a = (Math.acos(m[0]) * 180) / Math.PI;
|
||||
return `rotate(${pf(a)})`;
|
||||
}
|
||||
} else {
|
||||
if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
|
||||
return `translate(${pf(m[4])} ${pf(m[5])})`;
|
||||
}
|
||||
} else if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
|
||||
return `translate(${pf(m[4])} ${pf(m[5])})`;
|
||||
}
|
||||
return (
|
||||
`matrix(${pf(m[0])} ${pf(m[1])} ${pf(m[2])} ${pf(m[3])} ${pf(m[4])} ` +
|
||||
|
@ -127,12 +127,10 @@ class Field extends PDFObject {
|
||||
indices.forEach(i => {
|
||||
this._value.push(this._items[i].displayValue);
|
||||
});
|
||||
} else {
|
||||
if (indices.length > 0) {
|
||||
indices = indices.splice(1, indices.length - 1);
|
||||
this._currentValueIndices = indices[0];
|
||||
this._value = this._items[this._currentValueIndices];
|
||||
}
|
||||
} else if (indices.length > 0) {
|
||||
indices = indices.splice(1, indices.length - 1);
|
||||
this._currentValueIndices = indices[0];
|
||||
this._value = this._items[this._currentValueIndices];
|
||||
}
|
||||
this._send({ id: this._id, indices });
|
||||
}
|
||||
@ -389,12 +387,10 @@ class Field extends PDFObject {
|
||||
--this._currentValueIndices[index];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (this._currentValueIndices === nIdx) {
|
||||
this._currentValueIndices = this.numItems > 0 ? 0 : -1;
|
||||
} else if (this._currentValueIndices > nIdx) {
|
||||
--this._currentValueIndices;
|
||||
}
|
||||
} else if (this._currentValueIndices === nIdx) {
|
||||
this._currentValueIndices = this.numItems > 0 ? 0 : -1;
|
||||
} else if (this._currentValueIndices > nIdx) {
|
||||
--this._currentValueIndices;
|
||||
}
|
||||
|
||||
this._send({ id: this._id, remove: nIdx });
|
||||
|
@ -623,11 +623,10 @@ class PDFFindController {
|
||||
if (newQuery !== prevQuery) {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
// Array
|
||||
if (JSON.stringify(newQuery) !== JSON.stringify(prevQuery)) {
|
||||
return true;
|
||||
}
|
||||
} else if (
|
||||
/* isArray && */ JSON.stringify(newQuery) !== JSON.stringify(prevQuery)
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (state.type) {
|
||||
|
@ -378,40 +378,38 @@ class PDFLinkService {
|
||||
zoomArgs.length > 2 ? zoomArgs[2] | 0 : null,
|
||||
zoomArgNumber ? zoomArgNumber / 100 : zoomArg,
|
||||
];
|
||||
} else {
|
||||
if (zoomArg === "Fit" || zoomArg === "FitB") {
|
||||
dest = [null, { name: zoomArg }];
|
||||
} else if (
|
||||
zoomArg === "FitH" ||
|
||||
zoomArg === "FitBH" ||
|
||||
zoomArg === "FitV" ||
|
||||
zoomArg === "FitBV"
|
||||
) {
|
||||
} else if (zoomArg === "Fit" || zoomArg === "FitB") {
|
||||
dest = [null, { name: zoomArg }];
|
||||
} else if (
|
||||
zoomArg === "FitH" ||
|
||||
zoomArg === "FitBH" ||
|
||||
zoomArg === "FitV" ||
|
||||
zoomArg === "FitBV"
|
||||
) {
|
||||
dest = [
|
||||
null,
|
||||
{ name: zoomArg },
|
||||
zoomArgs.length > 1 ? zoomArgs[1] | 0 : null,
|
||||
];
|
||||
} else if (zoomArg === "FitR") {
|
||||
if (zoomArgs.length !== 5) {
|
||||
console.error(
|
||||
'PDFLinkService.setHash: Not enough parameters for "FitR".'
|
||||
);
|
||||
} else {
|
||||
dest = [
|
||||
null,
|
||||
{ name: zoomArg },
|
||||
zoomArgs.length > 1 ? zoomArgs[1] | 0 : null,
|
||||
zoomArgs[1] | 0,
|
||||
zoomArgs[2] | 0,
|
||||
zoomArgs[3] | 0,
|
||||
zoomArgs[4] | 0,
|
||||
];
|
||||
} else if (zoomArg === "FitR") {
|
||||
if (zoomArgs.length !== 5) {
|
||||
console.error(
|
||||
'PDFLinkService.setHash: Not enough parameters for "FitR".'
|
||||
);
|
||||
} else {
|
||||
dest = [
|
||||
null,
|
||||
{ name: zoomArg },
|
||||
zoomArgs[1] | 0,
|
||||
zoomArgs[2] | 0,
|
||||
zoomArgs[3] | 0,
|
||||
zoomArgs[4] | 0,
|
||||
];
|
||||
}
|
||||
} else {
|
||||
console.error(
|
||||
`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
console.error(
|
||||
`PDFLinkService.setHash: "${zoomArg}" is not a valid zoom value.`
|
||||
);
|
||||
}
|
||||
}
|
||||
if (dest) {
|
||||
|
@ -128,10 +128,8 @@ class BasePreferences {
|
||||
`Set preference: "${value}" is a ${valueType}, expected a ${defaultType}.`
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (valueType === "number" && !Number.isInteger(value)) {
|
||||
throw new Error(`Set preference: "${value}" must be an integer.`);
|
||||
}
|
||||
} else if (valueType === "number" && !Number.isInteger(value)) {
|
||||
throw new Error(`Set preference: "${value}" must be an integer.`);
|
||||
}
|
||||
|
||||
this.#prefs[name] = value;
|
||||
|
Loading…
Reference in New Issue
Block a user