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

@ -648,7 +648,7 @@ function getPdfFilenameFromUrl(url, defaultFilename = "document.pdf") {
suggestedFilename = reFilename.exec(
decodeURIComponent(suggestedFilename)
)[0];
} catch (ex) {
} catch {
// Possible (extremely rare) errors:
// URIError "Malformed URI", e.g. for "%AA.pdf"
// TypeError "null has no properties", e.g. for "%2F.pdf"
@ -702,7 +702,7 @@ function isValidFetchUrl(url, baseUrl) {
const { protocol } = baseUrl ? new URL(url, baseUrl) : new URL(url);
// The Fetch API only supports the http/https protocols, and not file/ftp.
return protocol === "http:" || protocol === "https:";
} catch (ex) {
} catch {
return false; // `new URL()` will throw on incorrect data.
}
}