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:
Jonas Jenwald 2023-06-12 11:46:11 +02:00
parent 9af50dc358
commit fee850737b
32 changed files with 45 additions and 44 deletions

View file

@ -523,7 +523,7 @@ function getUrlProp(val) {
try {
// The full path is required in the 'url' field.
return new URL(val, window.location).href;
} catch (ex) {
} catch {
if (
typeof PDFJSDev !== "undefined" &&
PDFJSDev.test("GENERIC") &&
@ -2011,7 +2011,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
if (!base.origin || base.origin === "null") {
return false; // non-HTTP url
}
} catch (e) {
} catch {
return false;
}
@ -2187,7 +2187,7 @@ class PDFWorker {
}
try {
sendTest();
} catch (e) {
} catch {
// We need fallback to a faked worker.
this._setupFakeWorker();
}
@ -2204,7 +2204,7 @@ class PDFWorker {
// The worker shall process only the first received "test" message.
sendTest();
return;
} catch (e) {
} catch {
info("The worker has been disabled.");
}
}
@ -2305,7 +2305,7 @@ class PDFWorker {
static get _mainThreadWorkerMessageHandler() {
try {
return globalThis.pdfjsWorker?.WorkerMessageHandler || null;
} catch (ex) {
} catch {
return null;
}
}