Skip to content

Commit 1d1d3c3

Browse files
authored
chore(lint): resolve ESLint warnings (#825)
* chore(lint): resolve ESLint warnings * fix(App): memoize pathParts for stable routing effect deps
1 parent ea838f9 commit 1d1d3c3

13 files changed

Lines changed: 50 additions & 102 deletions

File tree

SortVision/eslint.config.mjs

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,38 @@ export default [
3737
],
3838
'react-refresh/only-export-components': [
3939
'warn',
40-
{ allowConstantExport: true },
40+
{
41+
allowConstantExport: true,
42+
allowExportNames: [
43+
'generateMetadata',
44+
'generateStaticParams',
45+
'metadata',
46+
'viewport',
47+
'dynamic',
48+
'revalidate',
49+
'runtime',
50+
],
51+
},
4152
],
4253
'react-hooks/exhaustive-deps': 'warn',
4354
},
4455
},
56+
{
57+
files: ['public/code/**/*.js'],
58+
rules: {
59+
'no-unused-vars': 'off',
60+
},
61+
},
62+
{
63+
files: [
64+
'src/context/**/*.{js,jsx}',
65+
'src/components/MobileOverlay.jsx',
66+
'src/components/seo/LanguageDetection.jsx',
67+
'src/components/ui/badge.jsx',
68+
'src/components/ui/button.jsx',
69+
],
70+
rules: {
71+
'react-refresh/only-export-components': 'off',
72+
},
73+
},
4574
];

