Skip to content

Commit 6e3a60a

Browse files
authored
Fix lint issues in dashboard. (#43)
* Fix lint issues in dashboard. * Use Array.from pattern instead of array constructor. This pattern is more verbose.
1 parent 33ff1c5 commit 6e3a60a

File tree

24 files changed

+195
-93
lines changed

24 files changed

+195
-93
lines changed

apps/dashboard/app/(main)/websites/[id]/assistant/components/chat-history-sheet.tsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {
55
ClockIcon,
66
DotsThreeOutlineVerticalIcon,
77
DownloadIcon,
8-
ImageSquareIcon,
98
MagnifyingGlassIcon,
109
TrashIcon,
1110
} from '@phosphor-icons/react';
@@ -32,7 +31,6 @@ import {
3231
DropdownMenuTrigger,
3332
} from '@/components/ui/dropdown-menu';
3433
import { Input } from '@/components/ui/input';
35-
import { ScrollArea } from '@/components/ui/scroll-area';
3634
import {
3735
Sheet,
3836
SheetContent,
@@ -66,10 +64,18 @@ function formatRelativeTime(timestamp: number): string {
6664
const hours = Math.floor(diff / (1000 * 60 * 60));
6765
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
6866

69-
if (minutes < 1) return 'Just now';
70-
if (minutes < 60) return `${minutes}m ago`;
71-
if (hours < 24) return `${hours}h ago`;
72-
if (days < 7) return `${days}d ago`;
67+
if (minutes < 1) {
68+
return 'Just now';
69+
}
70+
if (minutes < 60) {
71+
return `${minutes}m ago`;
72+
}
73+
if (hours < 24) {
74+
return `${hours}h ago`;
75+
}
76+
if (days < 7) {
77+
return `${days}d ago`;
78+
}
7379
return new Date(timestamp).toLocaleDateString();
7480
}
7581

@@ -90,11 +96,11 @@ export function ChatHistorySheet({ isOpen, onClose }: ChatHistorySheetProps) {
9096
const chats = await chatDB.getAllChats();
9197

9298
const chatsWithPreview = await Promise.all(
93-
chats.map(async (chat: any) => {
99+
chats.map(async (chat) => {
94100
try {
95101
const messages = await chatDB.getMessages(chat.websiteId);
96102
const lastUserMessage = messages
97-
.filter((m: any) => m.type === 'user')
103+
.filter((m) => m.type === 'user')
98104
.pop();
99105

100106
return {

apps/dashboard/app/(main)/websites/[id]/assistant/components/loading-message.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
import { Robot } from '@phosphor-icons/react';
4-
import React from 'react';
54

65
export function LoadingMessage() {
76
return (

apps/dashboard/app/(main)/websites/[id]/assistant/hooks/use-chat.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ export function useChat() {
4646
const [model] = useAtom(modelAtom);
4747
const [websiteId] = useAtom(websiteIdAtom);
4848
const [websiteData] = useAtom(websiteDataAtom);
49-
const [dateRange] = useAtom(dateRangeAtom);
5049
const [messages, setMessages] = useAtom(messagesAtom);
5150
const [inputValue, setInputValue] = useAtom(inputValueAtom);
5251
const [isLoading, setIsLoading] = useAtom(isLoadingAtom);
@@ -124,9 +123,6 @@ export function useChat() {
124123
}, 50);
125124
}, [scrollAreaRef]);
126125

127-
const lastMessage = messages[messages.length - 1];
128-
const lastMessageThinkingSteps = lastMessage?.thinkingSteps?.length || 0;
129-
130126
useEffect(() => {
131127
scrollToBottom();
132128
}, [scrollToBottom]);
@@ -143,7 +139,9 @@ export function useChat() {
143139
const sendMessage = useCallback(
144140
async (content?: string) => {
145141
const messageContent = content || inputValue.trim();
146-
if (!messageContent || isLoading || isRateLimited) return;
142+
if (!messageContent || isLoading || isRateLimited) {
143+
return;
144+
}
147145

148146
const userMessage: Message = {
149147
id: Date.now().toString(),
@@ -238,7 +236,9 @@ export function useChat() {
238236
try {
239237
while (true) {
240238
const { done, value } = await reader.read();
241-
if (done) break;
239+
if (done) {
240+
break;
241+
}
242242

243243
const chunk = new TextDecoder().decode(value);
244244
const lines = chunk.split('\n');

apps/dashboard/app/(main)/websites/[id]/errors/_components/error-chart-tooltip.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
// Enhanced Custom Tooltip for Error Chart
22
export const ErrorChartTooltip = ({ active, payload, label }: any) => {
3-
if (!(active && payload && payload.length)) return null;
3+
if (!(active && payload && payload.length)) {
4+
return null;
5+
}
46

57
return (
68
<div className="rounded-lg border border-border bg-background p-3 text-xs shadow-lg">

apps/dashboard/app/(main)/websites/[id]/errors/_components/error-icons.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,31 @@ import {
1212

1313
// Get icon for error type
1414
export const getErrorTypeIcon = (type: string) => {
15-
if (!type) return <BugIcon className="h-4 w-4" size={16} weight="duotone" />;
15+
if (!type) {
16+
return <BugIcon className="h-4 w-4" size={16} weight="duotone" />;
17+
}
1618

1719
const lowerType = type.toLowerCase();
18-
if (lowerType.includes('react'))
20+
if (lowerType.includes('react')) {
1921
return <CodeIcon className="h-4 w-4" size={16} weight="duotone" />;
20-
if (lowerType.includes('network'))
22+
}
23+
if (lowerType.includes('network')) {
2124
return <NetworkIcon className="h-4 w-4" size={16} weight="duotone" />;
22-
if (lowerType.includes('script'))
25+
}
26+
if (lowerType.includes('script')) {
2327
return <FileCodeIcon className="h-4 w-4" size={16} weight="duotone" />;
24-
if (lowerType.includes('syntax'))
28+
}
29+
if (lowerType.includes('syntax')) {
2530
return <TerminalIcon className="h-4 w-4" size={16} weight="duotone" />;
31+
}
2632
return <BugIcon className="h-4 w-4" size={16} weight="duotone" />;
2733
};
2834

2935
// Get device icon
3036
export const getDeviceIcon = (deviceType: string) => {
31-
if (!deviceType)
37+
if (!deviceType) {
3238
return <MonitorIcon className="h-4 w-4" size={16} weight="duotone" />;
39+
}
3340

3441
switch (deviceType.toLowerCase()) {
3542
case 'mobile':

apps/dashboard/app/(main)/websites/[id]/errors/_components/error-table-columns.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,15 @@ export const createErrorTypeColumns = () => [
130130

131131
export const createDeviceColumn = () =>
132132
createNameColumn('Device Type', (name) => {
133-
if (!name)
133+
if (!name) {
134134
return (
135135
<MonitorIcon
136136
className="h-4 w-4 text-gray-500"
137137
size={16}
138138
weight="duotone"
139139
/>
140140
);
141+
}
141142

142143
const device = name.toLowerCase();
143144
return device.includes('mobile') || device.includes('phone') ? (

apps/dashboard/app/(main)/websites/[id]/errors/_components/error-trends-chart.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,12 @@ export const ErrorTrendsChart = ({ errorChartData }: ErrorTrendsChartProps) => {
155155
axisLine={false}
156156
tick={{ fontSize: 10, fill: 'var(--muted-foreground)' }}
157157
tickFormatter={(value) => {
158-
if (value >= 1_000_000)
158+
if (value >= 1_000_000) {
159159
return `${(value / 1_000_000).toFixed(1)}M`;
160-
if (value >= 1000) return `${(value / 1000).toFixed(1)}k`;
160+
}
161+
if (value >= 1000) {
162+
return `${(value / 1000).toFixed(1)}k`;
163+
}
161164
return value.toString();
162165
}}
163166
tickLine={false}

apps/dashboard/app/(main)/websites/[id]/errors/_components/errors-page-content.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ export const ErrorsPageContent = ({ params }: ErrorsPageContentProps) => {
4343
// Add a new filter
4444
const addFilter = (field: string, value: string | number) => {
4545
// Prevent adding duplicate filters
46-
if (activeFilters.some((f) => f.field === field && f.value === value))
46+
if (activeFilters.some((f) => f.field === field && f.value === value)) {
4747
return;
48+
}
4849

4950
const newFilter: DynamicQueryFilter = { field, operator: 'eq', value };
5051
setActiveFilters((prev) => [...prev, newFilter]);
@@ -182,7 +183,9 @@ export const ErrorsPageContent = ({ params }: ErrorsPageContentProps) => {
182183

183184
// Find the top error
184185
const topError = useMemo(() => {
185-
if (!processedData.error_types?.length) return null;
186+
if (!processedData.error_types?.length) {
187+
return null;
188+
}
186189

187190
return processedData.error_types.reduce(
188191
(max, error) => (error.count > max.count ? error : max),
@@ -192,7 +195,9 @@ export const ErrorsPageContent = ({ params }: ErrorsPageContentProps) => {
192195

193196
// Chart data for error trends
194197
const errorChartData = useMemo(() => {
195-
if (!processedData.error_trends?.length) return [];
198+
if (!processedData.error_trends?.length) {
199+
return [];
200+
}
196201

197202
return processedData.error_trends.map((point: any) => ({
198203
date: safeFormatDate(point.date, 'MMM d'),

apps/dashboard/app/(main)/websites/[id]/errors/_components/top-error-card.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ interface TopErrorCardProps {
1010
}
1111

1212
export const TopErrorCard = ({ topError }: TopErrorCardProps) => {
13-
if (!topError) return null;
13+
if (!topError) {
14+
return null;
15+
}
1416

1517
return (
1618
<Card>

apps/dashboard/app/(main)/websites/[id]/errors/_components/utils.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,25 @@ import { format, isValid, parseISO } from 'date-fns';
22

33
// Helper function to safely parse dates
44
export const safeDateParse = (dateString: string): Date => {
5-
if (!dateString) return new Date();
5+
if (!dateString) {
6+
return new Date();
7+
}
68

79
let date = parseISO(dateString);
8-
if (isValid(date)) return date;
10+
if (isValid(date)) {
11+
return date;
12+
}
913

1014
const isoString = dateString.replace(' ', 'T');
1115
date = parseISO(isoString);
12-
if (isValid(date)) return date;
16+
if (isValid(date)) {
17+
return date;
18+
}
1319

1420
date = new Date(dateString);
15-
if (isValid(date)) return date;
21+
if (isValid(date)) {
22+
return date;
23+
}
1624

1725
console.warn('Failed to parse date:', dateString);
1826
return new Date();

0 commit comments

Comments
 (0)