1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 14:48:08 +02:00

Merge pull request #19504 from Snuffleupagus/eslint-fix-arrow-body-style

Fix all outstanding ESLint `arrow-body-style` warnings
This commit is contained in:
Jonas Jenwald 2025-02-18 17:52:36 +01:00 committed by GitHub
commit 426c730e11
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 71 additions and 82 deletions

View file

@ -84,17 +84,14 @@ class AnnotationFactory {
// with "GoToE" actions, from throwing and thus breaking parsing:
pdfManager.ensureCatalog("attachments"),
]).then(
// eslint-disable-next-line arrow-body-style
([acroForm, xfaDatasets, structTreeRoot, baseUrl, attachments]) => {
return {
pdfManager,
acroForm: acroForm instanceof Dict ? acroForm : Dict.empty,
xfaDatasets,
structTreeRoot,
baseUrl,
attachments,
};
},
([acroForm, xfaDatasets, structTreeRoot, baseUrl, attachments]) => ({
pdfManager,
acroForm: acroForm instanceof Dict ? acroForm : Dict.empty,
xfaDatasets,
structTreeRoot,
baseUrl,
attachments,
}),
reason => {
warn(`createGlobals: "${reason}".`);
return null;

View file

@ -1620,24 +1620,24 @@ class PDFDocument {
} else {
promise = catalog.getPageDict(pageIndex);
}
// eslint-disable-next-line arrow-body-style
promise = promise.then(([pageDict, ref]) => {
return new Page({
pdfManager: this.pdfManager,
xref: this.xref,
pageIndex,
pageDict,
ref,
globalIdFactory: this._globalIdFactory,
fontCache: catalog.fontCache,
builtInCMapCache: catalog.builtInCMapCache,
standardFontDataCache: catalog.standardFontDataCache,
globalImageCache: catalog.globalImageCache,
systemFontCache: catalog.systemFontCache,
nonBlendModesSet: catalog.nonBlendModesSet,
xfaFactory,
});
});
promise = promise.then(
([pageDict, ref]) =>
new Page({
pdfManager: this.pdfManager,
xref: this.xref,
pageIndex,
pageDict,
ref,
globalIdFactory: this._globalIdFactory,
fontCache: catalog.fontCache,
builtInCMapCache: catalog.builtInCMapCache,
standardFontDataCache: catalog.standardFontDataCache,
globalImageCache: catalog.globalImageCache,
systemFontCache: catalog.systemFontCache,
nonBlendModesSet: catalog.nonBlendModesSet,
xfaFactory,
})
);
this._pagePromises.set(pageIndex, promise);
return promise;

View file

@ -1231,15 +1231,13 @@ class PartialEvaluator {
fallbackFontDict = null,
cssFontInfo = null
) {
// eslint-disable-next-line arrow-body-style
const errorFont = async () => {
return new TranslatedFont({
const errorFont = async () =>
new TranslatedFont({
loadedName: "g_font_error",
font: new ErrorFont(`Font "${fontName}" is not available.`),
dict: font,
evaluatorOptions: this.options,
});
};
let fontRef;
if (font) {

View file

@ -106,33 +106,33 @@ async function inlineImages(node, silentErrors = false) {
}
return response.blob();
})
// eslint-disable-next-line arrow-body-style
.then(blob => {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
resolve(reader.result);
};
reader.onerror = reject;
.then(
blob =>
new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
resolve(reader.result);
};
reader.onerror = reject;
reader.readAsDataURL(blob);
});
})
// eslint-disable-next-line arrow-body-style
.then(dataUrl => {
return new Promise((resolve, reject) => {
image.onload = resolve;
image.onerror = evt => {
if (silentErrors) {
resolve();
return;
}
reject(evt);
};
reader.readAsDataURL(blob);
})
)
.then(
dataUrl =>
new Promise((resolve, reject) => {
image.onload = resolve;
image.onerror = evt => {
if (silentErrors) {
resolve();
return;
}
reject(evt);
};
image.src = dataUrl;
});
})
image.src = dataUrl;
})
)
.catch(reason => {
throw new Error(`Error inlining image (${url}): ${reason}`);
})

View file

@ -4110,34 +4110,28 @@ Caron Broadcasting, Inc., an Ohio corporation (“Lessee”).`)
})
);
// eslint-disable-next-line arrow-body-style
const result1 = loadingTask1.promise.then(pdfDoc => {
// eslint-disable-next-line arrow-body-style
return pdfDoc.getPage(1).then(pdfPage => {
return pdfPage.getOperatorList().then(opList => {
expect(opList.fnArray.length).toBeGreaterThan(100);
expect(opList.argsArray.length).toBeGreaterThan(100);
expect(opList.lastChunk).toEqual(true);
expect(opList.separateAnnots).toEqual(null);
const result1 = loadingTask1.promise.then(async pdfDoc => {
const pdfPage = await pdfDoc.getPage(1);
const opList = await pdfPage.getOperatorList();
return loadingTask1.destroy();
});
});
expect(opList.fnArray.length).toBeGreaterThan(100);
expect(opList.argsArray.length).toBeGreaterThan(100);
expect(opList.lastChunk).toEqual(true);
expect(opList.separateAnnots).toEqual(null);
await loadingTask1.destroy();
});
// eslint-disable-next-line arrow-body-style
const result2 = loadingTask2.promise.then(pdfDoc => {
// eslint-disable-next-line arrow-body-style
return pdfDoc.getPage(1).then(pdfPage => {
return pdfPage.getOperatorList().then(opList => {
expect(opList.fnArray.length).toEqual(0);
expect(opList.argsArray.length).toEqual(0);
expect(opList.lastChunk).toEqual(true);
expect(opList.separateAnnots).toEqual(null);
const result2 = loadingTask2.promise.then(async pdfDoc => {
const pdfPage = await pdfDoc.getPage(1);
const opList = await pdfPage.getOperatorList();
return loadingTask2.destroy();
});
});
expect(opList.fnArray.length).toEqual(0);
expect(opList.argsArray.length).toEqual(0);
expect(opList.lastChunk).toEqual(true);
expect(opList.separateAnnots).toEqual(null);
await loadingTask2.destroy();
});
await Promise.all([result1, result2]);