From 2641f7822ddf4fc0ed0f71f0aa2461859d6ba582 Mon Sep 17 00:00:00 2001 From: Guido X Jansen Date: Fri, 13 Feb 2026 23:32:52 +0100 Subject: [PATCH] fix(ci): Resolve ESLint config and test failures - Fix ESLint config: Remove duplicate jsx-a11y plugin definition - Fix theme-toggle: Add eslint-disable for hydration pattern - Add utils.test.ts and test/setup.ts for vitest --- eslint.config.mjs | 5 ++--- src/components/theme-toggle.tsx | 6 ++++-- src/lib/utils.test.ts | 16 ++++++++++++++++ src/test/setup.ts | 1 + 4 files changed, 23 insertions(+), 5 deletions(-) create mode 100644 src/lib/utils.test.ts create mode 100644 src/test/setup.ts diff --git a/eslint.config.mjs b/eslint.config.mjs index ed51d9b..3d67c32 100644 --- a/eslint.config.mjs +++ b/eslint.config.mjs @@ -6,10 +6,9 @@ import jsxA11y from "eslint-plugin-jsx-a11y"; const eslintConfig = defineConfig([ ...nextVitals, ...nextTs, + // Configure jsx-a11y rules without redefining the plugin + // (eslint-config-next already includes jsx-a11y plugin) { - plugins: { - "jsx-a11y": jsxA11y, - }, rules: { // Accessibility - strict mode per PRD Section 6 "jsx-a11y/alt-text": "error", diff --git a/src/components/theme-toggle.tsx b/src/components/theme-toggle.tsx index 0b6d283..d0b507d 100644 --- a/src/components/theme-toggle.tsx +++ b/src/components/theme-toggle.tsx @@ -7,7 +7,7 @@ import { useTheme } from 'next-themes' import { Moon, Sun } from '@phosphor-icons/react' -import { useEffect, useState } from 'react' +import { useLayoutEffect, useState } from 'react' import { cn } from '@/lib/utils' interface ThemeToggleProps { @@ -19,9 +19,11 @@ export function ThemeToggle({ className }: ThemeToggleProps) { const [mounted, setMounted] = useState(false) // Prevent hydration mismatch - useEffect(() => { + /* eslint-disable react-hooks/set-state-in-effect -- Required for hydration mismatch prevention */ + useLayoutEffect(() => { setMounted(true) }, []) + /* eslint-enable react-hooks/set-state-in-effect */ if (!mounted) { return ( diff --git a/src/lib/utils.test.ts b/src/lib/utils.test.ts new file mode 100644 index 0000000..432db44 --- /dev/null +++ b/src/lib/utils.test.ts @@ -0,0 +1,16 @@ +import { describe, it, expect } from 'vitest' +import { cn } from './utils' + +describe('cn utility', () => { + it('should merge class names correctly', () => { + expect(cn('foo', 'bar')).toBe('foo bar') + }) + + it('should handle conditional classes', () => { + expect(cn('foo', false && 'bar', 'baz')).toBe('foo baz') + }) + + it('should merge tailwind classes with proper precedence', () => { + expect(cn('px-2', 'px-4')).toBe('px-4') + }) +}) diff --git a/src/test/setup.ts b/src/test/setup.ts new file mode 100644 index 0000000..4e2b5ce --- /dev/null +++ b/src/test/setup.ts @@ -0,0 +1 @@ +// Test setup file -- 2.51.2