Remove a few eslint-disable statements in the web/ folder

These cases could be easily re-written to avoid having to disable ESLint rules.
This commit is contained in:
Jonas Jenwald 2025-02-17 13:40:09 +01:00
parent 33c97570f5
commit a2d15ceb84
3 changed files with 24 additions and 33 deletions

View File

@ -18,19 +18,13 @@ import { getPdfFilenameFromUrl } from "pdfjs-lib";
async function docProperties(pdfDocument) { async function docProperties(pdfDocument) {
const url = "", const url = "",
baseUrl = url.split("#", 1)[0]; baseUrl = url.split("#", 1)[0];
// eslint-disable-next-line prefer-const const { info, metadata, contentDispositionFilename, contentLength } =
let { info, metadata, contentDispositionFilename, contentLength } =
await pdfDocument.getMetadata(); await pdfDocument.getMetadata();
if (!contentLength) {
const { length } = await pdfDocument.getDownloadInfo();
contentLength = length;
}
return { return {
...info, ...info,
baseURL: baseUrl, baseURL: baseUrl,
filesize: contentLength, filesize: contentLength || (await pdfDocument.getDownloadInfo()).length,
filename: contentDispositionFilename || getPdfFilenameFromUrl(url), filename: contentDispositionFilename || getPdfFilenameFromUrl(url),
metadata: metadata?.getRaw(), metadata: metadata?.getRaw(),
authors: metadata?.get("dc:creator"), authors: metadata?.get("dc:creator"),

View File

@ -886,9 +886,8 @@ class PDFFindController {
const { promise, resolve } = Promise.withResolvers(); const { promise, resolve } = Promise.withResolvers();
this._extractTextPromises[i] = promise; this._extractTextPromises[i] = promise;
// eslint-disable-next-line arrow-body-style deferred = deferred.then(() =>
deferred = deferred.then(() => { this._pdfDocument
return this._pdfDocument
.getPage(i + 1) .getPage(i + 1)
.then(pdfPage => pdfPage.getTextContent(textOptions)) .then(pdfPage => pdfPage.getTextContent(textOptions))
.then( .then(
@ -921,8 +920,8 @@ class PDFFindController {
this._hasDiacritics[i] = false; this._hasDiacritics[i] = false;
resolve(); resolve();
} }
)
); );
});
} }
} }

View File

@ -260,28 +260,26 @@ window.print = function () {
ensureOverlay().then(function () { ensureOverlay().then(function () {
overlayManager.closeIfActive(dialog); overlayManager.closeIfActive(dialog);
}); });
return; // eslint-disable-line no-unsafe-finally } else {
}
const activeServiceOnEntry = activeService; const activeServiceOnEntry = activeService;
activeService activeService
.renderPages() .renderPages()
.then(function () { .then(() => activeServiceOnEntry.performPrint())
return activeServiceOnEntry.performPrint(); .catch(() => {
})
.catch(function () {
// Ignore any error messages. // Ignore any error messages.
}) })
.then(function () { .then(() => {
// aborts acts on the "active" print request, so we need to check // aborts acts on the "active" print request, so we need to check
// whether the print request (activeServiceOnEntry) is still active. // whether the print request (activeServiceOnEntry) is still active.
// Without the check, an unrelated print request (created after aborting // Without the check, an unrelated print request (created after
// this print request while the pages were being generated) would be // aborting this print request while the pages were being generated)
// aborted. // would be aborted.
if (activeServiceOnEntry.active) { if (activeServiceOnEntry.active) {
abort(); abort();
} }
}); });
} }
}
}; };
function dispatchEvent(eventType) { function dispatchEvent(eventType) {