import { globalIgnores } from 'eslint/config'
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
import pluginVue from 'eslint-plugin-vue'
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'

// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
// import { configureVueProject } from '@vue/eslint-config-typescript'
// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup

export default defineConfigWithVueTs(
  {
    name: 'app/files-to-lint',
    files: ['**/*.{ts,mts,tsx,vue}'],
  },

  globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),

  pluginVue.configs['flat/essential'],
  vueTsConfigs.recommended,
  skipFormatting,
  {
    rules: {
      'vue/multi-word-component-names': 'off',
      '@typescript-eslint/no-explicit-any': 'off',
      '@typescript-eslint/no-unused-vars': ['off'],
      // Pre-existing code patterns: prop mutation via lodash set(), unused template vars, ts-ignore
      'vue/no-mutating-props': 'off',
      'vue/no-unused-vars': 'warn',
      '@typescript-eslint/no-unused-expressions': 'off',
      '@typescript-eslint/ban-ts-comment': 'warn',
      'vue/no-side-effects-in-computed-properties': 'off',
      '@typescript-eslint/no-unsafe-function-type': 'off',
    }
  },
  // Gradual type tightening for API layer and stores
  {
    name: 'app/strict-types',
    files: ['src/api/**/*.ts', 'src/stores/**/*.ts'],
    rules: {
      '@typescript-eslint/no-explicit-any': 'warn',
    }
  }
)
