From 084771ce7461dc226010d4e97017be1a9d7eef97 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Wed, 19 Apr 2023 14:40:04 -0700 Subject: [PATCH] eslint: Fix @typescript-eslint/consistent-type-definitions. Signed-off-by: Anders Kaseorg --- .eslintrc.json | 1 + web/src/global.d.ts | 1 + web/src/message_parser.ts | 4 ++-- web/src/settings_config.ts | 8 ++++---- web/src/url-template.d.ts | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.eslintrc.json b/.eslintrc.json index c3cabcdac5..59326c9abf 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -171,6 +171,7 @@ "@typescript-eslint/array-type": "error", "@typescript-eslint/consistent-type-assertions": "error", + "@typescript-eslint/consistent-type-definitions": ["error", "type"], "@typescript-eslint/consistent-type-imports": "error", "@typescript-eslint/explicit-function-return-type": [ "error", diff --git a/web/src/global.d.ts b/web/src/global.d.ts index f40ae0dc17..7e38aacdf6 100644 --- a/web/src/global.d.ts +++ b/web/src/global.d.ts @@ -5,6 +5,7 @@ declare let zulip_test: any; // eslint-disable-line @typescript-eslint/no-explicit-any +// eslint-disable-next-line @typescript-eslint/consistent-type-definitions interface JQuery { expectOne(): JQuery; tab(action?: string): this; // From web/third/bootstrap diff --git a/web/src/message_parser.ts b/web/src/message_parser.ts index 85a6f3a64d..eb5c6d708b 100644 --- a/web/src/message_parser.ts +++ b/web/src/message_parser.ts @@ -3,9 +3,9 @@ import $ from "jquery"; // TODO: Move this to message_store when it is // converted to TypeScript. -interface Message { +type Message = { content: string; -} +}; // We need to check if the message content contains the specified HTML // elements. We wrap the message.content in a
; this is diff --git a/web/src/settings_config.ts b/web/src/settings_config.ts index aba18e4dc7..a7aa2f134c 100644 --- a/web/src/settings_config.ts +++ b/web/src/settings_config.ts @@ -108,7 +108,7 @@ export const twenty_four_hour_time_values = { }, }; -export interface DisplaySettings { +export type DisplaySettings = { settings: { user_display_settings: string[]; }; @@ -116,7 +116,7 @@ export interface DisplaySettings { high_contrast_mode: boolean; dense_mode: boolean; }; -} +}; /* istanbul ignore next */ export const get_all_display_settings = (): DisplaySettings => ({ @@ -761,7 +761,7 @@ export function get_notifications_table_row_data( }); } -export interface AllNotifications { +export type AllNotifications = { general_settings: {label: string; notification_settings: NotificationSettingCheckbox[]}[]; settings: { desktop_notification_settings: string[]; @@ -773,7 +773,7 @@ export interface AllNotifications { push_notifications: boolean; enable_online_push_notifications: boolean; }; -} +}; export const all_notifications = (settings_object: Settings): AllNotifications => ({ general_settings: [ diff --git a/web/src/url-template.d.ts b/web/src/url-template.d.ts index a7d7e3180e..dff60bf82f 100644 --- a/web/src/url-template.d.ts +++ b/web/src/url-template.d.ts @@ -6,14 +6,14 @@ declare module "url-template" { export type PrimitiveValue = string | number | boolean | null; - export interface Template { + export type Template = { expand( context: Record< string, PrimitiveValue | PrimitiveValue[] | Record >, ): string; - } + }; export function parse(template: string): Template; }