Skip to content

Commit 4abb2cb

Browse files
Adam GaborjaniAdam Gaborjani
authored andcommitted
fix: lint errors and type safety
1 parent 36492c4 commit 4abb2cb

13 files changed

Lines changed: 74 additions & 29 deletions

File tree

‎src/components/ui/command.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const Command = React.forwardRef<
2121
));
2222
Command.displayName = CommandPrimitive.displayName;
2323

24-
interface CommandDialogProps extends DialogProps {}
24+
type CommandDialogProps = DialogProps;
2525

2626
const CommandDialog = ({ children, ...props }: CommandDialogProps) => {
2727
return (

‎src/components/ui/textarea.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from "react";
22

33
import { cn } from "@/lib/utils";
44

5-
export interface TextareaProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {}
5+
export type TextareaProps = React.TextareaHTMLAttributes<HTMLTextAreaElement>;
66

77
const Textarea = React.forwardRef<HTMLTextAreaElement, TextareaProps>(({ className, ...props }, ref) => {
88
return (

‎src/hooks/use-speech-to-text.ts‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,14 @@ interface SpeechRecognition extends EventTarget {
2929
stop(): void;
3030
abort(): void;
3131
onresult: (event: SpeechRecognitionEvent) => void;
32-
onerror: (event: any) => void;
32+
onerror: (event: SpeechRecognitionErrorEvent) => void;
3333
onend: () => void;
3434
}
3535

36+
interface SpeechRecognitionErrorEvent extends Event {
37+
error: string;
38+
}
39+
3640
declare global {
3741
interface Window {
3842
SpeechRecognition: new () => SpeechRecognition;
@@ -71,7 +75,7 @@ export function useSpeechToText() {
7175
setIsListening(false);
7276
};
7377

74-
recognitionInstance.onerror = (event: any) => {
78+
recognitionInstance.onerror = (event: SpeechRecognitionErrorEvent) => {
7579
console.error('Speech recognition error', event.error);
7680
setIsListening(false);
7781
};

‎src/lib/stores/session-store.ts‎

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,38 @@ async function getUserId() {
105105
return data.user?.id || null;
106106
}
107107

108+
interface SupabaseSavedRow<T> {
109+
id: string;
110+
title: string;
111+
output: T;
112+
created_at: string;
113+
}
114+
115+
interface SupabaseChatRow {
116+
id: string;
117+
title: string;
118+
created_at: string;
119+
}
120+
121+
interface SupabaseMessageRow {
122+
id: string;
123+
chat_id: string;
124+
role: 'user' | 'assistant';
125+
content: string;
126+
output: AskOutput | null;
127+
created_at: string;
128+
}
129+
130+
interface SupabaseSourceRow {
131+
id: string;
132+
title: string;
133+
content: string;
134+
type: 'url' | 'file' | 'text';
135+
origin: string | null;
136+
is_active: boolean;
137+
created_at: string;
138+
}
139+
108140
export const useSessionStore = create<SessionState>()(
109141
persist(
110142
(set, get) => ({
@@ -374,41 +406,47 @@ export const useSessionStore = create<SessionState>()(
374406
supabase.from('sources').select('*').order('created_at', { ascending: false }),
375407
]);
376408

377-
const chatIds = (chatsRes.data || []).map((c: any) => c.id);
409+
const chatRows = (chatsRes.data || []) as SupabaseChatRow[];
410+
const chatIds = chatRows.map((c) => c.id);
378411
const messagesRes = chatIds.length
379412
? await supabase.from('messages').select('*').in('chat_id', chatIds).order('created_at', { ascending: true })
380413
: { data: [] };
381414

382-
const serverCases = (casesRes.data || []).map((row: any) => ({
415+
const caseRows = (casesRes.data || []) as SupabaseSavedRow<GenerateOutput>[];
416+
const serverCases = caseRows.map((row) => ({
383417
id: row.id,
384418
data: row.output,
385419
createdAt: toTimestamp(row.created_at),
386420
title: row.title,
387421
}));
388422

389-
const serverAttacks = (attacksRes.data || []).map((row: any) => ({
423+
const attackRows = (attacksRes.data || []) as SupabaseSavedRow<AttackOutput>[];
424+
const serverAttacks = attackRows.map((row) => ({
390425
id: row.id,
391426
data: row.output,
392427
createdAt: toTimestamp(row.created_at),
393428
title: row.title,
394429
}));
395430

396-
const serverBrainstorms = (brainstormsRes.data || []).map((row: any) => ({
431+
const brainstormRows = (brainstormsRes.data || []) as SupabaseSavedRow<BrainstormOutput>[];
432+
const serverBrainstorms = brainstormRows.map((row) => ({
397433
id: row.id,
398434
data: row.output,
399435
createdAt: toTimestamp(row.created_at),
400436
title: row.title,
401437
}));
402438

403-
const serverFactoids = (factoidsRes.data || []).map((row: any) => ({
439+
const factoidRows = (factoidsRes.data || []) as SupabaseSavedRow<FactoidsOutput>[];
440+
const serverFactoids = factoidRows.map((row) => ({
404441
id: row.id,
405442
data: row.output,
406443
createdAt: toTimestamp(row.created_at),
407444
title: row.title,
408445
}));
409446

410447
const messageMap = new Map<string, Message[]>();
411-
(messagesRes.data || []).forEach((row: any) => {
448+
const messageRows = (messagesRes.data || []) as SupabaseMessageRow[];
449+
messageRows.forEach((row) => {
412450
const list = messageMap.get(row.chat_id) || [];
413451
list.push({
414452
id: row.id,
@@ -420,14 +458,15 @@ export const useSessionStore = create<SessionState>()(
420458
messageMap.set(row.chat_id, list);
421459
});
422460

423-
const serverChats = (chatsRes.data || []).map((row: any) => ({
461+
const serverChats = chatRows.map((row) => ({
424462
id: row.id,
425463
title: row.title,
426464
createdAt: toTimestamp(row.created_at),
427465
data: messageMap.get(row.id) || [],
428466
}));
429467

430-
const serverSources = (sourcesRes.data || []).map((row: any) => ({
468+
const sourceRows = (sourcesRes.data || []) as SupabaseSourceRow[];
469+
const serverSources = sourceRows.map((row) => ({
431470
id: row.id,
432471
title: row.title,
433472
content: row.content,

‎src/pages/AttackPage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ export default function AttackPage() {
6666
addAskMessage({
6767
role: 'assistant',
6868
content: result.response,
69-
// @ts-ignore
69+
// @ts-expect-error: form schema and UI fields diverge
7070
output: result
7171
});
7272
} catch (error) {

‎src/pages/BrainstormPage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export default function BrainstormPage() {
6262
addAskMessage({
6363
role: 'assistant',
6464
content: result.response,
65-
// @ts-ignore
65+
// @ts-expect-error: form schema and UI fields diverge
6666
output: result
6767
});
6868
} catch (error) {

‎src/pages/FactoidsPage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ export default function FactoidsPage() {
6767
addAskMessage({
6868
role: 'assistant',
6969
content: result.response,
70-
// @ts-ignore
70+
// @ts-expect-error: form schema and UI fields diverge
7171
output: result
7272
});
7373
} catch (error) {

‎src/pages/GeneratePage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default function GeneratePage() {
7878
addAskMessage({
7979
role: 'assistant',
8080
content: result.response,
81-
// @ts-ignore
81+
// @ts-expect-error: form schema and UI fields diverge
8282
output: result
8383
});
8484
} catch (error) {

‎src/test/mocks/supabase.ts‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import { vi } from "vitest";
22

33
type TableResponse = {
4-
select?: any[];
5-
single?: any;
6-
insert?: any;
7-
order?: any[];
8-
in?: any[];
9-
update?: any;
4+
select?: unknown[];
5+
single?: unknown;
6+
insert?: unknown;
7+
order?: unknown[];
8+
in?: unknown[];
9+
update?: unknown;
1010
};
1111

1212
const tableResponses: Record<string, TableResponse> = {};
@@ -73,8 +73,8 @@ export const setMockSessionToken = (token: string | null) => {
7373
sessionToken = token || "";
7474
};
7575

76-
export const setMockInvokeResponse = (data: any, error: any = null) => {
77-
(supabaseMock.functions.invoke as any).mockResolvedValue({ data, error });
76+
export const setMockInvokeResponse = (data: unknown, error: unknown = null) => {
77+
supabaseMock.functions.invoke.mockResolvedValue({ data, error });
7878
};
7979

8080
export const resetMockState = () => {

‎src/test/session-store.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ describe("session-store", () => {
171171
useSessionStore.setState({
172172
savedCases: [{ id: "1", title: "Case", createdAt: Date.now(), data: sampleGenerate }],
173173
savedAttacks: [{ id: "2", title: "Attack", createdAt: Date.now(), data: sampleAttack }],
174-
} as any);
174+
} as Partial<ReturnType<typeof useSessionStore.getState>>);
175175

176176
await useSessionStore.getState().clearAllData();
177177
const state = useSessionStore.getState();

0 commit comments

Comments
 (0)