Skip to content

Commit b4ebc5f

Browse files
committed
fix(web): apply pre-commit lint fixes from Phase 1-2
- Replace useContext with React 19 use() API - Simplify Context Provider syntax (remove .Provider suffix) - Use replaceAll instead of replace with global regex - Use append/remove instead of appendChild/removeChild - Add JSDoc param comments - Fix import ordering (type imports first) These changes were automatically applied by lint-stagedrc during previous commits but were not included in those commits.
1 parent e8384ca commit b4ebc5f

File tree

18 files changed

+71
-56
lines changed

18 files changed

+71
-56
lines changed

apps/web/src/components/activity/ActivityFeed.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@
55
* Integrates with ActivityContext for real-time updates.
66
*/
77

8-
import { useActivity } from '@/contexts/ActivityContext';
9-
import { ICON_SIZE } from '@/config/style-constants';
10-
import type { ActivityCategory } from '@/types/activity';
118
import {
129
Avatar,
1310
Box,
@@ -20,17 +17,21 @@ import {
2017
} from '@mantine/core';
2118
import {
2219
IconArrowRight,
23-
IconDatabaseImport,
2420
IconDatabaseExport,
21+
IconDatabaseImport,
2522
IconEdit,
2623
IconList,
2724
IconPlus,
2825
IconSearch,
2926
IconTrash,
3027
IconX,
3128
} from '@tabler/icons-react';
32-
import { memo } from 'react';
3329
import { formatDistanceToNow } from 'date-fns';
30+
import { memo } from 'react';
31+
32+
import { ICON_SIZE } from '@/config/style-constants';
33+
import { useActivity } from '@/contexts/ActivityContext';
34+
import type { ActivityCategory } from '@/types/activity';
3435

3536
const CATEGORY_ICONS: Record<ActivityCategory, React.ReactNode> = {
3637
create: <IconPlus size={ICON_SIZE.SM} />,

apps/web/src/components/error/ErrorBoundary.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
*/
77

88
import { logger } from '@bibgraph/utils/logger';
9-
import type { ClassValue } from 'clsx';
10-
import { clsx } from 'clsx';
119
import {
1210
Alert,
1311
Button,
@@ -23,6 +21,8 @@ import {
2321
IconHome,
2422
IconRefresh,
2523
} from '@tabler/icons-react';
24+
import type { ClassValue } from 'clsx';
25+
import { clsx } from 'clsx';
2626
import React, { Component, ErrorInfo, ReactNode } from 'react';
2727

2828
import { ICON_SIZE } from '@/config/style-constants';
@@ -222,6 +222,8 @@ export class ErrorBoundary extends Component<
222222

223223
/**
224224
* Functional wrapper for easier usage
225+
* @param Component
226+
* @param errorBoundaryProps
225227
*/
226228
export const withErrorBoundary = <P extends object>(
227229
Component: React.ComponentType<P>,

apps/web/src/components/export/ExportButton.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44
* Provides export functionality for search results to CSV and BibTeX formats.
55
*/
66

7+
import type { AutocompleteResult } from '@bibgraph/types';
78
import { ActionIcon, Group, Menu, Stack, Text, Tooltip } from '@mantine/core';
89
import { IconDownload, IconFileExport, IconFileTypography, IconTable } from '@tabler/icons-react';
910

1011
import { ICON_SIZE } from '@/config/style-constants';
1112
import { exportToBibTeX, exportToCSV, getExportFilename } from '@/utils/exportUtils';
1213

13-
import type { AutocompleteResult } from '@bibgraph/types';
14-
1514
interface ExportButtonProps {
1615
results: AutocompleteResult[];
1716
query: string;

apps/web/src/components/layout/MainLayout.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ import { Link } from "@tanstack/react-router";
3131
import React, { useCallback, useEffect, useRef, useState } from "react";
3232

3333
import { KeyboardShortcutsButton, KeyboardShortcutsHelp } from "@/components/modals/KeyboardShortcutsHelp";
34+
import { NotificationCenter } from "@/components/notifications/NotificationCenter";
35+
import { SyncStatusIndicator } from "@/components/sync/SyncStatusIndicator";
36+
import { UndoRedoControls } from "@/components/undo-redo/UndoRedoControls";
3437
import { ICON_SIZE } from "@/config/style-constants";
3538
import { useGlobalHotkeys } from "@/hooks/use-hotkeys";
3639
import { useLayoutStore } from "@/stores/layout-store";
@@ -46,9 +49,6 @@ import { ColorSchemeSelector } from "./ColorSchemeSelector";
4649
import { HeaderSearchInput } from "./HeaderSearchInput";
4750
import { HistorySidebar } from "./HistorySidebar";
4851
import { LeftRibbon } from "./LeftRibbon";
49-
import { NotificationCenter } from "@/components/notifications/NotificationCenter";
50-
import { UndoRedoControls } from "@/components/undo-redo/UndoRedoControls";
51-
import { SyncStatusIndicator } from "@/components/sync/SyncStatusIndicator";
5252
import { RightRibbon } from "./RightRibbon";
5353
import { RightSidebarContent } from "./RightSidebarContent";
5454
// import { ThemeDropdown } from "./ThemeDropdown";

apps/web/src/components/notifications/NotificationCenter.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* Shows toast-style notifications with mark as read and dismiss functionality.
66
*/
77

8-
import { useNotifications } from '@/contexts/NotificationContext';
9-
108
import {
119
ActionIcon,
1210
Box,
@@ -24,14 +22,15 @@ import {
2422
import { useDisclosure } from '@mantine/hooks';
2523
import {
2624
IconBell,
25+
IconBellOff,
2726
IconBellRinging,
2827
IconCheck,
29-
IconBellOff,
3028
IconX,
3129
} from '@tabler/icons-react';
3230
import { memo } from 'react';
3331

3432
import { ICON_SIZE } from '@/config/style-constants';
33+
import { useNotifications } from '@/contexts/NotificationContext';
3534

3635
interface NotificationBellProps {
3736
onClick: () => void;

apps/web/src/components/search/SearchInterface.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ import { useSearchHotkeys } from "@/hooks/use-hotkeys";
99
import { useSearchHistory } from "@/hooks/useSearchHistory";
1010
import { announceToScreenReader } from "@/utils/accessibility";
1111

12-
import { SearchHistoryDropdown } from "./SearchHistoryDropdown";
1312
import { AdvancedSearchFilters,SearchFilters } from "./SearchFilters";
13+
import { SearchHistoryDropdown } from "./SearchHistoryDropdown";
1414

1515
interface SearchFilters {
1616
query: string;

apps/web/src/components/sync/SyncStatusIndicator.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* Shows current state (idle, syncing, success, error, offline) with tooltips.
66
*/
77

8-
import { useSyncStatus } from '@/contexts/SyncStatusContext';
9-
import { ICON_SIZE } from '@/config/style-constants';
108
import { Badge, Box, Group, Stack, Text, Tooltip, UnstyledButton } from '@mantine/core';
119
import {
1210
IconAlertTriangle,
@@ -17,6 +15,9 @@ import {
1715
} from '@tabler/icons-react';
1816
import { memo, useMemo } from 'react';
1917

18+
import { ICON_SIZE } from '@/config/style-constants';
19+
import { useSyncStatus } from '@/contexts/SyncStatusContext';
20+
2021
const STATUS_CONFIG = {
2122
idle: {
2223
icon: IconCheck,

apps/web/src/components/undo-redo/UndoRedoControls.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55
* Integrates with global UndoRedoContext.
66
*/
77

8-
import { useUndoRedoContext } from '@/contexts/UndoRedoContext';
9-
import { ICON_SIZE } from '@/config/style-constants';
108
import {
119
ActionIcon,
1210
Box,
@@ -16,9 +14,12 @@ import {
1614
Text,
1715
Tooltip,
1816
} from '@mantine/core';
19-
import { IconHistory, IconRefresh, IconTrash, IconArrowBackUp, IconArrowForwardUp } from '@tabler/icons-react';
17+
import { IconArrowBackUp, IconArrowForwardUp,IconHistory, IconRefresh, IconTrash } from '@tabler/icons-react';
2018
import { memo } from 'react';
2119

20+
import { ICON_SIZE } from '@/config/style-constants';
21+
import { useUndoRedoContext } from '@/contexts/UndoRedoContext';
22+
2223
export const UndoRedoControls = memo(() => {
2324
const { canUndo, canRedo, undo, redo, clearHistory, historySize } = useUndoRedoContext();
2425

apps/web/src/contexts/ActivityContext.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
* Tracks user actions like create, update, delete, navigate, search, export, import.
66
*/
77

8-
import React, { createContext, useCallback, useContext, useState } from 'react';
8+
import React, { createContext, use, useCallback, useState } from 'react';
9+
910
import type { Activity, ActivityCategory, ActivityFilter } from '@/types/activity';
1011

1112
interface ActivityContextValue {
@@ -87,14 +88,14 @@ export const ActivityProvider: React.FC<{ children: React.ReactNode }> = ({ chil
8788
};
8889

8990
return (
90-
<ActivityContext.Provider value={value}>
91+
<ActivityContext value={value}>
9192
{children}
92-
</ActivityContext.Provider>
93+
</ActivityContext>
9394
);
9495
};
9596

9697
export const useActivity = (): ActivityContextValue => {
97-
const context = useContext(ActivityContext);
98+
const context = use(ActivityContext);
9899
if (!context) {
99100
throw new Error('useActivity must be used within ActivityProvider');
100101
}

apps/web/src/contexts/NotificationContext.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
import { type NotificationData, notifications } from '@mantine/notifications';
9-
import React, { createContext, useCallback, useContext, useState } from 'react';
9+
import React, { createContext, use, useCallback, useState } from 'react';
1010

1111
export type NotificationCategory = 'success' | 'error' | 'info' | 'warning';
1212

@@ -106,14 +106,14 @@ export const NotificationProvider: React.FC<{ children: React.ReactNode }> = ({
106106
};
107107

108108
return (
109-
<NotificationContext.Provider value={value}>
109+
<NotificationContext value={value}>
110110
{children}
111-
</NotificationContext.Provider>
111+
</NotificationContext>
112112
);
113113
};
114114

115115
export const useNotifications = (): NotificationContextValue => {
116-
const context = useContext(NotificationContext);
116+
const context = use(NotificationContext);
117117
if (!context) {
118118
throw new Error('useNotifications must be used within NotificationProvider');
119119
}

0 commit comments

Comments
 (0)