mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Enable the unicorn/prefer-optional-catch-binding
ESLint plugin rule
According to MDN this format is available in all browsers/environments that we currently support, see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch#browser_compatibility Please also see https://github.com/sindresorhus/eslint-plugin-unicorn/blob/main/docs/rules/prefer-optional-catch-binding.md
This commit is contained in:
parent
9af50dc358
commit
fee850737b
32 changed files with 45 additions and 44 deletions
|
@ -815,7 +815,7 @@ const PDFViewerApplication = {
|
|||
if (!title) {
|
||||
try {
|
||||
title = decodeURIComponent(getFilenameFromUrl(url)) || url;
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
// decodeURIComponent may throw URIError,
|
||||
// fall back to using the unprocessed url in that case
|
||||
title = url;
|
||||
|
@ -876,7 +876,7 @@ const PDFViewerApplication = {
|
|||
try {
|
||||
// Trigger saving, to prevent data loss in forms; see issue 12257.
|
||||
await this.save();
|
||||
} catch (reason) {
|
||||
} catch {
|
||||
// Ignoring errors, to ensure that document closing won't break.
|
||||
}
|
||||
}
|
||||
|
@ -1044,7 +1044,7 @@ const PDFViewerApplication = {
|
|||
const blob = new Blob([data], { type: "application/pdf" });
|
||||
|
||||
await this.downloadManager.download(blob, url, filename, options);
|
||||
} catch (reason) {
|
||||
} catch {
|
||||
// When the PDF document isn't ready, or the PDF file is still
|
||||
// downloading, simply download using the URL.
|
||||
await this.downloadManager.downloadUrl(url, filename, options);
|
||||
|
|
|
@ -150,7 +150,7 @@ function isRuntimeAvailable() {
|
|||
if (chrome.runtime?.getManifest()) {
|
||||
return true;
|
||||
}
|
||||
} catch (e) {}
|
||||
} catch {}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ class GrabToPan {
|
|||
try {
|
||||
// eslint-disable-next-line no-unused-expressions
|
||||
event.originalTarget.tagName;
|
||||
} catch (e) {
|
||||
} catch {
|
||||
// Mozilla-specific: element is a scrollbar (XUL element)
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -445,7 +445,7 @@ class PDFLinkService {
|
|||
// e.g. "4.3" or "true", because `JSON.parse` converted its type.
|
||||
dest = dest.toString();
|
||||
}
|
||||
} catch (ex) {}
|
||||
} catch {}
|
||||
|
||||
if (
|
||||
typeof dest === "string" ||
|
||||
|
|
|
@ -341,7 +341,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
|
|||
return null; // The document was closed while the data resolved.
|
||||
}
|
||||
this.linkService.cachePageRef(pageNumber, destRef);
|
||||
} catch (ex) {
|
||||
} catch {
|
||||
// Invalid page reference, ignore it and continue parsing.
|
||||
}
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ class PDFPresentationMode {
|
|||
await promise;
|
||||
pdfViewer.focus(); // Fixes bug 1787456.
|
||||
return true;
|
||||
} catch (reason) {
|
||||
} catch {
|
||||
this.#removeFullscreenChangeListeners();
|
||||
this.#notifyStateChange(PresentationModeState.NORMAL);
|
||||
}
|
||||
|
|
|
@ -487,7 +487,7 @@ class PDFScriptingManager {
|
|||
|
||||
try {
|
||||
await this._scripting.destroySandbox();
|
||||
} catch (ex) {}
|
||||
} catch {}
|
||||
|
||||
for (const [name, listener] of this._internalEvents) {
|
||||
this._eventBus._off(name, listener);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue