mirror of
				https://github.com/zulip/zulip.git
				synced 2025-10-31 12:03:46 +00:00 
			
		
		
		
	eslint: Fix @typescript-eslint/prefer-nullish-coalescing.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
		
				
					committed by
					
						 Tim Abbott
						Tim Abbott
					
				
			
			
				
	
			
			
			
						parent
						
							b280843e51
						
					
				
				
					commit
					60d49ae4a6
				
			| @@ -101,7 +101,7 @@ export class IterationProfiler { | ||||
|         if (diff > 1) { | ||||
|             this.sections.set( | ||||
|                 "_rest_of_iteration", | ||||
|                 (this.sections.get("_rest_of_iteration") || 0) + diff, | ||||
|                 (this.sections.get("_rest_of_iteration") ?? 0) + diff, | ||||
|             ); | ||||
|         } | ||||
|         this.last_time = now; | ||||
| @@ -109,7 +109,7 @@ export class IterationProfiler { | ||||
|  | ||||
|     section(label: string): void { | ||||
|         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; | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -121,7 +121,7 @@ export function launch(conf: WidgetConfig): void { | ||||
|     // * loading_spinner: Whether to show a loading spinner inside the | ||||
|     //   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({ | ||||
|         heading_text: conf.html_heading, | ||||
|         link: conf.help_link, | ||||
|   | ||||
| @@ -204,7 +204,7 @@ function build_emojis_by_name({ | ||||
|                 const emoji_dict: EmojiDict = { | ||||
|                     name: emoji_name, | ||||
|                     display_name: emoji_name, | ||||
|                     aliases: default_emoji_aliases.get(codepoint) || [], | ||||
|                     aliases: default_emoji_aliases.get(codepoint) ?? [], | ||||
|                     is_realm_emoji: false, | ||||
|                     emoji_code: codepoint, | ||||
|                     has_reacted: false, | ||||
|   | ||||
| @@ -37,6 +37,6 @@ export function is_enter_event(event: JQuery.KeyDownEvent): boolean { | ||||
|     // phonetic input method like ZhuYin in a character-based | ||||
|     // language. See #22062 for details. Further reading: | ||||
|     // 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"; | ||||
| } | ||||
|   | ||||
| @@ -110,7 +110,7 @@ export function open_overlay(opts: OverlayOptions): void { | ||||
|     if (active_overlay || open_overlay_name) { | ||||
|         blueslip.error( | ||||
|             `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); | ||||
|  | ||||
|     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; | ||||
|     } | ||||
|  | ||||
| @@ -304,7 +304,7 @@ export function close_modal(modal_id: string, conf: Pick<ModalConfig, "on_hidden | ||||
|  | ||||
|     if (active_modal() !== `#${CSS.escape(modal_id)}`) { | ||||
|         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; | ||||
|     } | ||||
| @@ -335,7 +335,7 @@ export function close_active_modal(): void { | ||||
|     } | ||||
|  | ||||
|     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 { | ||||
|   | ||||
| @@ -26,7 +26,7 @@ $(() => { | ||||
|     // In case user presses `back` with menu open. | ||||
|     // See https://github.com/zulip/zulip/pull/24301#issuecomment-1418547337. | ||||
|     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); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -48,7 +48,7 @@ const loaded_repos: string[] = []; | ||||
| function calculate_total_commits(contributor: Contributor): number { | ||||
|     let commits = 0; | ||||
|     for (const repo_name of all_repository_names) { | ||||
|         commits += contributor[repo_name] || 0; | ||||
|         commits += contributor[repo_name] ?? 0; | ||||
|     } | ||||
|     return commits; | ||||
| } | ||||
| @@ -132,11 +132,11 @@ export default function render_tabs(contributors: Contributor[]): void { | ||||
|  | ||||
|         $(`#${CSS.escape(tab_name)}`).on("click", () => { | ||||
|             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 | ||||
|                     .sort((a, b) => { | ||||
|                         const a_commits = a[repo_name] || 0; | ||||
|                         const b_commits = b[repo_name] || 0; | ||||
|                         const a_commits = a[repo_name] ?? 0; | ||||
|                         const b_commits = b[repo_name] ?? 0; | ||||
|                         return a_commits < b_commits ? 1 : a_commits > b_commits ? -1 : 0; | ||||
|                     }) | ||||
|                     .map((c) => | ||||
| @@ -153,7 +153,7 @@ export default function render_tabs(contributors: Contributor[]): void { | ||||
|                 $(`#tab-${CSS.escape(tab_name)} .contributors-grid`).html(html); | ||||
|                 const contributor_count = filtered_by_repo.length; | ||||
|                 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; | ||||
|                 }).length; | ||||
|                 const repo_url = `https://github.com/zulip/${repo_name}`; | ||||
|   | ||||
| @@ -46,7 +46,7 @@ if (page_params.server_sentry_dsn) { | ||||
|  | ||||
|     Sentry.init({ | ||||
|         dsn: page_params.server_sentry_dsn, | ||||
|         environment: page_params.server_sentry_environment || "development", | ||||
|         environment: page_params.server_sentry_environment ?? "development", | ||||
|         tunnel: "/error_tracing", | ||||
|  | ||||
|         release: "zulip-server@" + ZULIP_VERSION, | ||||
| @@ -56,8 +56,8 @@ if (page_params.server_sentry_dsn) { | ||||
|             }), | ||||
|         ], | ||||
|         allowUrls: url_matches, | ||||
|         sampleRate: page_params.server_sentry_sample_rate || 0, | ||||
|         tracesSampleRate: page_params.server_sentry_trace_rate || 0, | ||||
|         sampleRate: page_params.server_sentry_sample_rate ?? 0, | ||||
|         tracesSampleRate: page_params.server_sentry_trace_rate ?? 0, | ||||
|         initialScope: { | ||||
|             tags: { | ||||
|                 realm: sentry_key, | ||||
|   | ||||
| @@ -1,7 +1,7 @@ | ||||
| import $ from "jquery"; | ||||
|  | ||||
| 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 | ||||
|     // frame to allow CSS transition animation to work | ||||
|   | ||||
| @@ -18,7 +18,7 @@ function get_key(group: number[]): string { | ||||
|  | ||||
| export function add_typist(group: number[], typist: number): void { | ||||
|     const key = get_key(group); | ||||
|     const current = typist_dct.get(key) || []; | ||||
|     const current = typist_dct.get(key) ?? []; | ||||
|     if (!current.includes(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 { | ||||
|     const key = get_key(group); | ||||
|     let current = typist_dct.get(key) || []; | ||||
|     let current = typist_dct.get(key) ?? []; | ||||
|  | ||||
|     if (!current.includes(typist)) { | ||||
|         return false; | ||||
| @@ -41,7 +41,7 @@ export function remove_typist(group: number[], typist: number): boolean { | ||||
|  | ||||
| export function get_group_typists(group: number[]): number[] { | ||||
|     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); | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -198,7 +198,7 @@ export default ( | ||||
|         }, | ||||
|         plugins: [ | ||||
|             new DefinePlugin({ | ||||
|                 ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION || "development"), | ||||
|                 ZULIP_VERSION: JSON.stringify(env.ZULIP_VERSION ?? "development"), | ||||
|             }), | ||||
|             new DebugRequirePlugin(), | ||||
|             new BundleTracker({ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user