Skip to content

Commit 7e780a4

Browse files
Fix ES-Lint Errors
1 parent dc1f553 commit 7e780a4

18 files changed

Lines changed: 330 additions & 186 deletions
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
2+
import * as React from "react"
3+
import { cva, type VariantProps } from "class-variance-authority"
4+
import { cn } from "@/lib/utils"
5+
6+
const badgeVariants = cva(
7+
"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",
8+
{
9+
variants: {
10+
variant: {
11+
default:
12+
"border-transparent bg-primary text-primary-foreground hover:bg-primary/80",
13+
secondary:
14+
"border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80",
15+
destructive:
16+
"border-transparent bg-destructive text-destructive-foreground hover:bg-destructive/80",
17+
outline: "text-foreground",
18+
},
19+
},
20+
defaultVariants: {
21+
variant: "default",
22+
},
23+
}
24+
)
25+
26+
export interface BadgeProps
27+
extends React.HTMLAttributes<HTMLDivElement>,
28+
VariantProps<typeof badgeVariants> { }
29+
30+
function Badge({ className, variant, ...props }: BadgeProps) {
31+
return (
32+
<div className={cn(badgeVariants({ variant }), className)} {...props} />
33+
)
34+
}
35+
36+
// eslint-disable-next-line react-refresh/only-export-components
37+
export { Badge, badgeVariants }

version 2/src/components/ui/button.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ export interface ButtonProps
3838
extends React.ButtonHTMLAttributes<HTMLButtonElement>,
3939
VariantProps<typeof buttonVariants> {
4040
asChild?: boolean
41+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link" | null | undefined
42+
size?: "default" | "sm" | "lg" | "icon" | null | undefined
4143
}
4244

4345
const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
@@ -54,4 +56,5 @@ const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(
5456
)
5557
Button.displayName = "Button"
5658

59+
// eslint-disable-next-line react-refresh/only-export-components
5760
export { Button, buttonVariants }

version 2/src/components/ui/input.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ import * as React from "react"
22

33
import { cn } from "@/lib/utils"
44

5-
export interface InputProps
6-
extends React.InputHTMLAttributes<HTMLInputElement> { }
5+
export type InputProps = React.InputHTMLAttributes<HTMLInputElement>
76

87
const Input = React.forwardRef<HTMLInputElement, InputProps>(
98
({ className, type, ...props }, ref) => {
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
2+
import * as React from "react"
3+
import { cn } from "@/lib/utils"
4+
5+
const Table = React.forwardRef<HTMLTableElement, React.HTMLAttributes<HTMLTableElement>>(({ className, ...props }, ref) => (
6+
<div className="relative w-full overflow-auto">
7+
<table ref={ref} className={cn("w-full caption-bottom text-sm", className)} {...props} />
8+
</div>
9+
))
10+
Table.displayName = "Table"
11+
12+
const TableHeader = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(({ className, ...props }, ref) => (
13+
<thead ref={ref} className={cn("[&_tr]:border-b", className)} {...props} />
14+
))
15+
TableHeader.displayName = "TableHeader"
16+
17+
const TableBody = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(({ className, ...props }, ref) => (
18+
<tbody ref={ref} className={cn("[&_tr:last-child]:border-0", className)} {...props} />
19+
))
20+
TableBody.displayName = "TableBody"
21+
22+
const TableFooter = React.forwardRef<HTMLTableSectionElement, React.HTMLAttributes<HTMLTableSectionElement>>(({ className, ...props }, ref) => (
23+
<tfoot ref={ref} className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)} {...props} />
24+
))
25+
TableFooter.displayName = "TableFooter"
26+
27+
const TableRow = React.forwardRef<HTMLTableRowElement, React.HTMLAttributes<HTMLTableRowElement>>(({ className, ...props }, ref) => (
28+
<tr ref={ref} className={cn("border-b transition-colors hover:bg-muted/50 data-[state=selected]:bg-muted", className)} {...props} />
29+
))
30+
TableRow.displayName = "TableRow"
31+
32+
const TableHead = React.forwardRef<HTMLTableCellElement, React.ThHTMLAttributes<HTMLTableCellElement>>(({ className, ...props }, ref) => (
33+
<th ref={ref} className={cn("h-12 px-4 text-left align-middle font-medium text-muted-foreground [&:has([role=checkbox])]:pr-0", className)} {...props} />
34+
))
35+
TableHead.displayName = "TableHead"
36+
37+
const TableCell = React.forwardRef<HTMLTableCellElement, React.TdHTMLAttributes<HTMLTableCellElement>>(({ className, ...props }, ref) => (
38+
<td ref={ref} className={cn("p-4 align-middle [&:has([role=checkbox])]:pr-0", className)} {...props} />
39+
))
40+
TableCell.displayName = "TableCell"
41+
42+
const TableCaption = React.forwardRef<HTMLTableCaptionElement, React.HTMLAttributes<HTMLTableCaptionElement>>(({ className, ...props }, ref) => (
43+
<caption ref={ref} className={cn("mt-4 text-sm text-muted-foreground", className)} {...props} />
44+
))
45+
TableCaption.displayName = "TableCaption"
46+
47+
export {
48+
Table,
49+
TableHeader,
50+
TableBody,
51+
TableFooter,
52+
TableHead,
53+
TableRow,
54+
TableCell,
55+
TableCaption,
56+
}

