{
  "root": true,
  "parser": "@typescript-eslint/parser",
  "plugins": [
    "@typescript-eslint",
    "import",
    "tailwindcss",
    "no-restricted-imports",
    "local-rules"
  ],
  "extends": [
    "eslint:recommended",
    "plugin:react/recommended",
    "plugin:react/jsx-runtime",
    "plugin:react-hooks/recommended",
    "plugin:jsx-a11y/recommended",
    "plugin:tailwindcss/recommended",
    "prettier"
  ],
  "ignorePatterns": ["coverage"],
  "env": {
    "browser": true,
    "node": true,
    "es2022": true
  },
  "globals": {
    "NodeJS": "readonly"
  },
  "parserOptions": {
    "ecmaVersion": "latest",
    "sourceType": "module",
    "ecmaFeatures": {
      "jsx": true
    },
    "project": ["./tsconfig.json"]
  },
  "settings": {
    "react": {
      "version": "detect"
    },
    // Help eslint-plugin-tailwindcss to parse Tailwind classes outside of className
    "tailwindcss": {
      "callees": ["tw"]
    },
    "jest": {
      "version": 27
    },
    "import/resolver": {
      "typescript": {
        "alwaysTryTypes": true,
        "project": "./tsconfig.json"
      }
    }
  },
  "rules": {
    "tailwindcss/no-custom-classname": "off",
    "no-console": "warn",
    "arrow-body-style": ["warn", "as-needed"],
    // Note: you must disable the base rule as it can report incorrect errors
    "no-unused-vars": "off",
    // Note: you must disable the base rule as it can report incorrect errors
    "no-redeclare": "off",
    // @typescript-eslint
    // Note: you must disable the base rule as it can report incorrect errors
    "no-return-await": "off",
    "@typescript-eslint/return-await": ["error", "in-try-catch"],
    // Note: you must disable the base rule as it can report incorrect errors
    "require-await": "off",
    "@typescript-eslint/require-await": "error",
    "@typescript-eslint/no-floating-promises": "error",
    "@typescript-eslint/await-thenable": "error",
    "@typescript-eslint/no-redeclare": [
      "error",
      {
        "ignoreDeclarationMerge": true
      }
    ],
    "@typescript-eslint/consistent-type-imports": "error",
    "@typescript-eslint/no-explicit-any": "off", // TODO: Enable in future PR - too many warnings currently
    "@typescript-eslint/ban-ts-comment": "off", // Allow both @ts-ignore and @ts-expect-error
    "@typescript-eslint/no-unused-vars": [
      "warn",
      {
        "vars": "all",
        "varsIgnorePattern": "^_",
        "args": "all",
        "argsIgnorePattern": "^_",
        "caughtErrors": "all",
        "caughtErrorsIgnorePattern": "^_",
        "destructuredArrayIgnorePattern": "^_",
        "ignoreRestSiblings": false
      }
    ],
    // import
    "import/no-cycle": "error",
    "import/no-unresolved": "error",
    "import/no-default-export": "off",
    "import/order": [
      "error",
      {
        "groups": ["builtin", "external", "internal"],
        "pathGroups": [
          {
            "pattern": "react",
            "group": "external",
            "position": "before"
          }
        ],
        "pathGroupsExcludedImportTypes": ["react"],
        "alphabetize": {
          "order": "asc",
          "caseInsensitive": true
        }
      }
    ],
    // jsx-a11y
    "jsx-a11y/no-autofocus": "off",
    "jsx-a11y/click-events-have-key-events": "off",
    "jsx-a11y/no-noninteractive-element-interactions": "off",
    // react
    "react/no-unescaped-entities": "off",
    "react/prop-types": "off", // Disabled for TypeScript projects - use TypeScript types instead
    "no-restricted-imports": [
      "error",
      {
        "paths": [
          {
            "name": "react-router",
            "importNames": ["useSearchParams"]
          }
        ]
      }
    ],
    // Custom local rules
    "local-rules/require-react-import-when-using-namespace": "error",
    "local-rules/require-satisfies-on-nested-prisma-selects": "error",
    "local-rules/require-deleted-at-check-on-custom-field-queries": "error",
    "local-rules/require-meta-export-in-routes": "warn",
    "local-rules/require-button-type": "error",
    "local-rules/require-org-scope-on-id-queries": "error"
  },
  "overrides": [
    {
      "files": [
        "./app/root.tsx",
        "./app/entry.client.tsx",
        "./app/entry.server.tsx",
        "./app/routes/**/*.tsx"
      ],
      "rules": {
        "import/no-default-export": "off"
      }
    },
    {
      "files": ["**/*.test.ts", "**/*.test.tsx"],
      "globals": {
        "vi": "readonly",
        "vitest": "readonly",
        "describe": "readonly",
        "it": "readonly",
        "expect": "readonly",
        "beforeEach": "readonly",
        "afterEach": "readonly",
        "beforeAll": "readonly",
        "afterAll": "readonly"
      }
    },
    {
      "files": ["scripts/**/*.ts"],
      "rules": {
        "no-console": "off",
        "@typescript-eslint/require-await": "off"
      }
    }
  ]
}
