import js from '@eslint/js'
import vue from 'eslint-plugin-vue'
import parser from 'vue-eslint-parser'
import globals from 'globals'

export default [
  js.configs.recommended,
  ...vue.configs['flat/recommended'],
  {
    files: ['**/*.vue', '**/*.js', '**/*.mjs', '**/*.cjs'],
    languageOptions: {
      parser: parser,
      ecmaVersion: 'latest',
      sourceType: 'module',
      globals: {
        ...globals.browser,
        ...globals.node,
        ...globals.es2021,
        // Nuxt/Vue specific globals
        '$fetch': 'readonly',
        'useAuthStore': 'readonly',
        'useRoute': 'readonly',
        'useRouter': 'readonly',
        'navigateTo': 'readonly',
        'useHead': 'readonly',
        'useFetch': 'readonly',
        'definePageMeta': 'readonly',
        'defineNuxtRouteMiddleware': 'readonly',
        'defineEventHandler': 'readonly',
        'readBody': 'readonly',
        'getCookie': 'readonly',
        'setCookie': 'readonly',
        'deleteCookie': 'readonly',
        'getHeader': 'readonly',
        'setHeader': 'readonly',
        'getRouterParam': 'readonly',
        'getQuery': 'readonly',
        'sendStream': 'readonly',
        'sendRedirect': 'readonly',
        'createError': 'readonly',
        'useRuntimeConfig': 'readonly',
        'hasAnyRole': 'readonly',
        'hasRole': 'readonly',
        'hasAllRoles': 'readonly',
        'process': 'readonly',
        // Vue Composition API
        'onUnmounted': 'readonly',
        'provide': 'readonly',
        'inject': 'readonly',
        'ref': 'readonly',
        'reactive': 'readonly',
        'computed': 'readonly',
        'watch': 'readonly',
        'onMounted': 'readonly',
        'defineComponent': 'readonly',
        'defineProps': 'readonly',
        'defineEmits': 'readonly',
        'defineExpose': 'readonly'
      },
      parserOptions: {
        ecmaVersion: 'latest',
        sourceType: 'module'
      }
    },
    rules: {
      'vue/multi-word-component-names': 'off',
      'vue/no-v-html': 'warn',
      'no-unused-vars': ['warn', { 
        argsIgnorePattern: '^_',
        varsIgnorePattern: '^_'
      }],
      'vue/no-unused-vars': ['warn', {
        ignorePattern: '^_'
      }],
      'no-undef': 'warn',
      'no-console': 'off'
    }
  },
  {
    ignores: [
      'node_modules/**',
      '.output/**',
      '.nuxt/**',
      '**/.output/**',
      '**/.nuxt/**',
      '.next/**',
      'dist/**',
      'build/**',
      '*.config.js',
      '*.config.ts',
      '*.config.cjs',
      '*.cjs',
      '**/*.cjs',
      'temp/**',
      'backups/**',
      'public/**',
      'tests/**',
      'scripts/**'
    ]
  }
]