SortVision/server/index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,4 @@ app.post('/api/gemini', async (req, res) => {
6666
const PORT = process.env.PORT || 3001;
6767
app.listen(PORT, () => {
6868
console.log(`✅ Gemini proxy server running on port ${PORT}`);
69-
// Log the API key being used (first few characters only)
70-
const apiKey = process.env.NEXT_PUBLIC_GEMINI_API_KEY || 'not set';
71-
// Do not log API keys, even partially
7269
});

SortVision/src/App.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ const MainContent = () => {
9191
const fullText = t('main.subtitle');
9292

9393
// Extract tab and algorithm/contribution section from path-based routing
94-
const pathParts = location.pathname.split('/').filter(Boolean);
94+
const pathParts = useMemo(
95+
() => location.pathname.split('/').filter(Boolean),
96+
[location.pathname]
97+
);
9598

9699
// Handle language prefixes - check if first segment is a language code
97100
const supportedLanguages = [
@@ -204,6 +207,7 @@ const MainContent = () => {
204207
}
205208
}, [
206209
location.pathname,
210+
pathParts,
207211
tabFromPath,
208212
isAlgorithmPath,
209213
isContributionPath,

SortVision/src/app/[[...slug]]/page.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,6 @@ export async function generateStaticParams() {
550550
return params;
551551
}
552552

553-
export default function Page({ params }) {
553+
export default function Page({ params: _params }) {
554554
return <ClientOnly />;
555555
}

SortVision/src/app/[lang]/sitemap.xml/route.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export async function GET(_request, _params) {
1818
'Cache-Control': 'public, max-age=3600, s-maxage=3600',
1919
},
2020
});
21-
} catch (fileError) {
21+
} catch {
2222
// Fallback: Generate a basic sitemap if file doesn't exist
2323
const baseUrl = 'https://www.sortvision.com';
2424
const sitemap = `<?xml version="1.0" encoding="UTF-8"?>

SortVision/src/components/MobileOverlay.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ const MobileOverlay = () => {
9696
window.removeEventListener('orientationchange', handleOrientationChange);
9797
clearTimeout(orientationTimeout);
9898
};
99-
}, []);
99+
}, [setMobileOverlayVisible]);
100100

101101
const handleContinue = () => {
102102
setAnimationStage(4);

SortVision/src/components/PWAInstaller.jsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, { useState, useEffect, useRef, startTransition } from 'react';
1+
import React, { useState, useEffect, startTransition } from 'react';
22
import { Download, X, Wifi, WifiOff } from 'lucide-react';
33
import { Z_INDEX } from '../utils/zIndex';
44

@@ -8,9 +8,6 @@ const PWAInstaller = () => {
88
const [isOnline, setIsOnline] = useState(true);
99
const [isInstalled, setIsInstalled] = useState(false);
1010

11-
const timerRef = useRef(null);
12-
const fallbackTimerRef = useRef(null);
13-
1411
useEffect(() => {
1512
// Check if app is already installed
1613
if (
@@ -71,10 +68,7 @@ const PWAInstaller = () => {
7168
setIsOnline(navigator.onLine);
7269
});
7370

74-
// Cleanup
7571
return () => {
76-
if (timerRef.current) clearTimeout(timerRef.current);
77-
if (fallbackTimerRef.current) clearTimeout(fallbackTimerRef.current);
7872
window.removeEventListener(
7973
'beforeinstallprompt',
8074
handleBeforeInstallPrompt
@@ -83,7 +77,7 @@ const PWAInstaller = () => {
8377
window.removeEventListener('online', handleOnline);
8478
window.removeEventListener('offline', handleOffline);
8579
};
86-
}, []);
80+
}, [isInstalled]);
8781

8882
const handleInstallClick = async () => {
8983
if (process.env.NODE_ENV === 'development') {

SortVision/src/components/chatbot/assistantEngine.js

Lines changed: 1 addition & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ const generateCodeExamples = (algorithmName, language = 'javascript') => {
495495
};
496496

497497
// Enhanced algorithm recommendation system
498-
const generateAlgorithmRecommendation = (query, context) => {
498+
const generateAlgorithmRecommendation = (query, _context) => {
499499
const lowerQuery = query.toLowerCase();
500500

501501
// Use case based recommendations
@@ -1146,55 +1146,6 @@ export async function processMessage(query, context) {
11461146
}
11471147
}
11481148

1149-
// Generate responses as separate functions for readability and reusability
1150-
function generateDeveloperResponse() {
1151-
return `
1152-
<div class="animate-fade-in animate-duration-100 space-y-1 max-w-full">
1153-
<p class="m-0 leading-tight break-words">SortVision was created by <span class="text-indigo-400 font-semibold animate-pulse animate-duration-[800ms]">alienX (Prabal Patra)</span>, a passionate developer dedicated to making algorithm learning more interactive and fun! 🚀</p>
1154-
<div class="flex flex-col sm:flex-row flex-wrap gap-2 text-sm mt-1">
1155-
<a href="https://github.com/alienx5499" target="_blank" class="inline-flex items-center gap-1 px-3 py-2 rounded-md border border-emerald-400 text-emerald-300 hover:bg-emerald-400/10 transition-all duration-150">
1156-
🐙 GitHub
1157-
</a>
1158-
<a href="https://www.linkedin.com/in/prabalpatra5499/" target="_blank" class="inline-flex items-center gap-1 px-3 py-2 rounded-md border border-blue-400 text-blue-300 hover:bg-blue-400/10 transition-all duration-150">
1159-
💼 LinkedIn
1160-
</a>
1161-
<a href="https://x.com/alienx5499" target="_blank" class="inline-flex items-center gap-1 px-3 py-2 rounded-md border border-sky-400 text-sky-300 hover:bg-sky-400/10 transition-all duration-150">
1162-
🐦 Twitter
1163-
</a>
1164-
</div>
1165-
</div>`;
1166-
}
1167-
1168-
function generateSupportResponse() {
1169-
return `
1170-
<div class="animate-fade-in animate-duration-150 space-y-0.5 max-w-full">
1171-
<p class="m-0 leading-tight break-words">Thank you for considering supporting SortVision! 💖</p>
1172-
<div class="flex flex-col gap-2 mt-1">
1173-
<a href="https://github.com/alienx5499/SortVision" target="_blank" class="inline-flex items-center gap-1 px-3 py-2 rounded-md border border-yellow-400 text-yellow-300 hover:bg-yellow-400/10 transition-all duration-150 text-sm">
1174-
⭐ Star on GitHub
1175-
</a>
1176-
<a href="https://github.com/sponsors/alienx5499" target="_blank" class="inline-flex items-center gap-1 px-3 py-2 rounded-md border border-pink-400 text-pink-300 hover:bg-pink-400/10 transition-all duration-150 text-sm">
1177-
♥ Sponsor on GitHub
1178-
</a>
1179-
<a href="https://buymeacoffee.com/alienx5499" target="_blank" class="inline-flex items-center gap-1 px-3 py-2 rounded-md border border-yellow-500 text-yellow-400 hover:bg-yellow-500/10 transition-all duration-150 text-sm">
1180-
☕ Buy me a coffee
1181-
</a>
1182-
</div>
1183-
<p class="m-0 text-xs text-slate-400 animate-pulse animate-duration-[1000ms] break-words">Your support helps keep SortVision free and improving! 🙏</p>
1184-
</div>`;
1185-
}
1186-
1187-
function generateGithubResponse() {
1188-
return `
1189-
<div class="animate-fade-in animate-duration-150 space-y-0.5 max-w-full">
1190-
<p class="m-0 leading-tight break-words">You can find SortVision on GitHub <a href="https://github.com/alienx5499/SortVision" target="_blank" class="text-blue-400 hover:text-blue-300 underline transition-colors duration-150">here</a>!</p>
1191-
<div class="animate-bounce animate-duration-[1000ms]">
1192-
<p class="text-sm break-words">If you find this project helpful, please give it a ⭐️ star on GitHub!</p>
1193-
</div>
1194-
<p class="m-0 text-xs text-slate-400 break-words">Your support helps us grow and improve! 🙏</p>
1195-
</div>`;
1196-
}
1197-
11981149
function generateThankYouResponse() {
11991150
return `
12001151
<div class="animate-fade-in animate-duration-150 space-y-0.5 max-w-full">

SortVision/src/components/feedback/FeedbackModal.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ const FeedbackModal = ({ isOpen, onClose }) => {
130130
if (isOpen && !locationData) {
131131
detectUserLocationEnhanced();
132132
}
133+
// eslint-disable-next-line react-hooks/exhaustive-deps -- run when modal opens; including locationData or the detector would loop or churn
133134
}, [isOpen]);
134135

135136
// Track time spent on site
@@ -361,8 +362,7 @@ const FeedbackModal = ({ isOpen, onClose }) => {
361362
if (storedErrors) {
362363
errors.push(...JSON.parse(storedErrors));
363364
}
364-
} catch (_e) {
365-
// eslint-disable-line no-unused-vars
365+
} catch {
366366
// Ignore localStorage errors
367367
}
368368
return errors.slice(-5); // Last 5 errors
@@ -372,8 +372,7 @@ const FeedbackModal = ({ isOpen, onClose }) => {
372372
try {
373373
const usage = localStorage.getItem('sortvision_feature_usage');
374374
return usage ? JSON.parse(usage) : null;
375-
} catch (_e) {
376-
// eslint-disable-line no-unused-vars
375+
} catch {
377376
return null;
378377
}
379378
};

SortVision/src/components/feedback/githubService.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ ${formatErrorHistory(feedbackData.errorHistory)}
468468
let errorData;
469469
try {
470470
errorData = await response.json();
471-
} catch (parseError) {
472-
// eslint-disable-line no-unused-vars
471+
} catch {
473472
errorData = {
474473
message: `HTTP ${response.status}: ${response.statusText}`,
475474
};

0 commit comments

Comments
 (0)