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

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-04-19 15:50:38 -07:00 committed by Tim Abbott
parent b280843e51
commit 60d49ae4a6
11 changed files with 23 additions and 23 deletions

View File

@ -101,7 +101,7 @@ export class IterationProfiler {
if (diff > 1) { if (diff > 1) {
this.sections.set( this.sections.set(
"_rest_of_iteration", "_rest_of_iteration",
(this.sections.get("_rest_of_iteration") || 0) + diff, (this.sections.get("_rest_of_iteration") ?? 0) + diff,
); );
} }
this.last_time = now; this.last_time = now;
@ -109,7 +109,7 @@ export class IterationProfiler {
section(label: string): void { section(label: string): void {
const now = window.performance.now(); const now = window.performance.now();
this.sections.set(label, (this.sections.get(label) || 0) + (now - this.last_time)); this.sections.set(label, (this.sections.get(label) ?? 0) + (now - this.last_time));
this.last_time = now; this.last_time = now;
} }

View File

@ -121,7 +121,7 @@ export function launch(conf: WidgetConfig): void {
// * loading_spinner: Whether to show a loading spinner inside the // * loading_spinner: Whether to show a loading spinner inside the
// submit button when clicked. // submit button when clicked.
const html_submit_button = conf.html_submit_button || $t_html({defaultMessage: "Save changes"}); const html_submit_button = conf.html_submit_button ?? $t_html({defaultMessage: "Save changes"});
const html = render_dialog_widget({ const html = render_dialog_widget({
heading_text: conf.html_heading, heading_text: conf.html_heading,
link: conf.help_link, link: conf.help_link,

View File

@ -204,7 +204,7 @@ function build_emojis_by_name({
const emoji_dict: EmojiDict = { const emoji_dict: EmojiDict = {
name: emoji_name, name: emoji_name,
display_name: emoji_name, display_name: emoji_name,
aliases: default_emoji_aliases.get(codepoint) || [], aliases: default_emoji_aliases.get(codepoint) ?? [],
is_realm_emoji: false, is_realm_emoji: false,
emoji_code: codepoint, emoji_code: codepoint,
has_reacted: false, has_reacted: false,

View File

@ -37,6 +37,6 @@ export function is_enter_event(event: JQuery.KeyDownEvent): boolean {
// phonetic input method like ZhuYin in a character-based // phonetic input method like ZhuYin in a character-based
// language. See #22062 for details. Further reading: // language. See #22062 for details. Further reading:
// https://developer.mozilla.org/en-US/docs/Glossary/Input_method_editor // https://developer.mozilla.org/en-US/docs/Glossary/Input_method_editor
const isComposing: boolean = event.originalEvent?.isComposing || false; const isComposing = event.originalEvent?.isComposing ?? false;
return !isComposing && event.key === "Enter"; return !isComposing && event.key === "Enter";
} }

View File

@ -110,7 +110,7 @@ export function open_overlay(opts: OverlayOptions): void {
if (active_overlay || open_overlay_name) { if (active_overlay || open_overlay_name) {
blueslip.error( blueslip.error(
`Programming error - trying to open ${opts.name} before closing ${ `Programming error - trying to open ${opts.name} before closing ${
open_overlay_name || "undefined" open_overlay_name ?? "undefined"
}`, }`,
); );
@ -255,7 +255,7 @@ export function close_overlay(name: string): void {
call_hooks(pre_close_hooks); call_hooks(pre_close_hooks);
if (name !== open_overlay_name) { if (name !== open_overlay_name) {
blueslip.error(`Trying to close ${name} when ${open_overlay_name || "undefined"} is open.`); blueslip.error(`Trying to close ${name} when ${open_overlay_name ?? "undefined"} is open.`);
return; return;
} }
@ -304,7 +304,7 @@ export function close_modal(modal_id: string, conf: Pick<ModalConfig, "on_hidden
if (active_modal() !== `#${CSS.escape(modal_id)}`) { if (active_modal() !== `#${CSS.escape(modal_id)}`) {
blueslip.error( blueslip.error(
`Trying to close ${modal_id} modal when ${active_modal() || "undefined"} is open.`, `Trying to close ${modal_id} modal when ${active_modal() ?? "undefined"} is open.`,
); );
return; return;
} }
@ -335,7 +335,7 @@ export function close_active_modal(): void {
} }
const $micromodal = $(".micromodal.modal--open"); const $micromodal = $(".micromodal.modal--open");
Micromodal.close(`${CSS.escape($micromodal.attr("id") || "")}`); Micromodal.close(`${CSS.escape($micromodal.attr("id") ?? "")}`);
} }
export function close_for_hash_change(): void { export function close_for_hash_change(): void {

View File

@ -26,7 +26,7 @@ $(() => {
// In case user presses `back` with menu open. // In case user presses `back` with menu open.
// See https://github.com/zulip/zulip/pull/24301#issuecomment-1418547337. // See https://github.com/zulip/zulip/pull/24301#issuecomment-1418547337.
if ($(".top-menu-tab-input:checked").length === 1) { if ($(".top-menu-tab-input:checked").length === 1) {
const sub_menu_height = $(".top-menu-tab-input:checked ~ .top-menu-submenu").height() || 0; const sub_menu_height = $(".top-menu-tab-input:checked ~ .top-menu-submenu").height() ?? 0;
$("#top-menu-submenu-backdrop").css("height", sub_menu_height + 16); $("#top-menu-submenu-backdrop").css("height", sub_menu_height + 16);
} }

View File

@ -48,7 +48,7 @@ const loaded_repos: string[] = [];
function calculate_total_commits(contributor: Contributor): number { function calculate_total_commits(contributor: Contributor): number {
let commits = 0; let commits = 0;
for (const repo_name of all_repository_names) { for (const repo_name of all_repository_names) {
commits += contributor[repo_name] || 0; commits += contributor[repo_name] ?? 0;
} }
return commits; return commits;
} }
@ -132,11 +132,11 @@ export default function render_tabs(contributors: Contributor[]): void {
$(`#${CSS.escape(tab_name)}`).on("click", () => { $(`#${CSS.escape(tab_name)}`).on("click", () => {
if (!loaded_repos.includes(repo_name)) { if (!loaded_repos.includes(repo_name)) {
const filtered_by_repo = contributors_list.filter((c) => c[repo_name] || 0); const filtered_by_repo = contributors_list.filter((c) => c[repo_name] ?? 0);
const html = filtered_by_repo const html = filtered_by_repo
.sort((a, b) => { .sort((a, b) => {
const a_commits = a[repo_name] || 0; const a_commits = a[repo_name] ?? 0;
const b_commits = b[repo_name] || 0; const b_commits = b[repo_name] ?? 0;
return a_commits < b_commits ? 1 : a_commits > b_commits ? -1 : 0; return a_commits < b_commits ? 1 : a_commits > b_commits ? -1 : 0;
}) })
.map((c) => .map((c) =>
@ -153,7 +153,7 @@ export default function render_tabs(contributors: Contributor[]): void {
$(`#tab-${CSS.escape(tab_name)} .contributors-grid`).html(html); $(`#tab-${CSS.escape(tab_name)} .contributors-grid`).html(html);
const contributor_count = filtered_by_repo.length; const contributor_count = filtered_by_repo.length;
const hundred_plus_contributor_count = filtered_by_repo.filter((c) => { const hundred_plus_contributor_count = filtered_by_repo.filter((c) => {
const commits = c[repo_name] || 0; const commits = c[repo_name] ?? 0;
return commits >= 100; return commits >= 100;
}).length; }).length;
const repo_url = `https://github.com/zulip/${repo_name}`; const repo_url = `https://github.com/zulip/${repo_name}`;

View File

@ -46,7 +46,7 @@ if (page_params.server_sentry_dsn) {
Sentry.init({ Sentry.init({
dsn: page_params.server_sentry_dsn, dsn: page_params.server_sentry_dsn,
environment: page_params.server_sentry_environment || "development", environment: page_params.server_sentry_environment ?? "development",
tunnel: "/error_tracing", tunnel: "/error_tracing",
release: "zulip-server@" + ZULIP_VERSION, release: "zulip-server@" + ZULIP_VERSION,
@ -56,8 +56,8 @@ if (page_params.server_sentry_dsn) {
}), }),
], ],
allowUrls: url_matches, allowUrls: url_matches,
sampleRate: page_params.server_sentry_sample_rate || 0, sampleRate: page_params.server_sentry_sample_rate ?? 0,
tracesSampleRate: page_params.server_sentry_trace_rate || 0, tracesSampleRate: page_params.server_sentry_trace_rate ?? 0,
initialScope: { initialScope: {
tags: { tags: {
realm: sentry_key, realm: sentry_key,

View File

@ -1,7 +1,7 @@
import $ from "jquery"; import $ from "jquery";
function collapse_spoiler($spoiler: JQuery): void { function collapse_spoiler($spoiler: JQuery): void {
const spoiler_height = $spoiler.height() || 0; const spoiler_height = $spoiler.height() ?? 0;
// Set height to rendered height on next frame, then to zero on following // Set height to rendered height on next frame, then to zero on following
// frame to allow CSS transition animation to work // frame to allow CSS transition animation to work

View File

@ -18,7 +18,7 @@ function get_key(group: number[]): string {
export function add_typist(group: number[], typist: number): void { export function add_typist(group: number[], typist: number): void {
const key = get_key(group); const key = get_key(group);
const current = typist_dct.get(key) || []; const current = typist_dct.get(key) ?? [];
if (!current.includes(typist)) { if (!current.includes(typist)) {
current.push(typist); current.push(typist);
} }
@ -27,7 +27,7 @@ export function add_typist(group: number[], typist: number): void {
export function remove_typist(group: number[], typist: number): boolean { export function remove_typist(group: number[], typist: number): boolean {
const key = get_key(group); const key = get_key(group);
let current = typist_dct.get(key) || []; let current = typist_dct.get(key) ?? [];
if (!current.includes(typist)) { if (!current.includes(typist)) {
return false; return false;
@ -41,7 +41,7 @@ export function remove_typist(group: number[], typist: number): boolean {
export function get_group_typists(group: number[]): number[] { export function get_group_typists(group: number[]): number[] {
const key = get_key(group); const key = get_key(group);
const user_ids = typist_dct.get(key) || []; const user_ids = typist_dct.get(key) ?? [];
return muted_users.filter_muted_user_ids(user_ids); return muted_users.filter_muted_user_ids(user_ids);
} }

View File

@ -198,7 +198,7 @@ export default (
}, },
plugins: [ plugins: [
new DefinePlugin({ new DefinePlugin({
ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION || "development"), ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION ?? "development"),
}), }),
new DebugRequirePlugin(), new DebugRequirePlugin(),
new BundleTracker({ new BundleTracker({