import { defineConfig, globalIgnores } from 'eslint/config';
import nextVitals from 'eslint-config-next/core-web-vitals';
import nextTs from 'eslint-config-next/typescript';

const eslintConfig = defineConfig([
  ...nextVitals,
  ...nextTs,
  {
    rules: {
      'react-hooks/set-state-in-effect': 'off',
      '@typescript-eslint/no-unused-vars': [
        'warn',
        { argsIgnorePattern: '^_', varsIgnorePattern: '^_', caughtErrorsIgnorePattern: '^_' },
      ],
      // CC.6 UI-drift ratchet: all @bytelyst/ui usage must go through the
      // Primitives adapter so future UI stays consistent and centrally swappable.
      'no-restricted-imports': [
        'error',
        {
          paths: [
            {
              name: '@bytelyst/ui',
              message:
                'Import @bytelyst/ui components via the adapter: src/components/ui/Primitives.tsx (UI-drift ratchet, CC.6).',
            },
          ],
          patterns: [
            {
              group: ['@bytelyst/ui/*'],
              message:
                'Import @bytelyst/ui components via the adapter: src/components/ui/Primitives.tsx (UI-drift ratchet, CC.6).',
            },
          ],
        },
      ],
    },
  },
  {
    // The adapter itself is the single sanctioned place to import @bytelyst/ui.
    files: ['src/components/ui/Primitives.tsx'],
    rules: {
      'no-restricted-imports': 'off',
    },
  },
  globalIgnores([
    '.next/**',
    'out/**',
    'build/**',
    'coverage/**',
    'test-results/**',
    'playwright-report/**',
    'next-env.d.ts',
  ]),
]);

export default eslintConfig;
