Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

eslint: Fix @typescript-eslint/prefer-nullish-coalescing.

Anders Kaseorg3d55e7ef1032
diff --git a/web/src/blueslip.ts b/web/src/blueslip.ts
index 6a6a4d59490..bdeeedf27ba 100644
--- a/web/src/blueslip.ts
+++ b/web/src/blueslip.ts
@@ -89,7 +89,7 @@ export function warn(msg: string, more_info?: unknown): void {
export function error(msg: string, more_info?: object | undefined, original_error?: unknown): void {
// Log the Sentry error before the console warning, so we don't
// end up with a doubled message in the Sentry logs.
- Sentry.setContext("more_info", more_info === undefined ? null : more_info);
+ Sentry.setContext("more_info", more_info ?? null);
// Note that original_error could be of any type, because you can "raise"
// any type -- something we do see in practice with the error
diff --git a/web/src/browser_history.ts b/web/src/browser_history.ts
index 2b23e2415d0..16d90a9e569 100644
--- a/web/src/browser_history.ts
+++ b/web/src/browser_history.ts
@@ -82,6 +82,7 @@ export function update(new_hash: string): void {
export function exit_overlay(): void {
if (hash_parser.is_overlay_hash(window.location.hash) && !state.changing_hash) {
ui_util.blur_active_element();
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
const new_hash = state.hash_before_overlay || `#${user_settings.web_home_view}`;
update(new_hash);
}
diff --git a/web/src/compose_call.ts b/web/src/compose_call.ts
index c39d5992c16..cc3c6cad8a5 100644
--- a/web/src/compose_call.ts
+++ b/web/src/compose_call.ts
@@ -35,7 +35,7 @@ export function compute_show_audio_chat_button(): boolean {
const available_providers = page_params.realm_available_video_chat_providers;
if (
(available_providers.jitsi_meet &&
- get_jitsi_server_url() &&
+ get_jitsi_server_url() !== null &&
page_params.realm_video_chat_provider === available_providers.jitsi_meet.id) ||
(available_providers.zoom &&
page_params.realm_video_chat_provider === available_providers.zoom.id)
diff --git a/web/src/compose_state.ts b/web/src/compose_state.ts
index fd69b98ec85..abfea4f0faf 100644
--- a/web/src/compose_state.ts
+++ b/web/src/compose_state.ts
@@ -104,7 +104,7 @@ export function stream_id(): number | undefined {
export function stream_name(): string {
const stream_id = selected_recipient_id;
if (typeof stream_id === "number") {
- return sub_store.maybe_get_stream_name(stream_id) || "";
+ return sub_store.maybe_get_stream_name(stream_id) ?? "";
}
return "";
}
diff --git a/web/src/message_store.ts b/web/src/message_store.ts
index dfe6f6b9053..726f96bd1a9 100644
--- a/web/src/message_store.ts
+++ b/web/src/message_store.ts
@@ -194,7 +194,7 @@ export function get_pm_full_names(message: Message): string {
}
export function set_message_booleans(message: Message): void {
- const flags = message.flags || [];
+ const flags = message.flags ?? [];
function convert_flag(flag_name: string): boolean {
return flags.includes(flag_name);
diff --git a/web/src/overlays.ts b/web/src/overlays.ts
index a0d204bff22..428dc254676 100644
--- a/web/src/overlays.ts
+++ b/web/src/overlays.ts
@@ -81,7 +81,7 @@ export function open_overlay(opts: OverlayOptions): void {
return;
}
- if (active_overlay || open_overlay_name) {
+ if (active_overlay !== undefined || open_overlay_name) {
blueslip.error("Programming error - trying to open overlay before closing other", {
name: opts.name,
open_overlay_name,
diff --git a/web/src/people.ts b/web/src/people.ts
index fe5d6b24b33..32b9be15271 100644
--- a/web/src/people.ts
+++ b/web/src/people.ts
@@ -190,7 +190,7 @@ export function get_bot_owner_user(user: User & {is_bot: true}): User | undefine
export function can_admin_user(user: User): boolean {
return (
- (user.is_bot && user.bot_owner_id && user.bot_owner_id === page_params.user_id) ||
+ (user.is_bot && user.bot_owner_id !== null && user.bot_owner_id === page_params.user_id) ||
is_my_user_id(user.user_id)
);
}
diff --git a/web/src/presence.ts b/web/src/presence.ts
index 3fc749b0ca8..651f2217821 100644
--- a/web/src/presence.ts
+++ b/web/src/presence.ts
@@ -75,8 +75,8 @@ export function status_from_raw(raw: RawPresence): PresenceStatus {
/* Mark users as offline after this many seconds since their last checkin, */
const offline_threshold_secs = page_params.server_presence_offline_threshold_seconds;
- function age(timestamp?: number): number {
- return raw.server_timestamp - (timestamp || 0);
+ function age(timestamp = 0): number {
+ return raw.server_timestamp - timestamp;
}
const active_timestamp = raw.active_timestamp;
@@ -84,7 +84,7 @@ export function status_from_raw(raw: RawPresence): PresenceStatus {
let last_active: number | undefined;
if (active_timestamp !== undefined || idle_timestamp !== undefined) {
- last_active = Math.max(active_timestamp || 0, idle_timestamp || 0);
+ last_active = Math.max(active_timestamp ?? 0, idle_timestamp ?? 0);
}
/*
@@ -141,18 +141,18 @@ export function update_info_from_event(
server_timestamp: 1585745140
}
*/
- const raw = raw_info.get(user_id) || {
+ const raw = raw_info.get(user_id) ?? {
server_timestamp: 0,
};
raw.server_timestamp = server_timestamp;
for (const rec of Object.values(info)) {
- if (rec.status === "active" && rec.timestamp > (raw.active_timestamp || 0)) {
+ if (rec.status === "active" && rec.timestamp > (raw.active_timestamp ?? 0)) {
raw.active_timestamp = rec.timestamp;
}
- if (rec.status === "idle" && rec.timestamp > (raw.idle_timestamp || 0)) {
+ if (rec.status === "idle" && rec.timestamp > (raw.idle_timestamp ?? 0)) {
raw.idle_timestamp = rec.timestamp;
}
}
diff --git a/web/src/settings_emoji.ts b/web/src/settings_emoji.ts
index a6689ab9fbf..e61aaada269 100644
--- a/web/src/settings_emoji.ts
+++ b/web/src/settings_emoji.ts
@@ -130,7 +130,7 @@ export function populate_emoji(): void {
name: item.name,
display_name: item.name.replaceAll("_", " "),
source_url: item.source_url,
- author: item.author || "",
+ author: item.author ?? "",
can_delete_emoji: can_delete_emoji(item),
},
});