module.exports = {
  root: true,
  env: { browser: true, es2020: true },
  extends: [
    "eslint:recommended",
    "plugin:@typescript-eslint/recommended",
    "plugin:@typescript-eslint/recommended-requiring-type-checking",
    "plugin:react-hooks/recommended",
    "prettier",
  ],
  ignorePatterns: ["dist", ".eslintrc.cjs"],
  parser: "@typescript-eslint/parser",
  parserOptions: {
    project: "./tsconfig.json",
    tsconfigRootDir: __dirname,
    sourceType: "module",
    extraFileExtensions: [".json"],
    exclude: ["*.json"],
  },
  plugins: ["react-refresh", "jsonc", "i18next"],
  rules: {
    "react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
    "no-restricted-globals": [
      "error",
      {
        name: "Date",
        message: "Use Luxon (DateTime) for date/time logic instead of the native Date.",
      },
    ],
    "@typescript-eslint/no-unsafe-member-access": "error",
    "@typescript-eslint/no-unsafe-assignment": "error",
    "@typescript-eslint/no-unsafe-call": "error",
    "@typescript-eslint/no-unsafe-return": "error",
    indent: "off",
    "jsonc/indent": ["error", 2], // Ensures 2 space indentation
    "jsonc/key-spacing": ["error", { beforeColon: false, afterColon: true }], // Ensures no space before colon and space after colon
    "i18next/no-literal-string": [
      "error",
      {
        markupOnly: true,
        ignoreAttribute: ["data-testid", "to", "key", "id", "name"],
      },
    ],
  },
  overrides: [
    {
      files: ["*.json"],
      parser: "jsonc-eslint-parser",
      rules: {
        "@typescript-eslint/": "off",
        "@typescript-eslint/no-unsafe-assignment": "off",
        "@typescript-eslint/await-thenable": "off",
        "@typescript-eslint/no-base-to-string": "off",
        "@typescript-eslint/no-duplicate-type-constituents": "off",
        "@typescript-eslint/no-floating-promises": "off",
        "@typescript-eslint/no-implied-eval": "off",
        "@typescript-eslint/no-unsafe-member-access": "off",
        "@typescript-eslint/no-misused-promises": "off",
        "@typescript-eslint/no-redundant-type-constituents": "off",
        "@typescript-eslint/no-unnecessary-type-assertion": "off",
        "@typescript-eslint/no-unsafe-argument": "off",
        "@typescript-eslint/no-unsafe-enum-comparison": "off",
        "@typescript-eslint/unbound-method": "off",

        "@typescript-eslint/adjacent-overload-signatures": "off",
        "@typescript-eslint/array-type": "off",
        "@typescript-eslint/no-empty-interface": "off",
        "@typescript-eslint/no-explicit-any": "off",
        "@typescript-eslint/no-inferrable-types": "off",
        "@typescript-eslint/no-invalid-this": "off",
        "@typescript-eslint/no-unsafe-call": "off",
        "@typescript-eslint/no-unsafe-return": "off",
        "@typescript-eslint/no-var-requires": "off",
        "@typescript-eslint/prefer-namespace-keyword": "off",
        "@typescript-eslint/promise-function-async": "off",
        "@typescript-eslint/require-await": "off",
        "@typescript-eslint/restrict-plus-operands": "off",
        "@typescript-eslint/restrict-template-expressions": "off",
        "@typescript-eslint/return-await": "off",
        "@typescript-eslint/switch-exhaustiveness-check": "off",
        "@typescript-eslint/triple-slash-reference": "off",
        "@typescript-eslint/type-annotation-spacing": "off",
        "@typescript-eslint/explicit-module-boundary-types": "off",
        "@typescript-eslint/explicit-function-return-type": "off",
        "@typescript-eslint/member-ordering": "off",
        "@typescript-eslint/naming-convention": "off",
        "@typescript-eslint/typedef": "off",
        "@typescript-eslint/consistent-type-assertions": "off",
        "@typescript-eslint/consistent-type-definitions": "off",
        "@typescript-eslint/explicit-member-accessibility": "off",
        "@typescript-eslint/method-signature-style": "off",
        "@typescript-eslint/no-absolute-path": "off",
        "@typescript-eslint/no-shadow": "off",
        "@typescript-eslint/no-use-before-define": "off",
        "@typescript-eslint/ban-types": "off",
        "@typescript-eslint/brace-style": "off",
        "@typescript-eslint/indent": "off",
        "@typescript-eslint/no-unnecessary-condition": "off",
        "@typescript-eslint/no-unused-expressions": "off",
        "@typescript-eslint/no-unused-vars": "off",
        "@typescript-eslint/prefer-for-of": "off",
        "@typescript-eslint/prefer-function-type": "off",
        "@typescript-eslint/prefer-optional-chain": "off",
        "@typescript-eslint/prefer-readonly": "off",
        "@typescript-eslint/prefer-readonly-parameter-types": "off",
        "@typescript-eslint/prefer-string-starts-ends-with": "off",
        "@typescript-eslint/prefer-ts-expect-error": "off",
        "@typescript-eslint/quotes": "off",
        "@typescript-eslint/semi": "off",
        "@typescript-eslint/unified-signatures": "off",
      },
    },
    {
      files: ["public/locales/**/*.json"],
      rules: {
        "no-irregular-whitespace": "off",
      },
    },
  ],
}
