eslint: Fix @typescript-eslint/no-confusing-void-expression.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-12-21 16:00:27 -08:00
parent 3fde4f977d
commit 6368cf17cb
16 changed files with 66 additions and 40 deletions

View File

@ -60,16 +60,17 @@ export default class DebugRequirePlugin implements WebpackPluginInstance {
"DebugRequirePlugin", "DebugRequirePlugin",
async ({normalModuleFactory}) => { async ({normalModuleFactory}) => {
const resolver = normalModuleFactory.getResolver("normal"); const resolver = normalModuleFactory.getResolver("normal");
debugRequirePath = await new Promise((resolve) => debugRequirePath = await new Promise((resolve) => {
resolver.resolve( resolver.resolve(
{}, {},
__dirname, __dirname,
"./debug-require", "./debug-require",
{}, {},
(err?: Error | null, result?: string | false) => (err?: Error | null, result?: string | false) => {
resolve(err ? false : result!), resolve(err ? false : result!);
), },
); );
});
}, },
); );

View File

@ -112,10 +112,9 @@ async function test_narrow_to_private_messages_with_cordelia(page: Page): Promis
const you_and_cordelia_selector = const you_and_cordelia_selector =
'*[data-tippy-content="Go to direct messages with Cordelia, Lear\'s daughter"]'; '*[data-tippy-content="Go to direct messages with Cordelia, Lear\'s daughter"]';
// For some unknown reason page.click() isn't working here. // For some unknown reason page.click() isn't working here.
await page.evaluate( await page.evaluate((selector: string) => {
(selector: string) => document.querySelector<HTMLElement>(selector)!.click(), document.querySelector<HTMLElement>(selector)!.click();
you_and_cordelia_selector, }, you_and_cordelia_selector);
);
const cordelia_user_id = await common.get_user_id_from_name(page, "Cordelia, Lear's daughter"); 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`; 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}); await page.waitForSelector(pm_list_selector, {visible: true});

View File

@ -269,7 +269,9 @@ export async function log_in(
password: credentials.password, password: credentials.password,
}; };
await fill_form(page, "form#login_form", params); 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}); await page.waitForSelector("#inbox-main", {visible: true});
} }

View File

@ -15,11 +15,15 @@ async function realm_creation_tests(page: Page): Promise<void> {
await page.waitForSelector("#email"); await page.waitForSelector("#email");
await page.type("#email", email); await page.type("#email", email);
await page.type("#id_team_name", organization_name); 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([ await Promise.all([
page.waitForNavigation(), page.waitForNavigation(),
page.$eval("form#create_realm", (form) => form.submit()), page.$eval("form#create_realm", (form) => {
form.submit();
}),
]); ]);
// Make sure confirmation email is sent. // Make sure confirmation email is sent.
@ -59,7 +63,9 @@ async function realm_creation_tests(page: Page): Promise<void> {
// For some reason, page.click() does not work this for particular checkbox // 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. // so use page.$eval here to call the .click method in the browser.
await common.fill_form(page, "#registration", params); 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 // Check if realm is created and user is logged in by checking if
// element of id `lightbox_overlay` exists. // element of id `lightbox_overlay` exists.

View File

@ -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); 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. // 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. // 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. // We return the success/failure status message back to the caller.
await page.waitForSelector(admin_playground_status_selector, {visible: true}); await page.waitForSelector(admin_playground_status_selector, {visible: true});

View File

@ -17,9 +17,9 @@ async function open_set_user_status_modal(page: Page): Promise<void> {
}); });
await page.waitForSelector(".user_popover_email", {visible: true}); 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. // We are using evaluate to click because it is very hard to detect if the user info popover has opened.
await page.evaluate(() => await page.evaluate(() => {
document.querySelector<HTMLAnchorElement>(".update_status_text")!.click(), document.querySelector<HTMLAnchorElement>(".update_status_text")!.click();
); });
// Wait for the modal to completely open. // Wait for the modal to completely open.
await common.wait_for_micromodal_to_open(page); await common.wait_for_micromodal_to_open(page);

View File

@ -99,8 +99,9 @@ function delete_attachments(attachment: string, file_name: string): void {
html_submit_button: $t_html({defaultMessage: "Delete"}), html_submit_button: $t_html({defaultMessage: "Delete"}),
id: "confirm_delete_file_modal", id: "confirm_delete_file_modal",
focus_submit_on_open: true, focus_submit_on_open: true,
on_click: () => on_click() {
dialog_widget.submit_api_request(channel.del, "/json/attachments/" + attachment), dialog_widget.submit_api_request(channel.del, "/json/attachments/" + attachment);
},
loading_spinner: true, loading_spinner: true,
}); });
} }

View File

@ -83,7 +83,7 @@ export function build_user_avatar_widget(upload_function: UploadFunction): void
} }
if (!settings_data.user_can_change_avatar) { if (!settings_data.user_can_change_avatar) {
return undefined; return;
} }
$("#user-avatar-upload-widget .image-delete-button").on("click", (e) => { $("#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, get_file_input,
$("#user-avatar-upload-widget .image_file_input_error").expectOne(), $("#user-avatar-upload-widget .image_file_input_error").expectOne(),
$("#user-avatar-upload-widget .image_upload_button").expectOne(), $("#user-avatar-upload-widget .image_upload_button").expectOne(),

View File

@ -184,11 +184,12 @@ export function initialize(): void {
"planchange", "planchange",
[], [],
"PATCH", "PATCH",
() => () => {
window.location.replace( window.location.replace(
`${billing_base_url}/upgrade/?success_message=` + `${billing_base_url}/upgrade/?success_message=` +
encodeURIComponent("Your plan is no longer scheduled for an upgrade."), encodeURIComponent("Your plan is no longer scheduled for an upgrade."),
), );
},
); );
e.preventDefault(); e.preventDefault();
}); });
@ -216,11 +217,12 @@ export function initialize(): void {
"planchange", "planchange",
[], [],
"PATCH", "PATCH",
() => () => {
window.location.replace( window.location.replace(
`${billing_base_url}/billing/?success_message=` + `${billing_base_url}/billing/?success_message=` +
encodeURIComponent("Your plan has been canceled and will not renew."), encodeURIComponent("Your plan has been canceled and will not renew."),
), );
},
); );
e.preventDefault(); e.preventDefault();
}); });
@ -231,13 +233,14 @@ export function initialize(): void {
"planchange", "planchange",
[], [],
"PATCH", "PATCH",
() => () => {
window.location.replace( window.location.replace(
`${billing_base_url}/billing/?success_message=` + `${billing_base_url}/billing/?success_message=` +
encodeURIComponent( encodeURIComponent(
"Your plan has been reactivated and will renew automatically.", "Your plan has been reactivated and will renew automatically.",
), ),
), );
},
); );
e.preventDefault(); e.preventDefault();
}); });
@ -248,13 +251,14 @@ export function initialize(): void {
"planchange", "planchange",
[], [],
"PATCH", "PATCH",
() => () => {
window.location.replace( window.location.replace(
`${billing_base_url}/billing/?success_message=` + `${billing_base_url}/billing/?success_message=` +
encodeURIComponent( encodeURIComponent(
"Your plan will be canceled at the end of the trial. Your card will not be charged.", "Your plan will be canceled at the end of the trial. Your card will not be charged.",
), ),
), );
},
); );
e.preventDefault(); e.preventDefault();
}); });

View File

@ -31,7 +31,7 @@ function make_logger_func(name: "debug" | "log" | "info" | "warn" | "error") {
} }
if (console[name] !== undefined) { if (console[name] !== undefined) {
return console[name](...args); console[name](...args);
} }
}; };
} }

View File

@ -56,7 +56,9 @@ const animate = {
return; return;
} }
setTimeout(() => animate.maybe_close(), 100); setTimeout(() => {
animate.maybe_close();
}, 100);
}, },
fadeOut() { fadeOut() {
if (!meta.opened) { if (!meta.opened) {
@ -86,7 +88,9 @@ const animate = {
if (meta.$container) { if (meta.$container) {
meta.$container.addClass("show-feedback-container"); meta.$container.addClass("show-feedback-container");
meta.opened = true; meta.opened = true;
setTimeout(() => animate.maybe_close(), 100); setTimeout(() => {
animate.maybe_close();
}, 100);
} }
}, },
}; };

View File

@ -290,7 +290,8 @@ export function create<T>(opts: InputPillCreateOptions<T>): InputPillContainer<T
createPillonPaste() { createPillonPaste() {
if (store.createPillonPaste !== undefined) { if (store.createPillonPaste !== undefined) {
return store.createPillonPaste(); store.createPillonPaste();
return undefined;
} }
return true; return true;
}, },

View File

@ -11,7 +11,7 @@ export function build_realm_icon_widget(upload_function: UploadFunction): void {
}; };
if (!page_params.is_admin) { if (!page_params.is_admin) {
return undefined; return;
} }
if (page_params.realm_icon_source === "G") { if (page_params.realm_icon_source === "G") {
$("#realm-icon-upload-widget .image-delete-button").hide(); $("#realm-icon-upload-widget .image-delete-button").hide();
@ -26,7 +26,7 @@ export function build_realm_icon_widget(upload_function: UploadFunction): void {
}); });
}); });
return upload_widget.build_direct_upload_widget( upload_widget.build_direct_upload_widget(
get_file_input, get_file_input,
$("#realm-icon-upload-widget .image_file_input_error").expectOne(), $("#realm-icon-upload-widget .image_file_input_error").expectOne(),
$("#realm-icon-upload-widget .image_upload_button").expectOne(), $("#realm-icon-upload-widget .image_upload_button").expectOne(),

View File

@ -26,7 +26,7 @@ export function build_realm_logo_widget(upload_function: UploadFunction, is_nigh
}; };
if (!page_params.is_admin) { if (!page_params.is_admin) {
return undefined; return;
} }
if (logo_source === "D") { if (logo_source === "D") {
@ -45,7 +45,7 @@ export function build_realm_logo_widget(upload_function: UploadFunction, is_nigh
}); });
}); });
return upload_widget.build_direct_upload_widget( upload_widget.build_direct_upload_widget(
get_file_input, get_file_input,
$file_input_error_elem.expectOne(), $file_input_error_elem.expectOne(),
$upload_button_elem.expectOne(), $upload_button_elem.expectOne(),

View File

@ -288,7 +288,9 @@ function show_modal(): void {
confirm_dialog.launch({ confirm_dialog.launch({
html_heading: $t_html({defaultMessage: "Override default emoji?"}), html_heading: $t_html({defaultMessage: "Override default emoji?"}),
html_body, html_body,
on_click: () => submit_custom_emoji_request(formData), on_click() {
submit_custom_emoji_request(formData);
},
}); });
}); });
} else { } else {
@ -335,7 +337,9 @@ export function set_up(): void {
html_heading: $t_html({defaultMessage: "Deactivate custom emoji?"}), html_heading: $t_html({defaultMessage: "Deactivate custom emoji?"}),
html_body, html_body,
id: "confirm_deactivate_custom_emoji_modal", 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, loading_spinner: true,
}); });
}); });

View File

@ -155,7 +155,9 @@ export function set_up(): void {
confirm_dialog.launch({ confirm_dialog.launch({
html_heading: $t_html({defaultMessage: "Delete data export?"}), html_heading: $t_html({defaultMessage: "Delete data export?"}),
html_body, 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, loading_spinner: true,
}); });
}); });