-
Notifications
You must be signed in to change notification settings - Fork 0
Fix ESLint warnings for fast refresh and hook dependencies #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,7 +2,7 @@ import { useEffect, useState } from 'react'; | |||||
| import { ExternalLink, Music, Sparkles, Loader2 } from 'lucide-react'; | ||||||
| import { Button } from './ui/button'; | ||||||
| import { useAuth } from '@/contexts/AuthContext'; | ||||||
| import { toast } from 'sonner'; | ||||||
| import { toast } from '@/lib/toast'; | ||||||
| import { Room } from '@/types/wejay'; | ||||||
|
|
||||||
| interface SpotifyPlaylistSyncProps { | ||||||
|
|
@@ -22,7 +22,7 @@ export function SpotifyPlaylistSync({ playlistUrl, hasTracksInQueue, room }: Spo | |||||
| if (playlistUrl && !url) { | ||||||
| setUrl(playlistUrl); | ||||||
| } | ||||||
| }, [playlistUrl]); | ||||||
| }, [playlistUrl, url]); | ||||||
|
||||||
| }, [playlistUrl, url]); | |
| }, [playlistUrl]); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| import { cva, type VariantProps } from "class-variance-authority"; | ||
|
|
||
| export const badgeVariants = cva( | ||
| "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", | ||
| { | ||
| variants: { | ||
| variant: { | ||
| default: | ||
| "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", | ||
| secondary: | ||
| "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", | ||
| destructive: | ||
| "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", | ||
| outline: "text-foreground", | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| variant: "default", | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| export type BadgeVariants = VariantProps<typeof badgeVariants>; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,29 +1,12 @@ | ||
| import * as React from "react"; | ||
| import { cva, type VariantProps } from "class-variance-authority"; | ||
| import { badgeVariants, type BadgeVariants } from "./badge-variants"; | ||
|
|
||
| import { cn } from "@/lib/utils"; | ||
|
|
||
| const badgeVariants = cva( | ||
| "inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2", | ||
| { | ||
| variants: { | ||
| variant: { | ||
| default: "border-transparent bg-primary text-primary-foreground hover:bg-primary/80", | ||
| secondary: "border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80", | ||
| destructive: "border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80", | ||
| outline: "text-foreground", | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| variant: "default", | ||
| }, | ||
| }, | ||
| ); | ||
|
|
||
| export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, VariantProps<typeof badgeVariants> {} | ||
| export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement>, BadgeVariants {} | ||
|
|
||
| function Badge({ className, variant, ...props }: BadgeProps) { | ||
| return <div className={cn(badgeVariants({ variant }), className)} {...props} />; | ||
| } | ||
|
|
||
| export { Badge, badgeVariants }; | ||
| export { Badge }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,32 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { cva, type VariantProps } from "class-variance-authority"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const buttonVariants = cva( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variants: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: "bg-primary text-primary-foreground hover:bg-primary/90", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| destructive: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "bg-destructive text-destructive-foreground hover:bg-destructive/90", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| outline: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "border border-input bg-background hover:bg-accent hover:text-accent-foreground", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| secondary: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "bg-secondary text-secondary-foreground hover:bg-secondary/80", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ghost: "hover:bg-accent hover:text-accent-foreground", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| link: "text-primary underline-offset-4 hover:underline", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| size: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: "h-10 px-4 py-2", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| sm: "h-9 rounded-md px-3", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| lg: "h-11 rounded-md px-8", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| icon: "h-10 w-10", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| defaultVariants: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variant: "default", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| size: "default", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export type ButtonVariants = VariantProps<typeof buttonVariants>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+32
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { cva, type VariantProps } from "class-variance-authority"; | |
| export const buttonVariants = cva( | |
| "inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50", | |
| { | |
| variants: { | |
| variant: { | |
| default: "bg-primary text-primary-foreground hover:bg-primary/90", | |
| destructive: | |
| "bg-destructive text-destructive-foreground hover:bg-destructive/90", | |
| outline: | |
| "border border-input bg-background hover:bg-accent hover:text-accent-foreground", | |
| secondary: | |
| "bg-secondary text-secondary-foreground hover:bg-secondary/80", | |
| ghost: "hover:bg-accent hover:text-accent-foreground", | |
| link: "text-primary underline-offset-4 hover:underline", | |
| }, | |
| size: { | |
| default: "h-10 px-4 py-2", | |
| sm: "h-9 rounded-md px-3", | |
| lg: "h-11 rounded-md px-8", | |
| icon: "h-10 w-10", | |
| }, | |
| }, | |
| defaultVariants: { | |
| variant: "default", | |
| size: "default", | |
| }, | |
| } | |
| ); | |
| export type ButtonVariants = VariantProps<typeof buttonVariants>; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { cva, type VariantProps } from "class-variance-authority"; | ||
|
|
||
| export const toggleVariants = cva( | ||
| "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground", | ||
| { | ||
| variants: { | ||
| variant: { | ||
| default: "bg-transparent", | ||
| outline: | ||
| "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground", | ||
| }, | ||
| size: { | ||
| default: "h-10 px-3", | ||
| sm: "h-9 px-2.5", | ||
| lg: "h-11 px-5", | ||
| }, | ||
| }, | ||
| defaultVariants: { | ||
| variant: "default", | ||
| size: "default", | ||
| }, | ||
| } | ||
| ); | ||
|
|
||
| export type ToggleVariants = VariantProps<typeof toggleVariants>; |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,37 +1,16 @@ | ||||||||
| import * as React from "react"; | ||||||||
| import * as TogglePrimitive from "@radix-ui/react-toggle"; | ||||||||
| import { cva, type VariantProps } from "class-variance-authority"; | ||||||||
| import { toggleVariants, type ToggleVariants } from "./toggle-variants"; | ||||||||
|
|
||||||||
| import { cn } from "@/lib/utils"; | ||||||||
|
|
||||||||
| const toggleVariants = cva( | ||||||||
| "inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground", | ||||||||
| { | ||||||||
| variants: { | ||||||||
| variant: { | ||||||||
| default: "bg-transparent", | ||||||||
| outline: "border border-input bg-transparent hover:bg-accent hover:text-accent-foreground", | ||||||||
| }, | ||||||||
| size: { | ||||||||
| default: "h-10 px-3", | ||||||||
| sm: "h-9 px-2.5", | ||||||||
| lg: "h-11 px-5", | ||||||||
| }, | ||||||||
| }, | ||||||||
| defaultVariants: { | ||||||||
| variant: "default", | ||||||||
| size: "default", | ||||||||
| }, | ||||||||
| }, | ||||||||
| ); | ||||||||
|
|
||||||||
| const Toggle = React.forwardRef< | ||||||||
| React.ElementRef<typeof TogglePrimitive.Root>, | ||||||||
| React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & VariantProps<typeof toggleVariants> | ||||||||
| React.ComponentPropsWithoutRef<typeof TogglePrimitive.Root> & ToggleVariants | ||||||||
| >(({ className, variant, size, ...props }, ref) => ( | ||||||||
| <TogglePrimitive.Root ref={ref} className={cn(toggleVariants({ variant, size, className }))} {...props} /> | ||||||||
| )); | ||||||||
|
|
||||||||
| Toggle.displayName = TogglePrimitive.Root.displayName; | ||||||||
|
|
||||||||
| export { Toggle, toggleVariants }; | ||||||||
| export { Toggle }; | ||||||||
|
||||||||
| export { Toggle }; | |
| export { Toggle }; | |
| export { toggleVariants, ToggleVariants }; |
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
| @@ -1,7 +1,7 @@ | ||||
| import { useEffect, useState, useCallback, useRef } from 'react'; | ||||
| import { useAuth } from '@/contexts/AuthContext'; | ||||
| import { Room, Track, SpotifyUser } from '@/types/wejay'; | ||||
| import { toast } from 'sonner'; | ||||
| import { toast } from '@/lib/toast'; | ||||
|
||||
| import { toast } from '@/lib/toast'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { toast as sonnerToast } from 'sonner'; | ||
|
|
||
| export const toast = sonnerToast; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding the entire
currentTrackobject to the dependency array is redundant and inefficient sincecurrentTrack?.idis already included. The effect should only re-run when the track ID changes, not when other properties of thecurrentTrackobject change. This could cause unnecessary re-renders and re-executions of the effect. RemovecurrentTrackfrom the dependency array.