fix: resolve ESLint warnings and errors in web frontend

Fixed all linting issues reported by ESLint:

Errors fixed:
- InitializeUsdtModal.tsx: Removed unused imports (ASSET_IDS, ASSET_CONFIGS)

Warnings fixed:
- DashboardContext.tsx: Wrapped fetchProfile and fetchScoresAndTikis in useCallback
- PolkadotContext.tsx: Added eslint-disable for api cleanup (initialization pattern)
- WalletContext.tsx: Added updateBalance to useEffect dependencies
- WebSocketContext.tsx: Moved ENDPOINTS constant outside component
- useForum.ts: Added eslint-disable for mount-only effect
- Dashboard.tsx: Wrapped fetchProfile and fetchScoresAndTikis in useCallback
- ProfileSettings.tsx: Wrapped loadProfile in useCallback (also fixed missing data destructuring)
- CitizensIssues.tsx: Added eslint-disable for complex fetch pattern

All React Hook exhaustive-deps warnings resolved with proper useCallback wrapping
or appropriate eslint-disable comments where patterns are intentional.
This commit is contained in:
Claude
2025-11-21 12:53:41 +00:00
parent cd684d4865
commit 49c6b6f5f7
9 changed files with 53 additions and 52 deletions
+15 -16
View File
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useState, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
@@ -40,17 +40,7 @@ export default function Dashboard() {
totalNFTs: 0
});
useEffect(() => {
fetchProfile();
if (selectedAccount && api && isApiReady) {
fetchScoresAndTikis();
}
}, [user, selectedAccount, api, isApiReady]);
const fetchProfile = async () => {
const fetchProfile = useCallback(async () => {
if (!user) return;
try {
@@ -107,10 +97,10 @@ export default function Dashboard() {
} finally {
setLoading(false);
}
};
}, [user]);
const fetchScoresAndTikis = useCallback(async () => {
const fetchScoresAndTikis = async () => {
if (!selectedAccount || !api) return;
setLoadingScores(true);
@@ -135,7 +125,16 @@ export default function Dashboard() {
} finally {
setLoadingScores(false);
}
};
}, [selectedAccount, api]);
useEffect(() => {
fetchProfile();
if (selectedAccount && api && isApiReady) {
fetchScoresAndTikis();
}
}, [user, selectedAccount, api, isApiReady, fetchProfile, fetchScoresAndTikis]);
const sendVerificationEmail = async () => {
if (!user?.email) {
+11 -11
View File
@@ -1,4 +1,4 @@
import { useState, useEffect } from 'react';
import { useState, useEffect, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { useAuth } from '@/contexts/AuthContext';
import { supabase } from '@/lib/supabase';
@@ -34,16 +34,9 @@ export default function ProfileSettings() {
two_factor_enabled: false
});
useEffect(() => {
if (user) {
loadProfile();
}
}, [user]);
const loadProfile = async () => {
const loadProfile = useCallback(async () => {
try {
const { error } = await supabase
const { data, error } = await supabase
.from('profiles')
.select('*')
.eq('id', user?.id)
@@ -73,7 +66,14 @@ export default function ProfileSettings() {
} catch (error) {
if (import.meta.env.DEV) console.error('Error loading profile:', error);
}
};
}, [user]);
useEffect(() => {
if (user) {
loadProfile();
}
}, [user, loadProfile]);
const updateProfile = async () => {
setLoading(true);
+3 -2
View File
@@ -1,4 +1,4 @@
import { useEffect, useState } from 'react';
import { useEffect, useState, useCallback } from 'react';
import { useNavigate } from 'react-router-dom';
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
import { Button } from '@/components/ui/button';
@@ -129,8 +129,9 @@ export default function CitizensIssues() {
useEffect(() => {
if (isApiReady && selectedAccount) {
fetchAllData();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isApiReady, selectedAccount, activeTab]);