// EN: ESLint v9 Flat Config for Root Monorepo
// VI: ESLint v9 Flat Config cho Root Monorepo
import tseslint from '@typescript-eslint/eslint-plugin';
import tsparser from '@typescript-eslint/parser';

export default [
    {
        // EN: Ignore patterns for monorepo root
        // VI: Các pattern bỏ qua cho monorepo root
        ignores: [
            '**/node_modules/**',
            '**/dist/**',
            '**/build/**',
            '**/.next/**',
            '**/coverage/**',
            '**/.turbo/**',
            '**/prisma/migrations/**',
            '**/_prisma_client/**',
            // EN: Ignore workspace packages (they have their own configs)
            // VI: Bỏ qua workspace packages (chúng có config riêng)
            'apps/**',
            'services/**',
            'packages/**',
        ],
    },
    {
        // EN: Configuration for root-level config files
        // VI: Cấu hình cho các config files ở root level
        files: ['*.js', '*.ts', '*.json'],
        languageOptions: {
            parser: tsparser,
            parserOptions: {
                ecmaVersion: 2024,
                sourceType: 'module',
            },
            globals: {
                // Node.js globals
                console: 'readonly',
                process: 'readonly',
                Buffer: 'readonly',
                __dirname: 'readonly',
                __filename: 'readonly',
                module: 'readonly',
                require: 'readonly',
                exports: 'readonly',
                globalThis: 'readonly',
            },
        },
        plugins: {
            '@typescript-eslint': tseslint,
        },
        rules: {
            // EN: Minimal rules for root config files
            // VI: Rules tối thiểu cho root config files
            'no-console': 'off',
            'no-debugger': 'error',
        },
    },
];
