Additional *manual* unicorn/prefer-ternary
changes
Not all cases could be automatically fixed, and the changes also triggered a number of `prefer-const` errors that needed to be handled manually.
This commit is contained in:
parent
674e7ee381
commit
c0fe96b8fe
@ -839,8 +839,7 @@ class Annotation {
|
|||||||
|
|
||||||
setRotation(mk, dict) {
|
setRotation(mk, dict) {
|
||||||
this.rotation = 0;
|
this.rotation = 0;
|
||||||
let angle;
|
let angle = mk instanceof Dict ? mk.get("R") || 0 : dict.get("Rotate") || 0;
|
||||||
angle = mk instanceof Dict ? mk.get("R") || 0 : dict.get("Rotate") || 0;
|
|
||||||
if (Number.isInteger(angle) && angle !== 0) {
|
if (Number.isInteger(angle) && angle !== 0) {
|
||||||
angle %= 360;
|
angle %= 360;
|
||||||
if (angle < 0) {
|
if (angle < 0) {
|
||||||
|
@ -558,8 +558,7 @@ class CFFParser {
|
|||||||
stackSize %= 2;
|
stackSize %= 2;
|
||||||
validationCommand = CharstringValidationData[value];
|
validationCommand = CharstringValidationData[value];
|
||||||
} else if (value === 10 || value === 29) {
|
} else if (value === 10 || value === 29) {
|
||||||
let subrsIndex;
|
const subrsIndex = value === 10 ? localSubrIndex : globalSubrIndex;
|
||||||
subrsIndex = value === 10 ? localSubrIndex : globalSubrIndex;
|
|
||||||
if (!subrsIndex) {
|
if (!subrsIndex) {
|
||||||
validationCommand = CharstringValidationData[value];
|
validationCommand = CharstringValidationData[value];
|
||||||
warn("Missing subrsIndex for " + validationCommand.id);
|
warn("Missing subrsIndex for " + validationCommand.id);
|
||||||
|
@ -1305,9 +1305,7 @@ const CalRGBCS = (function CalRGBCSClosure() {
|
|||||||
const LabCS = (function LabCSClosure() {
|
const LabCS = (function LabCSClosure() {
|
||||||
// Function g(x) from spec
|
// Function g(x) from spec
|
||||||
function fn_g(x) {
|
function fn_g(x) {
|
||||||
let result;
|
return x >= 6 / 29 ? x ** 3 : (108 / 841) * (x - 4 / 29);
|
||||||
result = x >= 6 / 29 ? x ** 3 : (108 / 841) * (x - 4 / 29);
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function decode(value, high1, low2, high2) {
|
function decode(value, high1, low2, high2) {
|
||||||
|
@ -1445,8 +1445,7 @@ const CipherTransformFactory = (function CipherTransformFactoryClosure() {
|
|||||||
} else {
|
} else {
|
||||||
password = [];
|
password = [];
|
||||||
}
|
}
|
||||||
let pdfAlgorithm;
|
const pdfAlgorithm = revision === 6 ? new PDF20() : new PDF17();
|
||||||
pdfAlgorithm = revision === 6 ? new PDF20() : new PDF17();
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)
|
pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)
|
||||||
|
@ -793,8 +793,7 @@ class PartialEvaluator {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (cacheKey && imageRef && cacheGlobally) {
|
if (cacheKey && imageRef && cacheGlobally) {
|
||||||
let length = 0;
|
const length = imgData.bitmap
|
||||||
length = imgData.bitmap
|
|
||||||
? imgData.width * imgData.height * 4
|
? imgData.width * imgData.height * 4
|
||||||
: imgData.data.length;
|
: imgData.data.length;
|
||||||
this.globalImageCache.addByteSize(imageRef, length);
|
this.globalImageCache.addByteSize(imageRef, length);
|
||||||
|
@ -116,11 +116,7 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
|
|||||||
baseEncoding = builtInEncoding;
|
baseEncoding = builtInEncoding;
|
||||||
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
||||||
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
||||||
if (glyphId >= 0) {
|
charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : /* notdef = */ 0;
|
||||||
charCodeToGlyphId[charCode] = glyphId;
|
|
||||||
} else {
|
|
||||||
charCodeToGlyphId[charCode] = 0; // notdef
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (properties.baseEncodingName) {
|
} else if (properties.baseEncodingName) {
|
||||||
// If a valid base encoding name was used, the mapping is initialized with
|
// If a valid base encoding name was used, the mapping is initialized with
|
||||||
@ -128,11 +124,7 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
|
|||||||
baseEncoding = getEncoding(properties.baseEncodingName);
|
baseEncoding = getEncoding(properties.baseEncodingName);
|
||||||
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
||||||
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
||||||
if (glyphId >= 0) {
|
charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : /* notdef = */ 0;
|
||||||
charCodeToGlyphId[charCode] = glyphId;
|
|
||||||
} else {
|
|
||||||
charCodeToGlyphId[charCode] = 0; // notdef
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if (isSymbolicFont) {
|
} else if (isSymbolicFont) {
|
||||||
// For a symbolic font the encoding should be the fonts built-in encoding.
|
// For a symbolic font the encoding should be the fonts built-in encoding.
|
||||||
@ -145,11 +137,7 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
|
|||||||
baseEncoding = StandardEncoding;
|
baseEncoding = StandardEncoding;
|
||||||
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
for (charCode = 0; charCode < baseEncoding.length; charCode++) {
|
||||||
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
glyphId = glyphNames.indexOf(baseEncoding[charCode]);
|
||||||
if (glyphId >= 0) {
|
charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : /* notdef = */ 0;
|
||||||
charCodeToGlyphId[charCode] = glyphId;
|
|
||||||
} else {
|
|
||||||
charCodeToGlyphId[charCode] = 0; // notdef
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,11 +158,7 @@ function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
|
|||||||
glyphId = glyphNames.indexOf(standardGlyphName);
|
glyphId = glyphNames.indexOf(standardGlyphName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (glyphId >= 0) {
|
charCodeToGlyphId[charCode] = glyphId >= 0 ? glyphId : /* notdef = */ 0;
|
||||||
charCodeToGlyphId[charCode] = glyphId;
|
|
||||||
} else {
|
|
||||||
charCodeToGlyphId[charCode] = 0; // notdef
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return charCodeToGlyphId;
|
return charCodeToGlyphId;
|
||||||
|
@ -385,8 +385,7 @@ function decodeScan(
|
|||||||
|
|
||||||
let mcu = 0,
|
let mcu = 0,
|
||||||
fileMarker;
|
fileMarker;
|
||||||
let mcuExpected;
|
const mcuExpected =
|
||||||
mcuExpected =
|
|
||||||
componentsLength === 1
|
componentsLength === 1
|
||||||
? components[0].blocksPerLine * components[0].blocksPerColumn
|
? components[0].blocksPerLine * components[0].blocksPerColumn
|
||||||
: mcusPerLine * frame.mcusPerColumn;
|
: mcusPerLine * frame.mcusPerColumn;
|
||||||
|
@ -55,9 +55,8 @@ class Binder {
|
|||||||
constructor(root) {
|
constructor(root) {
|
||||||
this.root = root;
|
this.root = root;
|
||||||
this.datasets = root.datasets;
|
this.datasets = root.datasets;
|
||||||
this.data = root.datasets?.data
|
this.data =
|
||||||
? root.datasets.data
|
root.datasets?.data || new XmlObject(NamespaceIds.datasets.id, "data");
|
||||||
: new XmlObject(NamespaceIds.datasets.id, "data");
|
|
||||||
this.emptyMerge = this.data[$getChildren]().length === 0;
|
this.emptyMerge = this.data[$getChildren]().length === 0;
|
||||||
|
|
||||||
this.root.form = this.form = root.template[$clone]();
|
this.root.form = this.form = root.template[$clone]();
|
||||||
|
@ -224,8 +224,7 @@ function getXfaFontWidths(name) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { baseWidths, baseMapping, factors } = info;
|
const { baseWidths, baseMapping, factors } = info;
|
||||||
let rescaledBaseWidths;
|
const rescaledBaseWidths = !factors
|
||||||
rescaledBaseWidths = !factors
|
|
||||||
? baseWidths
|
? baseWidths
|
||||||
: baseWidths.map((w, i) => w * factors[i]);
|
: baseWidths.map((w, i) => w * factors[i]);
|
||||||
|
|
||||||
|
@ -854,8 +854,7 @@ function genericComposeSMask(
|
|||||||
const g0 = hasBackdrop ? backdrop[1] : 0;
|
const g0 = hasBackdrop ? backdrop[1] : 0;
|
||||||
const b0 = hasBackdrop ? backdrop[2] : 0;
|
const b0 = hasBackdrop ? backdrop[2] : 0;
|
||||||
|
|
||||||
let composeFn;
|
const composeFn =
|
||||||
composeFn =
|
|
||||||
subtype === "Luminosity" ? composeSMaskLuminosity : composeSMaskAlpha;
|
subtype === "Luminosity" ? composeSMaskLuminosity : composeSMaskAlpha;
|
||||||
|
|
||||||
// processing image in chunks to save memory
|
// processing image in chunks to save memory
|
||||||
@ -2254,8 +2253,7 @@ class CanvasGraphics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let charWidth;
|
const charWidth = vertical
|
||||||
charWidth = vertical
|
|
||||||
? width * widthAdvanceScale - spacing * fontDirection
|
? width * widthAdvanceScale - spacing * fontDirection
|
||||||
: width * widthAdvanceScale + spacing * fontDirection;
|
: width * widthAdvanceScale + spacing * fontDirection;
|
||||||
x += charWidth;
|
x += charWidth;
|
||||||
|
@ -200,8 +200,7 @@ function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
|
|||||||
let xb, cbr, cbg, cbb;
|
let xb, cbr, cbg, cbb;
|
||||||
for (let y = minY; y <= maxY; y++) {
|
for (let y = minY; y <= maxY; y++) {
|
||||||
if (y < y2) {
|
if (y < y2) {
|
||||||
let k;
|
const k = y < y1 ? 0 : (y1 - y) / (y1 - y2);
|
||||||
k = y < y1 ? 0 : (y1 - y) / (y1 - y2);
|
|
||||||
xa = x1 - (x1 - x2) * k;
|
xa = x1 - (x1 - x2) * k;
|
||||||
car = c1r - (c1r - c2r) * k;
|
car = c1r - (c1r - c2r) * k;
|
||||||
cag = c1g - (c1g - c2g) * k;
|
cag = c1g - (c1g - c2g) * k;
|
||||||
|
@ -152,14 +152,9 @@ const convertImgDataToPng = (function () {
|
|||||||
// Node v0.11.12 zlib.deflateSync is introduced (and returns a Buffer).
|
// Node v0.11.12 zlib.deflateSync is introduced (and returns a Buffer).
|
||||||
// Node v3.0.0 Buffer inherits from Uint8Array.
|
// Node v3.0.0 Buffer inherits from Uint8Array.
|
||||||
// Node v8.0.0 zlib.deflateSync accepts Uint8Array as input.
|
// Node v8.0.0 zlib.deflateSync accepts Uint8Array as input.
|
||||||
let input;
|
const input =
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
if (parseInt(process.versions.node) >= 8) {
|
|
||||||
input = literals;
|
|
||||||
} else {
|
|
||||||
// eslint-disable-next-line no-undef
|
// eslint-disable-next-line no-undef
|
||||||
input = Buffer.from(literals);
|
parseInt(process.versions.node) >= 8 ? literals : Buffer.from(literals);
|
||||||
}
|
|
||||||
const output = __non_webpack_require__("zlib").deflateSync(input, {
|
const output = __non_webpack_require__("zlib").deflateSync(input, {
|
||||||
level: 9,
|
level: 9,
|
||||||
});
|
});
|
||||||
@ -857,8 +852,7 @@ class SVGGraphics {
|
|||||||
// might actually map to a different glyph.
|
// might actually map to a different glyph.
|
||||||
}
|
}
|
||||||
|
|
||||||
let charWidth;
|
const charWidth = vertical
|
||||||
charWidth = vertical
|
|
||||||
? width * widthAdvanceScale - spacing * fontDirection
|
? width * widthAdvanceScale - spacing * fontDirection
|
||||||
: width * widthAdvanceScale + spacing * fontDirection;
|
: width * widthAdvanceScale + spacing * fontDirection;
|
||||||
|
|
||||||
|
@ -212,8 +212,7 @@ class XfaLayer {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
let childHtml;
|
const childHtml = child?.attributes?.xmlns
|
||||||
childHtml = child?.attributes?.xmlns
|
|
||||||
? document.createElementNS(child.attributes.xmlns, name)
|
? document.createElementNS(child.attributes.xmlns, name)
|
||||||
: document.createElement(name);
|
: document.createElement(name);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user