mirror of
https://github.com/johndoe6345789/snippet-pastebin.git
synced 2026-04-29 07:54:56 +00:00
Key changes: 1. Fix critical bug in src/app/page.tsx: removed conflicting `export const dynamic` that shadowed imported `dynamic` from next/dynamic, causing ReferenceError at runtime. Replaced with `export const revalidate = 0` then removed (client component). 2. Install missing typescript-eslint dependency and fix ESLint configuration to use flat config format properly. 3. Fix 32 ESLint errors across codebase: - Remove unused variables and imports (concat unused props in components) - Replace `any` types with proper TypeScript types (React.MutableRefObject) - Change empty interface in textarea.tsx to type alias - Fix react-hooks rule name from non-existent `set-state-in-effect` to `exhaustive-deps` 4. Code quality improvements: - Removed unused cn import from aspect-ratio.tsx - Removed unused useRef, useEffect from sheet.tsx imports - Simplified handler parameters in avatar.tsx - Cleaned up test files (removed unused container/user variables) Results after review: - Unit tests: 275 passing, 14 failing (improved from 270/19) - E2E tests: 204 passing, 59 failing, 17 skipped (now running after critical fix) - Linter: 0 errors (all 32 fixed) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
/**
|
|
* Utility function to combine class names
|
|
* Replaces tailwind-merge and clsx with a simple implementation
|
|
*/
|
|
export function cn(...classes: (string | undefined | null | false)[]): string {
|
|
return classes.filter(Boolean).join(' ')
|
|
}
|
|
|
|
/**
|
|
* Format bytes to human readable string
|
|
*/
|
|
export function formatBytes(bytes: number): string {
|
|
if (bytes === 0) return '0 Bytes'
|
|
const k = 1024
|
|
const sizes = ['Bytes', 'KB', 'MB', 'GB']
|
|
const i = Math.floor(Math.log(bytes) / Math.log(k))
|
|
return Math.round(bytes / Math.pow(k, i) * 100) / 100 + ' ' + sizes[i]
|
|
}
|
|
|
|
/**
|
|
* Debounce function
|
|
*/
|
|
export function debounce<T extends (...args: Array<unknown>) => unknown>(
|
|
func: T,
|
|
wait: number
|
|
): (...args: Parameters<T>) => void {
|
|
let timeout: NodeJS.Timeout | null = null
|
|
|
|
return function executedFunction(...args: Parameters<T>) {
|
|
const later = () => {
|
|
timeout = null
|
|
func(...args)
|
|
}
|
|
|
|
if (timeout) {
|
|
clearTimeout(timeout)
|
|
}
|
|
timeout = setTimeout(later, wait)
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Sleep utility
|
|
*/
|
|
export function sleep(ms: number): Promise<void> {
|
|
return new Promise(resolve => setTimeout(resolve, ms))
|
|
}
|