fixed linting issues#99
Conversation
There was a problem hiding this comment.
Pull request overview
This PR aims to resolve frontend lint warnings by removing unused imports/variables, renaming unused parameters, and adjusting ESLint rule severity/settings across the React app and service layer.
Changes:
- Remove/rename unused imports and parameters across services, pages, hooks, and components.
- Add/adjust several hook-related implementations (e.g.,
useCallback) and inline ESLint suppressions. - Update ESLint configuration to relax unused-vars enforcement and disable
react-hooks/exhaustive-deps.
Reviewed changes
Copilot reviewed 54 out of 54 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/services/price.service.js | Adjusts error handling in getComparison and renames catch variable. |
| frontend/src/services/order.service.js | Removes unused authService import. |
| frontend/src/services/notification.service.js | Comments out unused local variable and prefixes unused params with _. |
| frontend/src/services/negotiation.service.js | Removes redundant try/catch; removes unused authService import. |
| frontend/src/services/dispute.service.js | Removes unused authService import; comments out unused persistence helper. |
| frontend/src/services/crop.service.js | Removes unused authService import; prefixes unused param with _. |
| frontend/src/pages/orders/OrderSummary.jsx | Drops unused default React import. |
| frontend/src/pages/orders/OrderStatus.jsx | Drops unused default React import. |
| frontend/src/pages/orders/OrderHistory.jsx | Drops unused default React import. |
| frontend/src/pages/orders/MyDisputes.jsx | Drops unused default React import; removes unused authService import. |
| frontend/src/pages/orders/DisputeDetails.jsx | Drops unused default React import. |
| frontend/src/pages/official/SchemesManager.jsx | Drops unused default React import; adds console logging in error paths. |
| frontend/src/pages/official/QualityStandards.jsx | Drops unused default React import; adds console logging in error paths. |
| frontend/src/pages/official/OfficialDashboard.jsx | Drops unused default React import. |
| frontend/src/pages/official/KycVerification.jsx | Drops unused default React import; adds console logging in error paths. |
| frontend/src/pages/official/DisputeTribunal.jsx | Drops unused default React import; adds console logging in error paths. |
| frontend/src/pages/official/AdvisoryManager.jsx | Drops unused default React import; adds console logging in error paths. |
| frontend/src/pages/logistics/LogisticsDashboard.jsx | Removes unused motion import (but still uses <motion.*>); adds console logging in error paths. |
| frontend/src/pages/admin/AdminLogin.jsx | Drops unused default React import. |
| frontend/src/pages/admin/AdminDisputes.jsx | Drops unused default React import; comments out unused variable; adds console logging in an error path. |
| frontend/src/pages/SchemesPage.jsx | Removes unused React import. |
| frontend/src/pages/SalesRevenue.jsx | Reworks filtering with useCallback and changes effects ordering; adds inline ESLint disables. |
| frontend/src/pages/ReviewsAndTrust.jsx | Drops unused default React import. |
| frontend/src/pages/Register.jsx | Removes unused imports and state; modifies language selection state; (but still uses <motion.*> without importing motion). |
| frontend/src/pages/QualityPricing.jsx | Removes unused icon import. |
| frontend/src/pages/Profile.jsx | Removes unused catch parameter. |
| frontend/src/pages/PriceInsights.jsx | Adds inline disables for unused vars. |
| frontend/src/pages/Otp.jsx | Removes motion import (but still uses <motion.*>). |
| frontend/src/pages/NegotiationHistory.jsx | Drops unused default React import. |
| frontend/src/pages/NegotiationDetail.jsx | Removes unused socket var; renames unused state updater param. |
| frontend/src/pages/Marketplace.jsx | Removes unused imports; removes unused setters by keeping state values only. |
| frontend/src/pages/Login.jsx | Removes motion import (but still uses <motion.*>). |
| frontend/src/pages/DemandForecast.jsx | Removes unused icon import; comments out unused callback; adds inline disable for unused state. |
| frontend/src/pages/Dashboard.jsx | Comments out unused imports/state setters; adds inline disable for unused handler. |
| frontend/src/pages/CropPlanning.jsx | Removes unused default React import and unused icons. |
| frontend/src/pages/CropDetails.jsx | Drops unused default React import and unused icons. |
| frontend/src/i18n/i18n.js | Removes duplicate/unused init properties at the bottom of the config block. |
| frontend/src/hooks/useVoiceNavigation.js | Removes unused catch binding; comments out unused variable. |
| frontend/src/hooks/useDynamicTranslation.js | Comments out unused state; suppresses unused catch param. |
| frontend/src/components/schemes/SchemesList.jsx | Drops unused default React import. |
| frontend/src/components/schemes/ContextualSchemeAlert.jsx | Drops unused default React import; removes unused icons from import. |
| frontend/src/components/schemes/AdvisoryFeed.jsx | Drops unused default React import. |
| frontend/src/components/marketplace/NegotiationModal.jsx | Drops unused default React import. |
| frontend/src/components/marketplace/CropForm.jsx | Removes unused import; changes useEffect state update logic; adds inline ESLint disable. |
| frontend/src/components/marketplace/CropCard.jsx | Removes unused icon import. |
| frontend/src/components/layout/Sidebar.jsx | Removes unused React import; comments out unused role flags. |
| frontend/src/components/layout/OfficialSidebar.jsx | Removes unused React import. |
| frontend/src/components/layout/Header.jsx | Removes motion import (but still uses <motion.*>); renames prop to avoid unused var. |
| frontend/src/components/dashboard/RotationAdvisoryCard.jsx | Drops unused default React import; removes unused icons from import. |
| frontend/src/components/common/LanguageSelector.jsx | Comments out motion import (but still uses <motion.*>). |
| frontend/src/components/common/GlobalVoiceButton.jsx | Removes motion import (but still uses <motion.*>). |
| frontend/src/components/common/DynamicText.jsx | Removes unused React import; renames Component prop binding to avoid conflicts/unused warnings. |
| frontend/eslint.config.js | Relaxes no-unused-vars to warn, adds argsIgnorePattern, disables react-hooks/exhaustive-deps. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| import React, { useState, useRef, useEffect } from "react"; | ||
| import { Search, Bell, User, ChevronRight, LogOut, MessageSquare, Gavel, AlertCircle } from "lucide-react"; | ||
| import { motion, AnimatePresence } from "framer-motion"; | ||
| import { AnimatePresence } from "framer-motion"; |
There was a problem hiding this comment.
motion is still used in this component (<motion.div>), but the import was changed to only bring in AnimatePresence. This will cause motion to be undefined at runtime; import motion from framer-motion (or stop using the motion.* components).
| import { AnimatePresence } from "framer-motion"; | |
| import { motion, AnimatePresence } from "framer-motion"; |
| import { useState, useEffect } from "react"; | ||
| import { useNavigate, useLocation } from "react-router-dom"; | ||
| import { motion, AnimatePresence } from "framer-motion"; | ||
| import { AnimatePresence } from "framer-motion"; |
There was a problem hiding this comment.
This file still renders multiple <motion.*> components, but the framer-motion import was reduced to only AnimatePresence. That makes motion undefined and will break the OTP page at runtime; import motion as well (or refactor to not use motion components).
| import { AnimatePresence } from "framer-motion"; | |
| import { motion, AnimatePresence } from "framer-motion"; |
| // import { motion, AnimatePresence } from "framer-motion"; | ||
| import { AnimatePresence } from "framer-motion"; |
There was a problem hiding this comment.
motion is used (<motion.div>), but the import was changed to only AnimatePresence and motion is commented out. This will break the dropdown animation at runtime; import motion from framer-motion (or remove the motion.* JSX).
| // import { motion, AnimatePresence } from "framer-motion"; | |
| import { AnimatePresence } from "framer-motion"; | |
| import { motion, AnimatePresence } from "framer-motion"; |
| import React from 'react'; | ||
| import { Mic, AlertCircle } from 'lucide-react'; | ||
| import { motion, AnimatePresence } from 'framer-motion'; | ||
| import { AnimatePresence } from 'framer-motion'; |
There was a problem hiding this comment.
This component renders <motion.div>, but the import was changed to only import AnimatePresence. That makes motion undefined at runtime; import motion from framer-motion (or refactor to not use motion.*).
| import { AnimatePresence } from 'framer-motion'; | |
| import { motion, AnimatePresence } from 'framer-motion'; |
| try { | ||
| const response = await api.get("/prices/compare", { params }); | ||
| return response.data; | ||
| } catch (error) { | ||
| } catch (err) { | ||
| // If 404 (no data), return null or valid structure | ||
| console.log(err) | ||
| return null; | ||
| } |
There was a problem hiding this comment.
getComparison currently returns null for any error, but the comment says this is specifically for a 404/no-data case. This can silently hide real failures (network/auth/server errors) and make callers treat them as "no comparison". Consider only returning null when the response status is 404, and otherwise logging with console.error and/or rethrowing so the UI can show an error state.
| import { useNavigate, Link } from "react-router-dom"; | ||
| import { motion } from "framer-motion"; | ||
| import { useTranslation } from "react-i18next"; | ||
| import { Leaf, User, Phone, Lock, ArrowRight, Loader2, Sprout, MapPin, Home, Languages } from "lucide-react"; | ||
| import authService from "../services/auth.service"; | ||
| import AuthCard from "../components/common/AuthCard"; // Keeping for reference if needed elsewhere, but not using here. | ||
| import authService from "../services/auth.service";// Keeping for reference if needed elsewhere, but not using here. | ||
| import { useState } from "react"; |
There was a problem hiding this comment.
<motion.div> is still used in this file, but the motion import from framer-motion was removed. This will throw at runtime; add back the motion import (or remove the motion.* components).
| CalendarClock | ||
| } from "lucide-react"; | ||
| import { motion, AnimatePresence } from "framer-motion"; | ||
| import { AnimatePresence } from "framer-motion"; | ||
| import orderService from "../../services/order.service"; |
There was a problem hiding this comment.
The framer-motion import now only includes AnimatePresence, but this component still renders <motion.div> in several places. motion will be undefined at runtime; import motion from framer-motion (or remove motion.* usage).
| useEffect(() => { | ||
| if (initialData) { | ||
| setFormData(initialData); | ||
| // Only update if data is truly different to avoid loops | ||
| // eslint-disable-next-line react-hooks/set-state-in-effect | ||
| setFormData(prev => { | ||
| if(JSON.stringify(prev) !== JSON.stringify(initialData)) { | ||
| return initialData; | ||
| } |
There was a problem hiding this comment.
The inline disable react-hooks/set-state-in-effect does not correspond to a rule provided by eslint-plugin-react-hooks (it only provides rules-of-hooks and exhaustive-deps). Using a non-existent rule name can cause ESLint warnings and doesn't actually suppress anything meaningful. Remove this directive and, if needed, address the actual hook lint (typically react-hooks/exhaustive-deps) or refactor to avoid the extra state update.
| useEffect(() => { | ||
| // eslint-disable-next-line react-hooks/set-state-in-effect | ||
| loadSalesData(); | ||
| }, []); | ||
|
|
||
| useEffect(() => { | ||
| // eslint-disable-next-line react-hooks/set-state-in-effect | ||
| filterSales(); | ||
| }, [filterSales]); |
There was a problem hiding this comment.
The // eslint-disable-next-line react-hooks/set-state-in-effect directives reference a rule that doesn't exist in eslint-plugin-react-hooks. This can produce ESLint warnings and doesn't reliably document what is being suppressed. Remove these directives and fix the underlying hook lint (usually react-hooks/exhaustive-deps) or refactor the effects so they don't need suppression.
| import { Leaf, User, Phone, Lock, ArrowRight, Loader2, Sprout, MapPin, Home, Languages } from "lucide-react"; | ||
| import authService from "../services/auth.service"; | ||
| import AuthCard from "../components/common/AuthCard"; // Keeping for reference if needed elsewhere, but not using here. | ||
| import authService from "../services/auth.service";// Keeping for reference if needed elsewhere, but not using here. | ||
| import { useState } from "react"; |
There was a problem hiding this comment.
The comment on the authService import says it's "not using here", but authService.register(...) is called in this file. This is misleading and should be removed or corrected.
No description provided.