xo: Fix @typescript-eslint/consistent-type-definitions.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg
2023-01-03 14:46:10 -08:00
parent 1aa4ade3c0
commit cd023ec5ab
23 changed files with 54 additions and 54 deletions

View File

@@ -13,10 +13,10 @@ export type DndSettings = {
type SettingName = keyof DndSettings; type SettingName = keyof DndSettings;
interface Toggle { type Toggle = {
dnd: boolean; dnd: boolean;
newSettings: Partial<DndSettings>; newSettings: Partial<DndSettings>;
} };
export function toggle(): Toggle { export function toggle(): Toggle {
const dnd = !ConfigUtil.getConfigItem("dnd", false); const dnd = !ConfigUtil.getConfigItem("dnd", false);

View File

@@ -6,9 +6,9 @@ import process from "node:process";
import {initSetUp} from "./default-util"; import {initSetUp} from "./default-util";
import {app} from "./remote"; import {app} from "./remote";
interface LoggerOptions { type LoggerOptions = {
file?: string; file?: string;
} };
initSetUp(); initSetUp();

View File

@@ -1,7 +1,7 @@
interface DialogBoxError { type DialogBoxError = {
title: string; title: string;
content: string; content: string;
} };
export function invalidZulipServerError(domain: string): string { export function invalidZulipServerError(domain: string): string {
return `${domain} does not appear to be a valid Zulip server. Make sure that return `${domain} does not appear to be a valid Zulip server. Make sure that

View File

@@ -1,7 +1,7 @@
import type {DndSettings} from "./dnd-util"; import type {DndSettings} from "./dnd-util";
import type {MenuProps, ServerConf} from "./types"; import type {MenuProps, ServerConf} from "./types";
export interface MainMessage { export type MainMessage = {
"clear-app-settings": () => void; "clear-app-settings": () => void;
"configure-spell-checker": () => void; "configure-spell-checker": () => void;
"fetch-user-agent": () => string; "fetch-user-agent": () => string;
@@ -22,15 +22,15 @@ export interface MainMessage {
"update-badge": (messageCount: number) => void; "update-badge": (messageCount: number) => void;
"update-menu": (props: MenuProps) => void; "update-menu": (props: MenuProps) => void;
"update-taskbar-icon": (data: string, text: string) => void; "update-taskbar-icon": (data: string, text: string) => void;
} };
export interface MainCall { export type MainCall = {
"get-server-settings": (domain: string) => ServerConf; "get-server-settings": (domain: string) => ServerConf;
"is-online": (url: string) => boolean; "is-online": (url: string) => boolean;
"save-server-icon": (iconURL: string) => string; "save-server-icon": (iconURL: string) => string;
} };
export interface RendererMessage { export type RendererMessage = {
back: () => void; back: () => void;
"copy-zulip-url": () => void; "copy-zulip-url": () => void;
destroytray: () => void; destroytray: () => void;
@@ -79,4 +79,4 @@ export interface RendererMessage {
zoomActualSize: () => void; zoomActualSize: () => void;
zoomIn: () => void; zoomIn: () => void;
zoomOut: () => void; zoomOut: () => void;
} };

View File

@@ -1,8 +1,8 @@
export interface MenuProps { export type MenuProps = {
tabs: TabData[]; tabs: TabData[];
activeTabIndex?: number; activeTabIndex?: number;
enableMenu?: boolean; enableMenu?: boolean;
} };
export type NavItem = export type NavItem =
| "General" | "General"
@@ -11,16 +11,16 @@ export type NavItem =
| "Organizations" | "Organizations"
| "Shortcuts"; | "Shortcuts";
export interface ServerConf { export type ServerConf = {
url: string; url: string;
alias: string; alias: string;
icon: string; icon: string;
} };
export type TabRole = "server" | "function"; export type TabRole = "server" | "function";
export interface TabData { export type TabData = {
role: TabRole; role: TabRole;
name: string; name: string;
index: number; index: number;
} };

View File

@@ -16,11 +16,11 @@ import crypto from "node:crypto";
// dont leak anything from the users clipboard other than the token // dont leak anything from the users clipboard other than the token
// intended for us. // intended for us.
export interface ClipboardDecrypter { export type ClipboardDecrypter = {
version: number; version: number;
key: Uint8Array; key: Uint8Array;
pasted: Promise<string>; pasted: Promise<string>;
} };
export class ClipboardDecrypterImpl implements ClipboardDecrypter { export class ClipboardDecrypterImpl implements ClipboardDecrypter {
version: number; version: number;

View File

@@ -5,9 +5,9 @@ import {generateNodeFromHtml} from "./base";
import type {TabProps} from "./tab"; import type {TabProps} from "./tab";
import Tab from "./tab"; import Tab from "./tab";
export interface FunctionalTabProps extends TabProps { export type FunctionalTabProps = {
$view: Element; $view: Element;
} } & TabProps;
export default class FunctionalTab extends Tab { export default class FunctionalTab extends Tab {
$view: Element; $view: Element;

View File

@@ -9,9 +9,9 @@ import type {TabProps} from "./tab";
import Tab from "./tab"; import Tab from "./tab";
import type WebView from "./webview"; import type WebView from "./webview";
export interface ServerTabProps extends TabProps { export type ServerTabProps = {
webview: Promise<WebView>; webview: Promise<WebView>;
} } & TabProps;
export default class ServerTab extends Tab { export default class ServerTab extends Tab {
webview: Promise<WebView>; webview: Promise<WebView>;

View File

@@ -1,6 +1,6 @@
import type {TabRole} from "../../../common/types"; import type {TabRole} from "../../../common/types";
export interface TabProps { export type TabProps = {
role: TabRole; role: TabRole;
icon?: string; icon?: string;
name: string; name: string;
@@ -12,7 +12,7 @@ export interface TabProps {
onHoverOut?: () => void; onHoverOut?: () => void;
materialIcon?: string; materialIcon?: string;
onDestroy?: () => void; onDestroy?: () => void;
} };
export default abstract class Tab { export default abstract class Tab {
abstract $el: Element; abstract $el: Element;

View File

@@ -19,7 +19,7 @@ import {contextMenu} from "./context-menu";
const shouldSilentWebview = ConfigUtil.getConfigItem("silent", false); const shouldSilentWebview = ConfigUtil.getConfigItem("silent", false);
interface WebViewProps { type WebViewProps = {
$root: Element; $root: Element;
rootWebContents: WebContents; rootWebContents: WebContents;
index: number; index: number;
@@ -32,7 +32,7 @@ interface WebViewProps {
preload?: string; preload?: string;
onTitleChange: () => void; onTitleChange: () => void;
hasPermission?: (origin: string, permission: string) => boolean; hasPermission?: (origin: string, permission: string) => boolean;
} };
export default class WebView { export default class WebView {
static templateHtml(props: WebViewProps): Html { static templateHtml(props: WebViewProps): Html {

View File

@@ -8,7 +8,7 @@ import {ipcRenderer} from "./typed-ipc-renderer";
type ListenerType = (...args: any[]) => void; type ListenerType = (...args: any[]) => void;
export interface ElectronBridge { export type ElectronBridge = {
send_event: (eventName: string | symbol, ...args: unknown[]) => boolean; send_event: (eventName: string | symbol, ...args: unknown[]) => boolean;
on_event: (eventName: string, listener: ListenerType) => void; on_event: (eventName: string, listener: ListenerType) => void;
new_notification: ( new_notification: (
@@ -21,7 +21,7 @@ export interface ElectronBridge {
get_send_notification_reply_message_supported: () => boolean; get_send_notification_reply_message_supported: () => boolean;
set_send_notification_reply_message_supported: (value: boolean) => void; set_send_notification_reply_message_supported: (value: boolean) => void;
decrypt_clipboard: (version: number) => ClipboardDecrypter; decrypt_clipboard: (version: number) => ClipboardDecrypter;
} };
let notificationReplySupported = false; let notificationReplySupported = false;
// Indicates if the user is idle or not // Indicates if the user is idle or not

View File

@@ -2,11 +2,11 @@
type ElectronBridge = import("./electron-bridge").ElectronBridge; type ElectronBridge = import("./electron-bridge").ElectronBridge;
interface CompatElectronBridge extends ElectronBridge { type CompatElectronBridge = {
readonly idle_on_system: boolean; readonly idle_on_system: boolean;
readonly last_active_on_system: number; readonly last_active_on_system: number;
send_notification_reply_message_supported: boolean; send_notification_reply_message_supported: boolean;
} } & ElectronBridge;
(() => { (() => {
const zulipWindow = window as typeof window & { const zulipWindow = window as typeof window & {

View File

@@ -1,6 +1,6 @@
import {ipcRenderer} from "../typed-ipc-renderer"; import {ipcRenderer} from "../typed-ipc-renderer";
export interface NotificationData { export type NotificationData = {
close: () => void; close: () => void;
title: string; title: string;
dir: NotificationDirection; dir: NotificationDirection;
@@ -9,7 +9,7 @@ export interface NotificationData {
tag: string; tag: string;
icon: string; icon: string;
data: unknown; data: unknown;
} };
export function newNotification( export function newNotification(
title: string, title: string,

View File

@@ -3,12 +3,12 @@ import {html} from "../../../../common/html";
import {generateNodeFromHtml} from "../../components/base"; import {generateNodeFromHtml} from "../../components/base";
import {ipcRenderer} from "../../typed-ipc-renderer"; import {ipcRenderer} from "../../typed-ipc-renderer";
interface BaseSectionProps { type BaseSectionProps = {
$element: HTMLElement; $element: HTMLElement;
disabled?: boolean; disabled?: boolean;
value: boolean; value: boolean;
clickHandler: () => void; clickHandler: () => void;
} };
export function generateSettingOption(props: BaseSectionProps): void { export function generateSettingOption(props: BaseSectionProps): void {
const {$element, disabled, value, clickHandler} = props; const {$element, disabled, value, clickHandler} = props;

View File

@@ -7,9 +7,9 @@ import {reloadApp} from "./base-section";
import {initFindAccounts} from "./find-accounts"; import {initFindAccounts} from "./find-accounts";
import {initServerInfoForm} from "./server-info-form"; import {initServerInfoForm} from "./server-info-form";
interface ConnectedOrgSectionProps { type ConnectedOrgSectionProps = {
$root: Element; $root: Element;
} };
export function initConnectedOrgSection({ export function initConnectedOrgSection({
$root, $root,

View File

@@ -3,9 +3,9 @@ import * as LinkUtil from "../../../../common/link-util";
import * as t from "../../../../common/translation-util"; import * as t from "../../../../common/translation-util";
import {generateNodeFromHtml} from "../../components/base"; import {generateNodeFromHtml} from "../../components/base";
interface FindAccountsProps { type FindAccountsProps = {
$root: Element; $root: Element;
} };
async function findAccounts(url: string): Promise<void> { async function findAccounts(url: string): Promise<void> {
if (!url) { if (!url) {

View File

@@ -20,9 +20,9 @@ import {generateSelectHtml, generateSettingOption} from "./base-section";
const currentBrowserWindow = remote.getCurrentWindow(); const currentBrowserWindow = remote.getCurrentWindow();
interface GeneralSectionProps { type GeneralSectionProps = {
$root: Element; $root: Element;
} };
export function initGeneralSection({$root}: GeneralSectionProps): void { export function initGeneralSection({$root}: GeneralSectionProps): void {
$root.innerHTML = html` $root.innerHTML = html`

View File

@@ -4,10 +4,10 @@ import * as t from "../../../../common/translation-util";
import type {NavItem} from "../../../../common/types"; import type {NavItem} from "../../../../common/types";
import {generateNodeFromHtml} from "../../components/base"; import {generateNodeFromHtml} from "../../components/base";
interface PreferenceNavProps { type PreferenceNavProps = {
$root: Element; $root: Element;
onItemSelected: (navItem: NavItem) => void; onItemSelected: (navItem: NavItem) => void;
} };
export default class PreferenceNav { export default class PreferenceNav {
navItems: NavItem[]; navItems: NavItem[];

View File

@@ -5,9 +5,9 @@ import {ipcRenderer} from "../../typed-ipc-renderer";
import {generateSettingOption} from "./base-section"; import {generateSettingOption} from "./base-section";
interface NetworkSectionProps { type NetworkSectionProps = {
$root: Element; $root: Element;
} };
export function initNetworkSection({$root}: NetworkSectionProps): void { export function initNetworkSection({$root}: NetworkSectionProps): void {
$root.innerHTML = html` $root.innerHTML = html`

View File

@@ -7,10 +7,10 @@ import {generateNodeFromHtml} from "../../components/base";
import {ipcRenderer} from "../../typed-ipc-renderer"; import {ipcRenderer} from "../../typed-ipc-renderer";
import * as DomainUtil from "../../utils/domain-util"; import * as DomainUtil from "../../utils/domain-util";
interface NewServerFormProps { type NewServerFormProps = {
$root: Element; $root: Element;
onChange: () => void; onChange: () => void;
} };
export function initNewServerForm({$root, onChange}: NewServerFormProps): void { export function initNewServerForm({$root, onChange}: NewServerFormProps): void {
const $newServerForm = generateNodeFromHtml(html` const $newServerForm = generateNodeFromHtml(html`

View File

@@ -8,12 +8,12 @@ import {generateNodeFromHtml} from "../../components/base";
import {ipcRenderer} from "../../typed-ipc-renderer"; import {ipcRenderer} from "../../typed-ipc-renderer";
import * as DomainUtil from "../../utils/domain-util"; import * as DomainUtil from "../../utils/domain-util";
interface ServerInfoFormProps { type ServerInfoFormProps = {
$root: Element; $root: Element;
server: ServerConf; server: ServerConf;
index: number; index: number;
onChange: () => void; onChange: () => void;
} };
export function initServerInfoForm(props: ServerInfoFormProps): void { export function initServerInfoForm(props: ServerInfoFormProps): void {
const $serverInfoForm = generateNodeFromHtml(html` const $serverInfoForm = generateNodeFromHtml(html`

View File

@@ -4,9 +4,9 @@ import * as t from "../../../../common/translation-util";
import {reloadApp} from "./base-section"; import {reloadApp} from "./base-section";
import {initNewServerForm} from "./new-server-form"; import {initNewServerForm} from "./new-server-form";
interface ServersSectionProps { type ServersSectionProps = {
$root: Element; $root: Element;
} };
export function initServersSection({$root}: ServersSectionProps): void { export function initServersSection({$root}: ServersSectionProps): void {
$root.innerHTML = html` $root.innerHTML = html`

View File

@@ -4,9 +4,9 @@ import {html} from "../../../../common/html";
import * as LinkUtil from "../../../../common/link-util"; import * as LinkUtil from "../../../../common/link-util";
import * as t from "../../../../common/translation-util"; import * as t from "../../../../common/translation-util";
interface ShortcutsSectionProps { type ShortcutsSectionProps = {
$root: Element; $root: Element;
} };
// eslint-disable-next-line complexity // eslint-disable-next-line complexity
export function initShortcutsSection({$root}: ShortcutsSectionProps): void { export function initShortcutsSection({$root}: ShortcutsSectionProps): void {