eslint: Fix unicorn/prefer-optional-catch-binding.

https://github.com/sindresorhus/eslint-plugin-unicorn/blob/master/docs/rules/prefer-optional-catch-binding.md

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2020-10-07 01:18:48 -07:00
committed by Tim Abbott
parent 70a0260ac1
commit d654992164
7 changed files with 10 additions and 10 deletions

View File

@@ -66,7 +66,7 @@ exports.decodeHashComponent = function (str) {
// that the url is invalid.
// TODO: Show possible valid urls to the user.
return decodeURIComponent(str.replace(/\./g, "%"));
} catch (e) {
} catch {
ui_report.error(i18n.t("Invalid URL"), undefined, $("#home-error"), 2000);
return "";
}

View File

@@ -5,7 +5,7 @@ const ls = {
parseJSON(str) {
try {
return JSON.parse(str);
} catch (err) {
} catch {
return undefined;
}
},
@@ -169,7 +169,7 @@ let warned_of_localstorage = false;
localstorage.supported = function supports_localstorage() {
try {
return window.localStorage !== undefined && window.localStorage !== null;
} catch (e) {
} catch {
if (!warned_of_localstorage) {
blueslip.error(
"Client browser does not support local storage, will lose socket message on reload",

View File

@@ -84,7 +84,7 @@ function get_custom_http_headers() {
try {
// Let JavaScript validate the JSON for us.
custom_headers = JSON.stringify(JSON.parse(custom_headers));
} catch (err) {
} catch {
set_results_notice("Custom HTTP headers are not in a valid JSON format.", "warning");
return undefined;
}
@@ -189,7 +189,7 @@ function handle_unsuccessful_response(response) {
const status_code = response.statusCode().status;
response = JSON.parse(response.responseText);
set_results_notice("Result: " + "(" + status_code + ") " + response.msg, "warning");
} catch (err) {
} catch {
// If the response is not a JSON response, then it is probably
// Django returning an HTML response containing a stack trace
// with useful debugging information regarding the backend
@@ -262,7 +262,7 @@ function send_webhook_fixture_message() {
// Let JavaScript validate the JSON for us.
body = JSON.stringify(JSON.parse(body));
is_json = true;
} catch (err) {
} catch {
set_results_notice("Invalid JSON in fixture body.", "warning");
return;
}

View File

@@ -119,7 +119,7 @@ exports.handle_event = function (submsg) {
try {
data = JSON.parse(submsg.content);
} catch (err) {
} catch {
blueslip.error("server sent us invalid json in handle_event: " + submsg.content);
return;
}

View File

@@ -164,7 +164,7 @@ exports.upload_files = function (uppy, config, files) {
type: file.type,
data: file,
});
} catch (error) {
} catch {
// Errors are handled by info-visible and upload-error event callbacks.
break;
}

View File

@@ -143,7 +143,7 @@ exports.make_strcmp = function () {
try {
const collator = new Intl.Collator();
return collator.compare;
} catch (e) {
} catch {
// continue regardless of error
}

View File

@@ -78,7 +78,7 @@ function wrap_tex(tex) {
return katex.renderToString(tex, {
displayMode: true,
});
} catch (ex) {
} catch {
return '<span class="tex-error">' + _.escape(tex) + "</span>";
}
}