1
0
Fork 0
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:
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

@ -471,7 +471,7 @@ describe("Interaction", () => {
await page._client.send("Page.setDownloadBehavior", {
behavior: "deny",
});
} catch (_) {}
} catch {}
await clearInput(page, getSelector("47R"));
await page.evaluate(_ => {
window.document.activeElement.blur();

View file

@ -168,7 +168,7 @@ describe("api", function () {
// Shouldn't get here.
expect(false).toEqual(true);
} catch (reason) {
} catch {
expect(true).toEqual(true);
await destroyed;
}

View file

@ -549,7 +549,7 @@ describe("CipherTransformFactory", function () {
try {
const factory = new CipherTransformFactory(dict, fileId, password);
expect("createCipherTransform" in factory).toEqual(true);
} catch (ex) {
} catch {
// Shouldn't get here.
expect(false).toEqual(true);
}

View file

@ -368,7 +368,7 @@ describe("evaluator", function () {
// Shouldn't get here.
expect(false).toEqual(true);
} catch (_) {
} catch {
expect(!!result.fnArray && !!result.argsArray).toEqual(true);
expect(result.fnArray.length).toEqual(0);
}
@ -389,7 +389,7 @@ describe("evaluator", function () {
// Shouldn't get here.
expect(false).toEqual(true);
} catch (_) {
} catch {
expect(true).toEqual(true);
}
});

View file

@ -90,7 +90,7 @@ WebServer.prototype = {
// Windows paths cause issues in statFile and serverDirectoryIndex.
// Converting to unix path would avoid platform checks in said functions.
pathPart = pathPart.replaceAll("\\", "/");
} catch (ex) {
} catch {
// If the URI cannot be decoded, a `URIError` is thrown. This happens for
// malformed URIs such as `http://localhost:8888/%s%s` and should be
// handled as a bad request.