Skip to content

Tech Debt: Minor Linting and React Hook Warnings #171

Description

@Aamod-Dev

Description
During a codebase scan, several minor technical debt items and linting warnings were identified across the frontend and backend. While they do not cause immediate crashes, they create noisy logs, trigger linter warnings, and include technically incorrect logic.
Specifically:

  • In ProductCard.jsx, the checkInWishlist function from WishlistContext.jsx (which is a synchronous array check using .some()) is unnecessarily prefixed with await inside a useEffect.
  • On the backend, there are unused error variables in catch (error) blocks within product.controller.js and authMiddleware.js.
  • The global error handler in errorMiddleware.js triggers an "unused next variable" warning from ESLint. Express requires all four parameters (err, req, res, next) for it to be recognized as an error handler, so it should be renamed to _next to satisfy the linter.

Steps to reproduce

  1. Run npx eslint BACKEND/ --ext .js in the terminal to see the unused variable warnings.
  2. Open FRONTEND/src/components/ui/ProductCard.jsx and look at the checkInWishlist call in the useEffect.

Expected behaviour

  • Remove the await keyword from the synchronous checkInWishlist call.
  • Remove the unused error variables from catch blocks or prefix them with _ (e.g., catch (_error)).
  • Rename next to _next in errorMiddleware.js.

Affected files

  • FRONTEND/src/components/ui/ProductCard.jsx
  • BACKEND/controllers/product.controller.js
  • BACKEND/middleware/authMiddleware.js
  • BACKEND/middleware/errorMiddleware.js

Notes
These are quick cleanup tasks to keep the linter happy, maintain code hygiene, and prevent confusion for future contributors.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions