Skip to content

Commit 65e01d0

Browse files
chore(frontend): fix lint errors and update biome schema
Fix exhaustive deps, non-null assertion, a11y roles, and error boundary type. Migrate biome config to 2.4.4.
1 parent cda830a commit 65e01d0

File tree

21 files changed

+2699
-90
lines changed

21 files changed

+2699
-90
lines changed

PROJECTS/advanced/ai-threat-detection/frontend/biome.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
2+
"$schema": "https://biomejs.dev/schemas/2.4.4/schema.json",
33
"vcs": {
44
"enabled": true,
55
"clientKind": "git",

PROJECTS/advanced/ai-threat-detection/frontend/pnpm-lock.yaml

Lines changed: 2629 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PROJECTS/advanced/ai-threat-detection/frontend/src/api/hooks/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// index.ts
44
// ===================
55

6-
export * from './useThreats'
7-
export * from './useStats'
8-
export * from './useModels'
96
export * from './useAlerts'
7+
export * from './useModels'
8+
export * from './useStats'
9+
export * from './useThreats'

PROJECTS/advanced/ai-threat-detection/frontend/src/api/hooks/useAlerts.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import { useEffect, useRef } from 'react'
77
import { create } from 'zustand'
8+
import { type WebSocketAlert, WebSocketAlertSchema } from '@/api/types'
89
import { ALERTS, WS_ENDPOINTS } from '@/config'
9-
import { WebSocketAlertSchema, type WebSocketAlert } from '@/api/types'
1010

1111
interface AlertState {
1212
alerts: WebSocketAlert[]
@@ -31,11 +31,9 @@ const useAlertStore = create<AlertState>()((set) => ({
3131
setConnected: (connected) =>
3232
set({ isConnected: connected, connectionError: null }),
3333

34-
setError: (error) =>
35-
set({ isConnected: false, connectionError: error }),
34+
setError: (error) => set({ isConnected: false, connectionError: error }),
3635

37-
clear: () =>
38-
set({ alerts: [], isConnected: false, connectionError: null }),
36+
clear: () => set({ alerts: [], isConnected: false, connectionError: null }),
3937
}))
4038

4139
function getWsUrl(): string {
@@ -82,7 +80,7 @@ export function useAlerts() {
8280
function scheduleReconnect() {
8381
const delay = Math.min(
8482
ALERTS.RECONNECT_BASE_MS * 2 ** retryCountRef.current,
85-
ALERTS.RECONNECT_MAX_MS,
83+
ALERTS.RECONNECT_MAX_MS
8684
)
8785
retryCountRef.current += 1
8886
retryTimerRef.current = setTimeout(connect, delay)

PROJECTS/advanced/ai-threat-detection/frontend/src/api/hooks/useModels.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55

66
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
77
import { toast } from 'sonner'
8-
import { QUERY_KEYS, API_ENDPOINTS } from '@/config'
9-
import { apiClient, QUERY_STRATEGIES } from '@/core/api'
108
import type { ModelStatus, RetrainResponse } from '@/api/types'
9+
import { API_ENDPOINTS, QUERY_KEYS } from '@/config'
10+
import { apiClient, QUERY_STRATEGIES } from '@/core/api'
1111

1212
export function useModelStatus() {
1313
return useQuery<ModelStatus>({
1414
queryKey: QUERY_KEYS.MODELS.STATUS(),
1515
queryFn: async () => {
1616
const { data } = await apiClient.get<ModelStatus>(
17-
API_ENDPOINTS.MODELS.STATUS,
17+
API_ENDPOINTS.MODELS.STATUS
1818
)
1919
return data
2020
},
@@ -28,7 +28,7 @@ export function useRetrain() {
2828
return useMutation<RetrainResponse>({
2929
mutationFn: async () => {
3030
const { data } = await apiClient.post<RetrainResponse>(
31-
API_ENDPOINTS.MODELS.RETRAIN,
31+
API_ENDPOINTS.MODELS.RETRAIN
3232
)
3333
return data
3434
},

PROJECTS/advanced/ai-threat-detection/frontend/src/api/hooks/useStats.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,17 @@
44
// ===================
55

66
import { useQuery } from '@tanstack/react-query'
7-
import { QUERY_KEYS, API_ENDPOINTS } from '@/config'
8-
import { apiClient, QUERY_STRATEGIES } from '@/core/api'
97
import type { StatsResponse } from '@/api/types'
8+
import { API_ENDPOINTS, QUERY_KEYS } from '@/config'
9+
import { apiClient, QUERY_STRATEGIES } from '@/core/api'
1010

1111
export function useStats(range = '24h') {
1212
return useQuery<StatsResponse>({
1313
queryKey: QUERY_KEYS.STATS.BY_RANGE(range),
1414
queryFn: async () => {
15-
const { data } = await apiClient.get<StatsResponse>(
16-
API_ENDPOINTS.STATS,
17-
{ params: { range } },
18-
)
15+
const { data } = await apiClient.get<StatsResponse>(API_ENDPOINTS.STATS, {
16+
params: { range },
17+
})
1918
return data
2019
},
2120
...QUERY_STRATEGIES.frequent,

PROJECTS/advanced/ai-threat-detection/frontend/src/api/hooks/useThreats.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
// ===================
55

66
import { useQuery } from '@tanstack/react-query'
7-
import { QUERY_KEYS, API_ENDPOINTS, PAGINATION } from '@/config'
7+
import type { ThreatEvent, ThreatList } from '@/api/types'
8+
import { API_ENDPOINTS, PAGINATION, QUERY_KEYS } from '@/config'
89
import { apiClient, QUERY_STRATEGIES } from '@/core/api'
9-
import type { ThreatList, ThreatEvent } from '@/api/types'
1010

1111
interface ThreatParams {
1212
limit?: number
@@ -29,7 +29,7 @@ export function useThreats(params: ThreatParams = {}) {
2929
queryFn: async () => {
3030
const { data } = await apiClient.get<ThreatList>(
3131
API_ENDPOINTS.THREATS.LIST,
32-
{ params: queryParams },
32+
{ params: queryParams }
3333
)
3434
return data
3535
},
@@ -42,7 +42,7 @@ export function useThreat(id: string | null) {
4242
queryKey: QUERY_KEYS.THREATS.BY_ID(id ?? ''),
4343
queryFn: async () => {
4444
const { data } = await apiClient.get<ThreatEvent>(
45-
API_ENDPOINTS.THREATS.BY_ID(id!),
45+
API_ENDPOINTS.THREATS.BY_ID(id as string)
4646
)
4747
return data
4848
},

PROJECTS/advanced/ai-threat-detection/frontend/src/api/types/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// index.ts
44
// ===================
55

6-
export * from './threats.types'
7-
export * from './stats.types'
86
export * from './models.types'
7+
export * from './stats.types'
8+
export * from './threats.types'
99
export * from './websocket.types'

PROJECTS/advanced/ai-threat-detection/frontend/src/components/alert-feed.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
import { useEffect, useRef } from 'react'
77
import type { WebSocketAlert } from '@/api/types'
8-
import { SeverityBadge } from './severity-badge'
98
import styles from './alert-feed.module.scss'
9+
import { SeverityBadge } from './severity-badge'
1010

1111
interface AlertFeedProps {
1212
alerts: WebSocketAlert[]
@@ -25,11 +25,13 @@ export function AlertFeed({
2525
}: AlertFeedProps): React.ReactElement {
2626
const listRef = useRef<HTMLDivElement>(null)
2727

28+
const alertCount = alerts.length
29+
// biome-ignore lint/correctness/useExhaustiveDependencies: scroll on new alerts
2830
useEffect(() => {
2931
if (listRef.current) {
3032
listRef.current.scrollTop = 0
3133
}
32-
}, [alerts.length])
34+
}, [alertCount])
3335

3436
return (
3537
<div className={styles.feed}>
@@ -50,9 +52,7 @@ export function AlertFeed({
5052
) : (
5153
alerts.map((alert, i) => (
5254
<div key={`${alert.timestamp}-${i}`} className={styles.row}>
53-
<span className={styles.time}>
54-
{formatTime(alert.timestamp)}
55-
</span>
55+
<span className={styles.time}>{formatTime(alert.timestamp)}</span>
5656
<span className={styles.ip}>{alert.source_ip}</span>
5757
<span className={styles.path}>{alert.request_path}</span>
5858
<SeverityBadge

PROJECTS/advanced/ai-threat-detection/frontend/src/components/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// index.tsx
44
// ===================
55

6+
export { AlertFeed } from './alert-feed'
67
export { SeverityBadge } from './severity-badge'
78
export { StatCard } from './stat-card'
8-
export { AlertFeed } from './alert-feed'
99
export { ThreatDetail } from './threat-detail'

0 commit comments

Comments
 (0)