version 2/src/context/AuthContext.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ interface User {
77
mailboxAddress?: string;
88
can_send?: number;
99
mailbox_limit?: number;
10+
id?: number;
11+
userId?: number;
1012
}
1113

1214
interface AuthContextType {
1315
user: User | null;
1416
isLoading: boolean;
15-
login: (data: any) => Promise<void>;
17+
login: (data: Record<string, unknown>) => Promise<void>;
1618
logout: () => Promise<void>;
1719
checkSession: () => Promise<void>;
1820
}
@@ -31,7 +33,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
3133
} else {
3234
setUser(null);
3335
}
34-
} catch (error) {
36+
} catch {
3537
setUser(null);
3638
} finally {
3739
setIsLoading(false);
@@ -42,8 +44,8 @@ export function AuthProvider({ children }: { children: ReactNode }) {
4244
checkSession();
4345
}, []);
4446

45-
const login = async (data: any) => {
46-
const response = await apiFetch('/api/login', {
47+
const login = async (data: Record<string, unknown>) => {
48+
const response = await apiFetch<{ success: boolean; message?: string }>('/api/login', {
4749
method: 'POST',
4850
body: JSON.stringify(data),
4951
});
@@ -70,6 +72,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {
7072
);
7173
}
7274

75+
// eslint-disable-next-line react-refresh/only-export-components
7376
export function useAuth() {
7477
const context = useContext(AuthContext);
7578
if (context === undefined) {

version 2/src/hooks/useSender.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function useSender() {
2929
const sendEmail = useCallback(async (payload: SendEmailPayload) => {
3030
setIsSending(true);
3131
try {
32-
const res = await apiFetch<any>('/api/send', {
32+
const res = await apiFetch<Record<string, unknown>>('/api/send', { // api return type is dynamic
3333
method: 'POST',
3434
headers: { 'Content-Type': 'application/json' },
3535
body: JSON.stringify(payload),
@@ -38,11 +38,12 @@ export function useSender() {
3838
toast.success('Email sent successfully');
3939
return true;
4040
} else {
41-
toast.error(res.error || 'Failed to send email');
41+
toast.error(String(res.error) || 'Failed to send email');
4242
return false;
4343
}
44-
} catch (error: any) {
45-
toast.error(error.message || 'Failed to send email');
44+
} catch (error) {
45+
const msg = error instanceof Error ? error.message : 'Failed to send email';
46+
toast.error(msg);
4647
return false;
4748
} finally {
4849
setIsSending(false);

version 2/src/lib/api.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
export interface ApiResponse<T = any> {
1+
export interface ApiResponse<T = unknown> {
22
success: boolean;
33
message?: string;
44
data?: T;
5-
[key: string]: any;
5+
[key: string]: unknown;
66
}
77

8-
export async function apiFetch<T = any>(
8+
export async function apiFetch<T = unknown>(
99
endpoint: string,
1010
options: RequestInit = {}
1111
): Promise<T> {

version 2/src/pages/auth/Login.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ export default function Login() {
1818
try {
1919
await login({ username, password });
2020
toast.success('Login successful');
21-
} catch (error: any) {
22-
toast.error(error.message || 'Login failed');
21+
} catch (error) {
22+
const msg = error instanceof Error ? error.message : 'Login failed';
23+
toast.error(msg);
2324
} finally {
2425
setIsLoading(false);
2526
}

version 2/src/pages/dashboard/AssignMailboxDialog.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function AssignMailboxDialog({ open, onOpenChange, user, onSuccess }: Ass
3030
setDomains(data);
3131
setDomain(data[0]);
3232
}
33-
} catch (_) { }
33+
} catch { /* ignore */ }
3434
}, []);
3535

3636
useEffect(() => {
@@ -68,8 +68,9 @@ export function AssignMailboxDialog({ open, onOpenChange, user, onSuccess }: Ass
6868
toast.success(`Mailbox assigned to ${user.username}`);
6969
onSuccess();
7070
onOpenChange(false);
71-
} catch (error: any) {
72-
toast.error(error.message || 'Failed to assign mailbox');
71+
} catch (error) {
72+
const msg = error instanceof Error ? error.message : 'Failed to assign mailbox';
73+
toast.error(msg);
7374
} finally {
7475
setIsLoading(false);
7576
}

version 2/src/pages/dashboard/BatchActionModal.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ export function BatchActionModal({ open, onOpenChange, action, selectedMailboxes
7777
toast.success('Batch action completed successfully');
7878
onSuccess();
7979
onOpenChange(false);
80-
} catch (error: any) {
80+
} catch (error) {
8181
console.error('Batch action failed:', error);
82-
toast.error(error.message || 'Batch action failed');
82+
const msg = error instanceof Error ? error.message : 'Batch action failed';
83+
toast.error(msg);
8384
} finally {
8485
setIsLoading(false);
8586
}

0 commit comments

Comments
 (0)