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

const eslintConfig = defineConfig([
  ...nextVitals,
  ...nextTs,
  // Override default ignores of eslint-config-next.
  globalIgnores([
    // Default ignores of eslint-config-next:
    ".next/**",
    "out/**",
    "build/**",
    "next-env.d.ts",
    "coverage/**",
  ]),
  // Tests: Jest globals + relax rules that are noisy for mocks/spies (RULE-QUA-01: no bare file-wide disable).
  {
    name: "test-files",
    files: [
      "**/*.test.ts",
      "**/*.test.tsx",
      "**/_tests_/**/*.ts",
      "**/_tests_/**/*.tsx",
    ],
    languageOptions: {
      globals: {
        ...globals.jest,
      },
    },
    rules: {
      "@typescript-eslint/no-explicit-any": "off",
      "@typescript-eslint/no-require-imports": "off",
      "@next/next/no-assign-module-variable": "off",
      "@next/next/no-img-element": "off",
      "@next/next/no-html-link-for-pages": "off",
      "react/display-name": "off",
      "react-hooks/globals": "off",
      "react-hooks/refs": "off",
      "jsx-a11y/alt-text": "off",
      "jsx-a11y/role-has-required-aria-props": "off",
      "react-hooks/incompatible-library": "off",
    },
  },
]);

export default eslintConfig;
