import love from "eslint-config-love"
import eslintConfigPrettier from "eslint-config-prettier/flat"

export default [
  // Global ignores (must be a standalone object with only `ignores`)
  {
    ignores: [
      "dist/**",
      "node_modules/**",
      "coverage/**",
      "build/**",
      "*.config.js",
      "*.config.cjs",
      "jest.config.cjs",
      "**/*.test.ts",
      "**/*.spec.ts",
    ],
  },

  // eslint-config-love base (TypeScript files only)
  {
    ...love,
    files: ["**/*.ts"],
  },

  // Prettier must come after all other configs
  eslintConfigPrettier,

  // Relax rules that are new in eslint-config-love but were not in the
  // previous config. Tighten incrementally — remove lines as code is fixed.
  {
    files: ["**/*.ts"],
    rules: {
      // --- type-safety (big refactor needed) ---
      "@typescript-eslint/no-unsafe-assignment": "off",
      "@typescript-eslint/no-unsafe-member-access": "off",
      "@typescript-eslint/no-unsafe-argument": "off",
      "@typescript-eslint/no-unsafe-call": "off",
      "@typescript-eslint/no-unsafe-return": "off",
      "@typescript-eslint/no-unsafe-type-assertion": "off",
      "@typescript-eslint/no-unsafe-enum-comparison": "off",
      "@typescript-eslint/no-explicit-any": "off",
      "@typescript-eslint/no-base-to-string": "off",
      "@typescript-eslint/restrict-template-expressions": "off",
      "@typescript-eslint/no-non-null-assertion": "off",
      "@typescript-eslint/no-redundant-type-constituents": "off",
      "@typescript-eslint/consistent-type-assertions": "off",
      "@typescript-eslint/use-unknown-in-catch-callback-variable": "off",

      // --- promise handling ---
      "@typescript-eslint/no-floating-promises": "off",
      "@typescript-eslint/no-misused-promises": "off",
      "@typescript-eslint/require-await": "off",
      "@typescript-eslint/strict-void-return": "off",
      "@typescript-eslint/no-confusing-void-expression": "off",
      "promise/avoid-new": "off",
      "no-async-promise-executor": "off",
      "no-promise-executor-return": "off",

      // --- style / convention ---
      "@typescript-eslint/strict-boolean-expressions": "off",
      "@typescript-eslint/no-unnecessary-condition": "off",
      "@typescript-eslint/no-magic-numbers": "off",
      "@typescript-eslint/prefer-nullish-coalescing": "off",
      "@typescript-eslint/prefer-destructuring": "off",
      "@typescript-eslint/explicit-function-return-type": "off",
      "@typescript-eslint/no-unnecessary-boolean-literal-compare": "off",
      "@typescript-eslint/no-useless-default-assignment": "off",
      "@typescript-eslint/naming-convention": "off",
      "@typescript-eslint/consistent-type-imports": "off",
      "@typescript-eslint/no-inferrable-types": "off",
      "@typescript-eslint/max-params": "off",
      "@typescript-eslint/init-declarations": "off",
      "@typescript-eslint/no-var-requires": "off",
      "@typescript-eslint/unbound-method": "off",
      "@typescript-eslint/no-empty-function": "off",
      "@typescript-eslint/no-useless-constructor": "off",
      "@typescript-eslint/method-signature-style": "off",
      "@typescript-eslint/unified-signatures": "off",
      "@typescript-eslint/ban-ts-comment": "off",
      "@typescript-eslint/no-dynamic-delete": "off",
      "@typescript-eslint/no-extraneous-class": "off",
      "@typescript-eslint/no-namespace": "off",
      "@typescript-eslint/promise-function-async": "off",
      "@typescript-eslint/no-unnecessary-type-conversion": "off",
      "@typescript-eslint/no-unused-vars": [
        "warn",
        { argsIgnorePattern: "^_", varsIgnorePattern: "^_" },
      ],
      "@typescript-eslint/prefer-optional-chain": "off",

      // --- eslint core ---
      "no-console": "off",
      "no-await-in-loop": "off",
      "no-param-reassign": "off",
      "no-plusplus": "off",
      "no-negated-condition": "off",
      "no-useless-assignment": "off",
      "no-useless-concat": "off",
      "prefer-named-capture-group": "off",
      "prefer-regex-literals": "off",
      "require-unicode-regexp": "off",
      "require-atomic-updates": "off",
      "logical-assignment-operators": "off",
      "guard-for-in": "off",
      "max-depth": "off",
      "max-lines": "off",
      complexity: "off",
      eqeqeq: "off",
      radix: "off",
    },
  },
]
