1nwf / Produx-v2

Found unused variables in TypeScript code JS-0356
Performance
Major
40 occurrences in this check
'error' is assigned a value but never used
 2import Image from 'next/image'
 3import { ProductResponse } from '../state/reducers/api'
 4export default function ShowProducts() {
 5    const { data, error, isLoading } = useGetProductsQuery({ page: 1 }) 6    const { products } = data ? (data as ProductResponse) : { products: [] }
 7    return (
 8        <div>
'error' is assigned a value but never used
16    })
17    const fileRef = useRef() as MutableRefObject<HTMLInputElement>
18    const [img, setImg] = useState('')
19    const [createUser, { error, isLoading }] = useCreateUserMutation()20    const handleImg = (e: ChangeEvent<HTMLInputElement>) => {
21        if (e.target.files) {
22            setUserInfo({ ...userInfo, pfp: e.target.files[0] })
'isLoading' is assigned a value but never used
16    })
17    const fileRef = useRef() as MutableRefObject<HTMLInputElement>
18    const [img, setImg] = useState('')
19    const [createUser, { error, isLoading }] = useCreateUserMutation()20    const handleImg = (e: ChangeEvent<HTMLInputElement>) => {
21        if (e.target.files) {
22            setUserInfo({ ...userInfo, pfp: e.target.files[0] })
'img' is assigned a value but never used
15        pfp: null,
16    })
17    const fileRef = useRef() as MutableRefObject<HTMLInputElement>
18    const [img, setImg] = useState('')19    const [createUser, { error, isLoading }] = useCreateUserMutation()
20    const handleImg = (e: ChangeEvent<HTMLInputElement>) => {
21        if (e.target.files) {
'setImg' is assigned a value but never used
15        pfp: null,
16    })
17    const fileRef = useRef() as MutableRefObject<HTMLInputElement>
18    const [img, setImg] = useState('')19    const [createUser, { error, isLoading }] = useCreateUserMutation()
20    const handleImg = (e: ChangeEvent<HTMLInputElement>) => {
21        if (e.target.files) {
'useRouter' is defined but never used
 4import { useAppDispatch } from '../../state/hooks'
 5import { changeAuthStatus } from '../../state/reducers/auth'
 6import { useCreateUserMutation } from '../../state/reducers/api'
 7import { useRouter } from 'next/router' 8export default function Register() {
 9    const [userInfo, setUserInfo] = useState<
10        Pick<User, 'name' | 'email'> & { password: string; pfp: File | null }
14        password: '',
15    })
16
17    const submitHandler = async (e: any) => {18        await signIn(userInfo)
19            .then((res: any) => {
20                localStorage.setItem('token', res.data.token)
'error' is assigned a value but never used
 2import { useGetTopProductsQuery } from '../../state/reducers/api'
 3
 4export default function TopProducts() {
 5    const { data, error, isLoading } = useGetTopProductsQuery() 6    return (
 7        <div className="">
 8            <h1 className="bg-gray-200 p-6 flex justify-center mr-2 rounded-box  ">
'isLoading' is assigned a value but never used
 5import { useRouter } from 'next/router'
 6import AccessPrivateProduct from './AccessPrivateProduct'
 7export default function SearchProducts({ name }: { name: string }) {
 8    const { data, isLoading, error } = useGetProductsQuery({ 9        name: name,
10        page: 1,
11    })
'error' is assigned a value but never used
 5import { useRouter } from 'next/router'
 6import AccessPrivateProduct from './AccessPrivateProduct'
 7export default function SearchProducts({ name }: { name: string }) {
 8    const { data, isLoading, error } = useGetProductsQuery({ 9        name: name,
10        page: 1,
11    })
'filters' is assigned a value but never used
 28    const { data, isLoading, error } = useGetUserInfoQuery()
 29    const mdBreakpoint = 1024
 30    const channelName = channel.charAt(0).toUpperCase() + channel.slice(1)
 31    const filters = ['😱 All Posts', '🎉 Latest Posts', '🙌 Most Upvoted Posts'] 32    const [width, setWidth] = useState(window.innerWidth)
 33    useEffect(() => {
 34        if (window !== undefined) {
'isLoading' is assigned a value but never used
 25    }
 26    const [followProduct] = useFollowProductMutation()
 27    const [follow, setFollow] = useState(false)
 28    const { data, isLoading, error } = useGetUserInfoQuery() 29    const mdBreakpoint = 1024
 30    const channelName = channel.charAt(0).toUpperCase() + channel.slice(1)
 31    const filters = ['😱 All Posts', '🎉 Latest Posts', '🙌 Most Upvoted Posts']
'error' is assigned a value but never used
 25    }
 26    const [followProduct] = useFollowProductMutation()
 27    const [follow, setFollow] = useState(false)
 28    const { data, isLoading, error } = useGetUserInfoQuery() 29    const mdBreakpoint = 1024
 30    const channelName = channel.charAt(0).toUpperCase() + channel.slice(1)
 31    const filters = ['😱 All Posts', '🎉 Latest Posts', '🙌 Most Upvoted Posts']
'handleChannelChange' is assigned a value but never used
10        Changelogs: { icon: '🔑', color: '#FF4D00' },
11        Questions: { icon: '🤨', color: '#FF4D00' },
12    }
13    const handleChannelChange = (e: any) => {14        e.preventDefault()
15    }
16    return (
'isLoading' is assigned a value but never used
 13    productUserID: number
 14}) {
 15    const [filteredUsers, setFilteredUsers] = useState(users)
 16    const [updateRole, { data, error, isLoading }] = useUpdateUserRoleMutation() 17    const onlineUsers = useAppSelector((state) => state.product.onlineUsers)
 18    const [showUserInfo, setShowUserInfo] = useState({
 19        show: false,
'data' is assigned a value but never used
 13    productUserID: number
 14}) {
 15    const [filteredUsers, setFilteredUsers] = useState(users)
 16    const [updateRole, { data, error, isLoading }] = useUpdateUserRoleMutation() 17    const onlineUsers = useAppSelector((state) => state.product.onlineUsers)
 18    const [showUserInfo, setShowUserInfo] = useState({
 19        show: false,
'setPosts' is assigned a value but never used
 24        Suggestions: { icon: '🙏', color: '#0094FF' },
 25        Changelogs: { icon: '🔑', color: '#FF4D00' },
 26    }
 27    const [posts, setPosts] = useState(data ? data.posts : []) 28    const observer = useRef()
 29    const lastPostRef = useCallback(
 30        (node) => {
'error' is assigned a value but never used
 14    channel: string
 15}) {
 16    const [showAdd, setShowAdd] = useState(false)
 17    const { data, isLoading, error } = useGetPostsQuery({ 18        productId,
 19        channel: channel.toLowerCase(),
 20    })
'res' is assigned a value but never used
 75            for (let i = 0; i < images.length; i++) {
 76                formData.set(`image${i + 1}`, images[i])
 77            }
 78            const res = await createPost({ 79                productName,
 80                channel: `${selectedTag.toLowerCase()}s`,
 81                post: formData,
'data' is assigned a value but never used
 31        : Object.keys(tags).filter(
 32              (tag) => tag !== 'Announcement' && tag !== 'Changelog'
 33          )
 34    const [createPost, { data, isLoading, error }] = useCreatePostMutation() 35    const [selectedTag, setSelectedTag] = useState(
 36        allowedTags.includes(currentChannel) ? currentChannel : allowedTags[0]
 37    )
  8    show,
  9    setShow,
 10    productName,
 11    owner, 12}: {
 13    show: boolean
 14    setShow: any
'submit' is assigned a value but never used
 60        )
 61        confetti.reset()
 62    }
 63    const [submit, setSubmit] = useState(false) 64    return (
 65        <div>
 66            <Modal
'file1' is assigned a value but never used
 56                ...product,
 57                images: [e.target.files[0]],
 58            } as NewProduct
 59            const file1 = e.target.files[0] 60            setProduct(newProductData)
 61        }
 62    }
'preview' is assigned a value but never used
 51    }
 52    const handleProductImage = (e: ChangeEvent<HTMLInputElement>) => {
 53        if (e.target.files) {
 54            let preview = URL.createObjectURL(e.target.files[0]) 55            const newProductData = {
 56                ...product,
 57                images: [e.target.files[0]],
 10import {
 11    ChangeEvent,
 12    MutableRefObject,
 13    useEffect, 14    useRef,
 15    useState,
 16} from 'react'