Fix lint errors

This commit is contained in:
Gregory Schier
2026-03-13 08:12:21 -07:00
parent be34dfe74a
commit 7670ab007f
44 changed files with 110 additions and 75 deletions

View File

@@ -19,7 +19,7 @@ export const openWorkspaceFromSyncDir = createFastMutation<void, void, string>({
await applySync(workspace.id, dir, ops);
router.navigate({
await router.navigate({
to: '/workspaces/$workspaceId',
params: { workspaceId: workspace.id },
});

View File

@@ -1,6 +1,7 @@
import type { DnsOverride, Workspace } from '@yaakapp-internal/models';
import { patchModel } from '@yaakapp-internal/models';
import { useCallback, useId, useMemo } from 'react';
import { fireAndForget } from '../lib/fireAndForget';
import { Button } from './core/Button';
import { Checkbox } from './core/Checkbox';
import { IconButton } from './core/IconButton';
@@ -29,7 +30,7 @@ export function DnsOverridesEditor({ workspace }: Props) {
const handleChange = useCallback(
(overrides: DnsOverride[]) => {
patchModel(workspace, { settingDnsOverrides: overrides });
fireAndForget(patchModel(workspace, { settingDnsOverrides: overrides }));
},
[workspace],
);

View File

@@ -9,6 +9,7 @@ import {
useEnvironmentsBreakdown,
} from '../hooks/useEnvironmentsBreakdown';
import { deleteModelWithConfirm } from '../lib/deleteModelWithConfirm';
import { fireAndForget } from '../lib/fireAndForget';
import { jotaiStore } from '../lib/jotai';
import { isBaseEnvironment, isSubEnvironment } from '../lib/model_util';
import { resolvedModelName } from '../lib/resolvedModelName';
@@ -199,7 +200,7 @@ function EnvironmentEditDialogSidebar({
// Not sure why this is needed, but without it the
// edit input blurs immediately after opening.
requestAnimationFrame(() => {
actions['sidebar.selected.rename'].cb(items);
fireAndForget(actions['sidebar.selected.rename'].cb(items));
});
},
},

View File

@@ -8,6 +8,7 @@ import { allRequestsAtom } from '../hooks/useAllRequests';
import { useFolderActions } from '../hooks/useFolderActions';
import { useLatestHttpResponse } from '../hooks/useLatestHttpResponse';
import { sendAnyHttpRequest } from '../hooks/useSendAnyHttpRequest';
import { fireAndForget } from '../lib/fireAndForget';
import { showDialog } from '../lib/dialog';
import { resolvedModelName } from '../lib/resolvedModelName';
import { router } from '../lib/router';
@@ -45,7 +46,7 @@ export function FolderLayout({ folder, style }: Props) {
}, [folder.id, folders, requests]);
const handleSendAll = useCallback(() => {
sendAllAction?.call(folder);
if (sendAllAction) fireAndForget(sendAllAction.call(folder));
}, [sendAllAction, folder]);
return (

View File

@@ -1,6 +1,7 @@
import { clear, readText } from '@tauri-apps/plugin-clipboard-manager';
import * as m from 'motion/react-m';
import { useEffect, useState } from 'react';
import { fireAndForget } from '../lib/fireAndForget';
import { useImportCurl } from '../hooks/useImportCurl';
import { useWindowFocus } from '../hooks/useWindowFocus';
import { Button } from './core/Button';
@@ -15,7 +16,7 @@ export function ImportCurlButton() {
// biome-ignore lint/correctness/useExhaustiveDependencies: none
useEffect(() => {
readText().then(setClipboardText);
fireAndForget(readText().then(setClipboardText));
}, [focused]);
if (!clipboardText?.trim().startsWith('curl ')) {

View File

@@ -2,6 +2,7 @@ import { linter } from '@codemirror/lint';
import type { HttpRequest } from '@yaakapp-internal/models';
import { patchModel } from '@yaakapp-internal/models';
import { useCallback, useMemo } from 'react';
import { fireAndForget } from '../lib/fireAndForget';
import { useKeyValue } from '../hooks/useKeyValue';
import { textLikelyContainsJsonComments } from '../lib/jsonComments';
import { Banner } from './core/Banner';
@@ -58,12 +59,12 @@ export function JsonBodyEditor({ forceUpdateKey, heightMode, request }: Props) {
} else {
delete newBody.sendJsonComments;
}
patchModel(request, { body: newBody });
fireAndForget(patchModel(request, { body: newBody }));
}, [request, autoFix]);
const handleDropdownOpen = useCallback(() => {
if (!bannerDismissed) {
setBannerDismissed(true);
fireAndForget(setBannerDismissed(true));
}
}, [bannerDismissed, setBannerDismissed]);

View File

@@ -5,6 +5,7 @@ import { getRecentCookieJars } from '../hooks/useRecentCookieJars';
import { getRecentEnvironments } from '../hooks/useRecentEnvironments';
import { getRecentRequests } from '../hooks/useRecentRequests';
import { useRecentWorkspaces } from '../hooks/useRecentWorkspaces';
import { fireAndForget } from '../lib/fireAndForget';
import { router } from '../lib/router';
export function RedirectToLatestWorkspace() {
@@ -20,7 +21,7 @@ export function RedirectToLatestWorkspace() {
return;
}
(async () => {
fireAndForget((async () => {
const workspaceId = recentWorkspaces[0] ?? workspaces[0]?.id ?? 'n/a';
const environmentId = (await getRecentEnvironments(workspaceId))[0] ?? null;
const cookieJarId = (await getRecentCookieJars(workspaceId))[0] ?? null;
@@ -34,7 +35,7 @@ export function RedirectToLatestWorkspace() {
console.log('Redirecting to workspace', params, search);
await router.navigate({ to: '/workspaces/$workspaceId', params, search });
})();
})());
}, [recentWorkspaces, workspaces, workspaces.length]);
return null;

View File

@@ -43,6 +43,7 @@ import { useSidebarHidden } from '../hooks/useSidebarHidden';
import { getWebsocketRequestActions } from '../hooks/useWebsocketRequestActions';
import { deepEqualAtom } from '../lib/atoms';
import { deleteModelWithConfirm } from '../lib/deleteModelWithConfirm';
import { fireAndForget } from '../lib/fireAndForget';
import { jotaiStore } from '../lib/jotai';
import { resolvedModelName } from '../lib/resolvedModelName';
import { isSidebarFocused } from '../lib/scopes';
@@ -439,7 +440,7 @@ function Sidebar({ className }: { className?: string }) {
leftSlot: <Icon icon="arrow_right_circle" />,
hidden: workspaces.length <= 1 || requestItems.length === 0 || requestItems.length !== items.length,
onSelect: () => {
actions['sidebar.selected.move'].cb(items);
fireAndForget(actions['sidebar.selected.move'].cb(items));
},
},
{

View File

@@ -127,7 +127,7 @@ export function WorkspaceEncryptionSetting({ size, expanded, onDone, onEnabledEn
await enableEncryption(workspaceMeta.workspaceId);
setJustEnabledEncryption(true);
} catch (err) {
setError(`Failed to enable encryption: ${err}`);
setError(`Failed to enable encryption: ${err instanceof Error ? err.message : String(err)}`);
}
}}
>

View File

@@ -25,6 +25,7 @@ import {
} from 'react';
import { useKey, useWindowSize } from 'react-use';
import { useClickOutside } from '../../hooks/useClickOutside';
import { fireAndForget } from '../../lib/fireAndForget';
import type { HotkeyAction } from '../../hooks/useHotKey';
import { useHotKey } from '../../hooks/useHotKey';
import { useStateWithDeps } from '../../hooks/useStateWithDeps';
@@ -614,7 +615,7 @@ const Menu = forwardRef<Omit<DropdownRef, 'open' | 'isOpen' | 'toggle' | 'items'
setActiveSubmenu({ item, parent, viaKeyboard: true });
}
} else if (item.onSelect) {
handleSelect(item);
fireAndForget(handleSelect(item));
}
},
{},

View File

@@ -22,6 +22,7 @@ import {
useState,
} from 'react';
import { useKeyValue } from '../../../hooks/useKeyValue';
import { fireAndForget } from '../../../lib/fireAndForget';
import { computeSideForDragMove } from '../../../lib/dnd';
import { DropMarker } from '../../DropMarker';
import { ErrorBoundary } from '../../ErrorBoundary';
@@ -143,7 +144,7 @@ export const Tabs = forwardRef<TabsRef, Props>(function Tabs(
forwardedRef,
() => ({
setActiveTab: (value: string) => {
onChangeValue(value);
fireAndForget(onChangeValue(value));
},
}),
[onChangeValue],

View File

@@ -11,6 +11,7 @@ import { useRandomKey } from '../../hooks/useRandomKey';
import { sync } from '../../init/sync';
import { showConfirm, showConfirmDelete } from '../../lib/confirm';
import { showDialog } from '../../lib/dialog';
import { fireAndForget } from '../../lib/fireAndForget';
import { showPrompt } from '../../lib/prompt';
import { showErrorToast, showToast } from '../../lib/toast';
import { Banner } from '../core/Banner';
@@ -246,7 +247,7 @@ function SyncDropdownWithSyncDir({ syncDir }: { syncDir: string }) {
message: 'Changes have been reset',
color: 'success',
});
sync({ force: true });
fireAndForget(sync({ force: true }));
},
onError(err) {
showErrorToast({
@@ -293,7 +294,7 @@ function SyncDropdownWithSyncDir({ syncDir }: { syncDir: string }) {
</>
),
});
sync({ force: true });
fireAndForget(sync({ force: true }));
},
onError(err) {
showErrorToast({

View File

@@ -270,7 +270,7 @@ function GqlTypeInfo({
{Object.entries(fields).map(([fieldName, field]) => {
const fieldItem: ExplorerItem = toExplorerItem(field, item);
return (
<div key={`${field.type}::${field.name}`} className="my-4">
<div key={`${String(field.type)}::${field.name}`} className="my-4">
<GqlTypeRow
item={fieldItem}
setItem={setItem}
@@ -363,7 +363,7 @@ function GqlTypeInfo({
<Subheading>Arguments</Subheading>
{item.type.args.map((a) => {
return (
<div key={`${a.type}::${a.name}`} className="my-4">
<div key={`${String(a.type)}::${a.name}`} className="my-4">
<GqlTypeRow
name={{ value: a.name, color: 'info' }}
item={{ kind: 'type', type: a.type, from: item }}
@@ -393,7 +393,7 @@ function GqlTypeInfo({
from: item,
};
return (
<div key={`${field.type}::${field.name}`} className="my-4">
<div key={`${String(field.type)}::${field.name}`} className="my-4">
<GqlTypeRow
item={fieldItem}
setItem={setItem}
@@ -431,7 +431,7 @@ function GqlTypeInfo({
if (field == null) return null;
const fieldItem: ExplorerItem = { kind: 'field', type: field, from: item };
return (
<div key={`${field.type}::${field.name}`} className="my-4">
<div key={`${String(field.type)}::${field.name}`} className="my-4">
<GqlTypeRow
item={fieldItem}
setItem={setItem}
@@ -512,7 +512,7 @@ function GqlTypeRow({
<span className="text-text-subtle">(</span>
{item.type.args.map((arg) => (
<div
key={`${arg.type}::${arg.name}`}
key={`${String(arg.type)}::${arg.name}`}
className={classNames(item.type.args.length === 1 && 'inline-flex')}
>
{item.type.args.length > 1 && <>&nbsp;&nbsp;</>}

View File

@@ -6,13 +6,14 @@ import type { PDFDocumentProxy } from 'pdfjs-dist';
import { useEffect, useRef, useState } from 'react';
import { Document, Page } from 'react-pdf';
import { useContainerSize } from '../../hooks/useContainerQuery';
import { fireAndForget } from '../../lib/fireAndForget';
import('react-pdf').then(({ pdfjs }) => {
fireAndForget(import('react-pdf').then(({ pdfjs }) => {
pdfjs.GlobalWorkerOptions.workerSrc = new URL(
'pdfjs-dist/build/pdf.worker.min.mjs',
import.meta.url,
).toString();
});
}));
interface Props {
bodyPath?: string;

View File

@@ -1,6 +1,7 @@
// Listen for settings changes, the re-compute theme
import { listen } from '@tauri-apps/api/event';
import type { ModelPayload } from '@yaakapp-internal/models';
import { fireAndForget } from './lib/fireAndForget';
import { getSettings } from './lib/settings';
function setFontSizeOnDocument(fontSize: number) {
@@ -13,4 +14,4 @@ listen<ModelPayload>('model_write', async (event) => {
setFontSizeOnDocument(event.payload.model.interfaceFontSize);
}).catch(console.error);
getSettings().then((settings) => setFontSizeOnDocument(settings.interfaceFontSize));
fireAndForget(getSettings().then((settings) => setFontSizeOnDocument(settings.interfaceFontSize)));

View File

@@ -1,6 +1,7 @@
// Listen for settings changes, the re-compute theme
import { listen } from '@tauri-apps/api/event';
import type { ModelPayload, Settings } from '@yaakapp-internal/models';
import { fireAndForget } from './lib/fireAndForget';
import { getSettings } from './lib/settings';
function setFonts(settings: Settings) {
@@ -17,4 +18,4 @@ listen<ModelPayload>('model_write', async (event) => {
setFonts(event.payload.model);
}).catch(console.error);
getSettings().then((settings) => setFonts(settings));
fireAndForget(getSettings().then((settings) => setFonts(settings)));

View File

@@ -16,7 +16,7 @@ interface TypeMap {
}
export function useActiveRequest<T extends keyof TypeMap>(
model?: T | undefined,
model?: T,
): TypeMap[T] | null {
const activeRequest = useAtomValue(activeRequestAtom);
if (model == null) return activeRequest as TypeMap[T];

View File

@@ -18,7 +18,7 @@ export function useCreateDropdownItems({
}: {
hideFolder?: boolean;
hideIcons?: boolean;
folderId?: string | null | 'active-folder';
folderId?: string | null;
} = {}): DropdownItem[] {
const workspaceId = useAtomValue(activeWorkspaceIdAtom);
const activeRequest = useAtomValue(activeRequestAtom);
@@ -40,7 +40,7 @@ export function getCreateDropdownItems({
}: {
hideFolder?: boolean;
hideIcons?: boolean;
folderId?: string | null | 'active-folder';
folderId?: string | null;
workspaceId: string | null;
activeRequest: HttpRequest | GrpcRequest | WebsocketRequest | null;
onCreate?: (

View File

@@ -42,7 +42,7 @@ export function createFastMutation<TData = unknown, TError = unknown, TVariables
if (!disableToastError) {
showToast({
id: stringKey,
message: `${err}`,
message: err instanceof Error ? err.message : String(err),
color: 'danger',
timeout: 5000,
});

View File

@@ -7,6 +7,7 @@ import {
} from '@yaakapp-internal/models';
import { useAtomValue } from 'jotai';
import { useEffect } from 'react';
import { fireAndForget } from '../lib/fireAndForget';
export function useHttpResponseEvents(response: HttpResponse | null) {
const allEvents = useAtomValue(httpResponseEventsAtom);
@@ -18,10 +19,10 @@ export function useHttpResponseEvents(response: HttpResponse | null) {
}
// Fetch events from database, filtering out events from other responses and merging atomically
invoke<HttpResponseEvent[]>('cmd_get_http_response_events', { responseId: response.id }).then(
fireAndForget(invoke<HttpResponseEvent[]>('cmd_get_http_response_events', { responseId: response.id }).then(
(events) =>
mergeModelsInStore('http_response_event', events, (e) => e.responseId === response.id),
);
));
}, [response?.id]);
const events = allEvents.filter((e) => e.responseId === response?.id);

View File

@@ -8,6 +8,7 @@ import {
} from '@yaakapp-internal/models';
import { atom, useAtomValue } from 'jotai';
import { useEffect, useMemo } from 'react';
import { fireAndForget } from '../lib/fireAndForget';
import { atomWithKVStorage } from '../lib/atoms/atomWithKVStorage';
import { activeRequestIdAtom } from './useActiveRequestId';
@@ -69,9 +70,9 @@ export function useGrpcEvents(connectionId: string | null) {
}
// Fetch events from database, filtering out events from other connections and merging atomically
invoke<GrpcEvent[]>('models_grpc_events', { connectionId }).then((events) =>
fireAndForget(invoke<GrpcEvent[]>('models_grpc_events', { connectionId }).then((events) =>
mergeModelsInStore('grpc_event', events, (e) => e.connectionId === connectionId),
);
));
}, [connectionId]);
return useMemo(

View File

@@ -8,6 +8,7 @@ import {
} from '@yaakapp-internal/models';
import { atom, useAtomValue } from 'jotai';
import { useEffect, useMemo } from 'react';
import { fireAndForget } from '../lib/fireAndForget';
import { atomWithKVStorage } from '../lib/atoms/atomWithKVStorage';
import { jotaiStore } from '../lib/jotai';
import { activeRequestIdAtom } from './useActiveRequestId';
@@ -56,9 +57,9 @@ export function useWebsocketEvents(connectionId: string | null) {
}
// Fetch events from database, filtering out events from other connections and merging atomically
invoke<WebsocketEvent[]>('models_websocket_events', { connectionId }).then((events) =>
fireAndForget(invoke<WebsocketEvent[]>('models_websocket_events', { connectionId }).then((events) =>
mergeModelsInStore('websocket_event', events, (e) => e.connectionId === connectionId),
);
));
}, [connectionId]);
return useMemo(

View File

@@ -1,5 +1,6 @@
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
import { useEffect, useState } from 'react';
import { fireAndForget } from '../lib/fireAndForget';
export function useWindowFocus() {
const [visible, setVisible] = useState(true);
@@ -10,7 +11,7 @@ export function useWindowFocus() {
});
return () => {
unlisten.then((fn) => fn());
fireAndForget(unlisten.then((fn) => fn()));
};
}, []);

View File

@@ -0,0 +1,16 @@
import { showErrorToast } from './toast';
/**
* Handles a fire-and-forget promise by catching and reporting errors
* via console.error and a toast notification.
*/
export function fireAndForget(promise: Promise<unknown>) {
promise.catch((err: unknown) => {
console.error('Unhandled async error:', err);
showErrorToast({
id: 'async-error',
title: 'Unexpected Error',
message: err instanceof Error ? err.message : String(err),
});
});
}

View File

@@ -22,6 +22,7 @@ import { HStack, VStack } from '../components/core/Stacks';
// Listen for toasts
import { listenToTauriEvent } from '../hooks/useListenToTauriEvent';
import { fireAndForget } from './fireAndForget';
import { updateAvailableAtom } from './atoms';
import { stringToColor } from './color';
import { generateId } from './generateId';
@@ -81,7 +82,7 @@ export function initGlobalListeners() {
done,
},
};
emit(event.id, result);
fireAndForget(emit(event.id, result));
};
const values = await showPromptForm({
@@ -110,7 +111,7 @@ export function initGlobalListeners() {
// Listen for update events
listenToTauriEvent<UpdateInfo>('update_available', async ({ payload }) => {
console.log('Got update available', payload);
showUpdateAvailableToast(payload);
fireAndForget(showUpdateAvailableToast(payload));
});
listenToTauriEvent<YaakNotification>('notification', ({ payload }) => {
@@ -125,7 +126,7 @@ export function initGlobalListeners() {
});
// Check for plugin initialization errors
invokeCmd<[string, string][]>('cmd_plugin_init_errors').then((errors) => {
fireAndForget(invokeCmd<[string, string][]>('cmd_plugin_init_errors').then((errors) => {
for (const [dir, message] of errors) {
const dirBasename = dir.split('/').pop() ?? dir;
showToast({
@@ -155,7 +156,7 @@ export function initGlobalListeners() {
),
});
}
});
}));
}
function showUpdateInstalledToast(version: string) {

View File

@@ -1,4 +1,5 @@
import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow';
import { fireAndForget } from '../fireAndForget';
export type Appearance = 'light' | 'dark';
@@ -22,13 +23,13 @@ export function subscribeToWindowAppearanceChange(
unsubscribe: () => {},
};
getCurrentWebviewWindow()
fireAndForget(getCurrentWebviewWindow()
.onThemeChanged((t) => {
cb(t.payload);
})
.then((l) => {
container.unsubscribe = l;
});
}));
return () => container.unsubscribe();
}
@@ -43,6 +44,6 @@ export function resolveAppearance(
export function subscribeToPreferredAppearance(cb: (a: Appearance) => void) {
cb(getCSSAppearance());
getWindowAppearance().then(cb);
fireAndForget(getWindowAppearance().then(cb));
subscribeToWindowAppearanceChange(cb);
}

View File

@@ -138,6 +138,7 @@ module.exports = {
},
plugins: [
require('@tailwindcss/container-queries'),
// oxlint-disable-next-line unbound-method
plugin(function ({ addVariant }) {
addVariant('hocus', ['&:hover', '&:focus-visible', '&.focus:focus']);
addVariant('focus-visible-or-class', ['&:focus-visible', '&.focus:focus']);