From 6368cf17cbfa1874c4564b1020801fa5b6232759 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Thu, 21 Dec 2023 16:00:27 -0800 Subject: [PATCH] eslint: Fix @typescript-eslint/no-confusing-void-expression. Signed-off-by: Anders Kaseorg --- web/debug-require-webpack-plugin.ts | 11 ++++++----- web/e2e-tests/compose.test.ts | 7 +++---- web/e2e-tests/lib/common.ts | 4 +++- web/e2e-tests/realm-creation.test.ts | 12 +++++++++--- web/e2e-tests/realm-playground.test.ts | 4 +++- web/e2e-tests/user-status.test.ts | 6 +++--- web/src/attachments_ui.ts | 5 +++-- web/src/avatar.ts | 4 ++-- web/src/billing/billing.ts | 20 ++++++++++++-------- web/src/blueslip.ts | 2 +- web/src/feedback_widget.ts | 8 ++++++-- web/src/input_pill.ts | 3 ++- web/src/realm_icon.ts | 4 ++-- web/src/realm_logo.ts | 4 ++-- web/src/settings_emoji.ts | 8 ++++++-- web/src/settings_exports.ts | 4 +++- 16 files changed, 66 insertions(+), 40 deletions(-) diff --git a/web/debug-require-webpack-plugin.ts b/web/debug-require-webpack-plugin.ts index d19fbb15a5..c3c8b8b6fc 100644 --- a/web/debug-require-webpack-plugin.ts +++ b/web/debug-require-webpack-plugin.ts @@ -60,16 +60,17 @@ export default class DebugRequirePlugin implements WebpackPluginInstance { "DebugRequirePlugin", async ({normalModuleFactory}) => { const resolver = normalModuleFactory.getResolver("normal"); - debugRequirePath = await new Promise((resolve) => + debugRequirePath = await new Promise((resolve) => { resolver.resolve( {}, __dirname, "./debug-require", {}, - (err?: Error | null, result?: string | false) => - resolve(err ? false : result!), - ), - ); + (err?: Error | null, result?: string | false) => { + resolve(err ? false : result!); + }, + ); + }); }, ); diff --git a/web/e2e-tests/compose.test.ts b/web/e2e-tests/compose.test.ts index 648fc115d7..60d33ecf5d 100644 --- a/web/e2e-tests/compose.test.ts +++ b/web/e2e-tests/compose.test.ts @@ -112,10 +112,9 @@ async function test_narrow_to_private_messages_with_cordelia(page: Page): Promis const you_and_cordelia_selector = '*[data-tippy-content="Go to direct messages with Cordelia, Lear\'s daughter"]'; // For some unknown reason page.click() isn't working here. - await page.evaluate( - (selector: string) => document.querySelector(selector)!.click(), - you_and_cordelia_selector, - ); + await page.evaluate((selector: string) => { + document.querySelector(selector)!.click(); + }, you_and_cordelia_selector); const cordelia_user_id = await common.get_user_id_from_name(page, "Cordelia, Lear's daughter"); const pm_list_selector = `li[data-user-ids-string="${cordelia_user_id}"].dm-list-item.active-sub-filter`; await page.waitForSelector(pm_list_selector, {visible: true}); diff --git a/web/e2e-tests/lib/common.ts b/web/e2e-tests/lib/common.ts index bc8cd64b90..1b16563ee2 100644 --- a/web/e2e-tests/lib/common.ts +++ b/web/e2e-tests/lib/common.ts @@ -269,7 +269,9 @@ export async function log_in( password: credentials.password, }; await fill_form(page, "form#login_form", params); - await page.$eval("form#login_form", (form) => form.submit()); + await page.$eval("form#login_form", (form) => { + form.submit(); + }); await page.waitForSelector("#inbox-main", {visible: true}); } diff --git a/web/e2e-tests/realm-creation.test.ts b/web/e2e-tests/realm-creation.test.ts index dac3d89bf7..5ca0777281 100644 --- a/web/e2e-tests/realm-creation.test.ts +++ b/web/e2e-tests/realm-creation.test.ts @@ -15,11 +15,15 @@ async function realm_creation_tests(page: Page): Promise { await page.waitForSelector("#email"); await page.type("#email", email); await page.type("#id_team_name", organization_name); - await page.$eval("input#realm_in_root_domain", (el) => el.click()); + await page.$eval("input#realm_in_root_domain", (el) => { + el.click(); + }); await Promise.all([ page.waitForNavigation(), - page.$eval("form#create_realm", (form) => form.submit()), + page.$eval("form#create_realm", (form) => { + form.submit(); + }), ]); // Make sure confirmation email is sent. @@ -59,7 +63,9 @@ async function realm_creation_tests(page: Page): Promise { // For some reason, page.click() does not work this for particular checkbox // so use page.$eval here to call the .click method in the browser. await common.fill_form(page, "#registration", params); - await page.$eval("form#registration", (form) => form.submit()); + await page.$eval("form#registration", (form) => { + form.submit(); + }); // Check if realm is created and user is logged in by checking if // element of id `lightbox_overlay` exists. diff --git a/web/e2e-tests/realm-playground.test.ts b/web/e2e-tests/realm-playground.test.ts index b80699ae16..7e03af2dd4 100644 --- a/web/e2e-tests/realm-playground.test.ts +++ b/web/e2e-tests/realm-playground.test.ts @@ -20,7 +20,9 @@ async function _add_playground_and_return_status(page: Page, payload: Playground await common.fill_form(page, "form.admin-playground-form", payload); // Not sure why, but page.click() doesn't seem to always click the submit button. // So we resort to using eval with the button ID instead. - await page.$eval("button#submit_playground_button", (el) => el.click()); + await page.$eval("button#submit_playground_button", (el) => { + el.click(); + }); // We return the success/failure status message back to the caller. await page.waitForSelector(admin_playground_status_selector, {visible: true}); diff --git a/web/e2e-tests/user-status.test.ts b/web/e2e-tests/user-status.test.ts index f89a923a55..fa11dfb7c7 100644 --- a/web/e2e-tests/user-status.test.ts +++ b/web/e2e-tests/user-status.test.ts @@ -17,9 +17,9 @@ async function open_set_user_status_modal(page: Page): Promise { }); await page.waitForSelector(".user_popover_email", {visible: true}); // We are using evaluate to click because it is very hard to detect if the user info popover has opened. - await page.evaluate(() => - document.querySelector(".update_status_text")!.click(), - ); + await page.evaluate(() => { + document.querySelector(".update_status_text")!.click(); + }); // Wait for the modal to completely open. await common.wait_for_micromodal_to_open(page); diff --git a/web/src/attachments_ui.ts b/web/src/attachments_ui.ts index e265fac3de..05530fbd5d 100644 --- a/web/src/attachments_ui.ts +++ b/web/src/attachments_ui.ts @@ -99,8 +99,9 @@ function delete_attachments(attachment: string, file_name: string): void { html_submit_button: $t_html({defaultMessage: "Delete"}), id: "confirm_delete_file_modal", focus_submit_on_open: true, - on_click: () => - dialog_widget.submit_api_request(channel.del, "/json/attachments/" + attachment), + on_click() { + dialog_widget.submit_api_request(channel.del, "/json/attachments/" + attachment); + }, loading_spinner: true, }); } diff --git a/web/src/avatar.ts b/web/src/avatar.ts index 608774b7c5..57d94c4dee 100644 --- a/web/src/avatar.ts +++ b/web/src/avatar.ts @@ -83,7 +83,7 @@ export function build_user_avatar_widget(upload_function: UploadFunction): void } if (!settings_data.user_can_change_avatar) { - return undefined; + return; } $("#user-avatar-upload-widget .image-delete-button").on("click", (e) => { @@ -116,7 +116,7 @@ export function build_user_avatar_widget(upload_function: UploadFunction): void }); }); - return upload_widget.build_direct_upload_widget( + upload_widget.build_direct_upload_widget( get_file_input, $("#user-avatar-upload-widget .image_file_input_error").expectOne(), $("#user-avatar-upload-widget .image_upload_button").expectOne(), diff --git a/web/src/billing/billing.ts b/web/src/billing/billing.ts index e72919a808..052c74469c 100644 --- a/web/src/billing/billing.ts +++ b/web/src/billing/billing.ts @@ -184,11 +184,12 @@ export function initialize(): void { "planchange", [], "PATCH", - () => + () => { window.location.replace( `${billing_base_url}/upgrade/?success_message=` + encodeURIComponent("Your plan is no longer scheduled for an upgrade."), - ), + ); + }, ); e.preventDefault(); }); @@ -216,11 +217,12 @@ export function initialize(): void { "planchange", [], "PATCH", - () => + () => { window.location.replace( `${billing_base_url}/billing/?success_message=` + encodeURIComponent("Your plan has been canceled and will not renew."), - ), + ); + }, ); e.preventDefault(); }); @@ -231,13 +233,14 @@ export function initialize(): void { "planchange", [], "PATCH", - () => + () => { window.location.replace( `${billing_base_url}/billing/?success_message=` + encodeURIComponent( "Your plan has been reactivated and will renew automatically.", ), - ), + ); + }, ); e.preventDefault(); }); @@ -248,13 +251,14 @@ export function initialize(): void { "planchange", [], "PATCH", - () => + () => { window.location.replace( `${billing_base_url}/billing/?success_message=` + encodeURIComponent( "Your plan will be canceled at the end of the trial. Your card will not be charged.", ), - ), + ); + }, ); e.preventDefault(); }); diff --git a/web/src/blueslip.ts b/web/src/blueslip.ts index 899ff1489e..6a6a4d5949 100644 --- a/web/src/blueslip.ts +++ b/web/src/blueslip.ts @@ -31,7 +31,7 @@ function make_logger_func(name: "debug" | "log" | "info" | "warn" | "error") { } if (console[name] !== undefined) { - return console[name](...args); + console[name](...args); } }; } diff --git a/web/src/feedback_widget.ts b/web/src/feedback_widget.ts index a33265e88f..dca3aa76f5 100644 --- a/web/src/feedback_widget.ts +++ b/web/src/feedback_widget.ts @@ -56,7 +56,9 @@ const animate = { return; } - setTimeout(() => animate.maybe_close(), 100); + setTimeout(() => { + animate.maybe_close(); + }, 100); }, fadeOut() { if (!meta.opened) { @@ -86,7 +88,9 @@ const animate = { if (meta.$container) { meta.$container.addClass("show-feedback-container"); meta.opened = true; - setTimeout(() => animate.maybe_close(), 100); + setTimeout(() => { + animate.maybe_close(); + }, 100); } }, }; diff --git a/web/src/input_pill.ts b/web/src/input_pill.ts index 72c8f50c9f..04149aca71 100644 --- a/web/src/input_pill.ts +++ b/web/src/input_pill.ts @@ -290,7 +290,8 @@ export function create(opts: InputPillCreateOptions): InputPillContainer submit_custom_emoji_request(formData), + on_click() { + submit_custom_emoji_request(formData); + }, }); }); } else { @@ -335,7 +337,9 @@ export function set_up(): void { html_heading: $t_html({defaultMessage: "Deactivate custom emoji?"}), html_body, id: "confirm_deactivate_custom_emoji_modal", - on_click: () => dialog_widget.submit_api_request(channel.del, url, {}, opts), + on_click() { + dialog_widget.submit_api_request(channel.del, url, {}, opts); + }, loading_spinner: true, }); }); diff --git a/web/src/settings_exports.ts b/web/src/settings_exports.ts index f96793d4be..390f194c15 100644 --- a/web/src/settings_exports.ts +++ b/web/src/settings_exports.ts @@ -155,7 +155,9 @@ export function set_up(): void { confirm_dialog.launch({ html_heading: $t_html({defaultMessage: "Delete data export?"}), html_body, - on_click: () => dialog_widget.submit_api_request(channel.del, url), + on_click() { + dialog_widget.submit_api_request(channel.del, url); + }, loading_spinner: true, }); });