module.exports = {
  parser: '@typescript-eslint/parser',
  env: {
    browser: true,
    node: true,
    es2021: true,
    jest: true
  },
  parserOptions: {
    ecmaVersion: 2020,
    sourceType: 'module',
    ecmaFeatures: {
      jsx: true,
    },
  },
  settings: {
    react: {
      version: 'detect',
    },
  },
  plugins: ['@typescript-eslint', 'react'],
  extends: [
    'eslint:recommended',
    'plugin:react/recommended',
    'plugin:@typescript-eslint/recommended'
  ],
  rules: {
    'react/prop-types': 'off',
    // During incremental migration we relax some rules so legacy JS/TS files
    // don't block CI. We'll re-enable stricter rules as files are converted.
    'no-undef': 'off',
    'no-console': 'off',
    'react/react-in-jsx-scope': 'off',
    '@typescript-eslint/no-extra-semi': 'off',
    '@typescript-eslint/no-empty-function': 'off'
  }
};

// During incremental migration we allow legacy .js files more leeway.
// Disable some TypeScript-specific and strict React rules for .js files
// so the production build isn't blocked while we convert sources.
module.exports.overrides = [
  {
    files: ["**/*.js"],
    rules: {
      "@typescript-eslint/no-extra-semi": "off",
      "@typescript-eslint/no-empty-function": "off",
      "@typescript-eslint/no-loss-of-precision": "off",
      "react/no-unescaped-entities": "off"
    }
  }
];
