plugins:
  - "@typescript-eslint"

parser: "@typescript-eslint/parser"

extends:
  - eslint:recommended
  - plugin:@typescript-eslint/strict
  # We use the recommended Next.js eslint configuration `next/core-web-vitals` as per
  # <https://nextjs.org/docs/14/app/building-your-application/configuring/eslint#core-web-vitals>
  # In v14, the base configuration uses predefined rulesets including react, react-hooks, and next
  # <https://github.com/vercel/next.js/blob/v14.1.4/packages/eslint-config-next/index.js#L54>
  - next/core-web-vitals

settings:
  react:
    version: "16"

ignorePatterns:
  - "/*"
  - "!/app"
  - "!/data"
  - "!/components"
  - "!/pages"
  - "!/src"
  - "!/types.d.ts"
  - "!/vendored"

rules:
  "@typescript-eslint/consistent-type-assertions": ["error", { assertionStyle: 'never' }]

  no-use-before-define: off
  "@typescript-eslint/no-use-before-define": ["error",
    {
      # Variable declarations are not hoisted, but they are safe to reference
      # within a function as long as the function is not run before the variable
      # declaration.
      # This allows true errors to pass linting, but such errors should be
      # caught by the TypeScript compiler.
      # <https://github.com/microsoft/TypeScript/blob/v5.4.5/src/compiler/diagnosticMessages.json#L2263-L2266>
      "variables": false,

      # See commentary in parent configuration file
      "functions": false,
      "classes": false,
    }]

  react/prop-types: off # Remove this override once all props have been typed using PropTypes or TypeScript.
  '@next/next/no-img-element': off # Remove this if we use next.js optimisations for <img>
  '@next/next/no-html-link-for-pages': off

overrides:
  # require() is used for images that are not under static-site/public
  - files:
      - '**.[jt]sx'
    rules:
      '@typescript-eslint/no-var-requires': off

parserOptions:
  sourceType: module
  ecmaVersion: 2022

env:
  browser: true
  es6: true
  node: true
