const path = require('path');
const thisDir = path.resolve(__dirname);

module.exports = {
  extends: [
    '../../.eslintrc.cjs',
    'plugin:mocha/recommended'
  ],
  parserOptions: {
    project: path.join(thisDir, 'tsconfig.json'),
    tsconfigRootDir: thisDir,
  },
  env: {
    browser: true,
    mocha: true,
  },
  plugins: [
    'mocha',
  ],
  rules: {
    '@typescript-eslint/no-explicit-any': 'off',
    '@typescript-eslint/strict-boolean-expressions': 'off',
    'import/no-nodejs-modules': 'off',
    'jsdoc/require-jsdoc': 'off',
    'mocha/no-exports': 'off',
    'mocha/no-async-describe': 'error',
    'mocha/no-exclusive-tests': 'warn',
    'mocha/no-hooks': 'off',
    'mocha/no-hooks-for-single-case': 'off', // Disabled to avoid duplicates, because 'no-hooks' is enabled
    'mocha/no-identical-title': 'error',
    'mocha/no-mocha-arrows': 'error',
    'mocha/no-return-from-async': 'error',
    'mocha/no-top-level-hooks': 'error',
    'max-lines-per-function': 'off',
    'no-console': 'off',
    'no-useless-catch': 'off',
    'no-extra-boolean-cast': 'off',
    'no-template-curly-in-string': 'off',
    'no-inner-declarations': 'off',
    'no-await-in-loop': 'off',
    'require-atomic-updates': 'off',
    'quote-props': 'off',

    // can only allow 1, to produce proper junit test format for later consumption
    "mocha/max-top-level-suites": ['error', {limit: 1}],
    'mocha/no-setup-in-describe': 'off',
    'mocha/no-synchronous-tests': 'off',

    '@typescript-eslint/no-unused-vars': ["warn", { "varsIgnorePattern": "^_", "argsIgnorePattern": "^_|context" }],
    '@typescript-eslint/prefer-readonly': 'off',
    '@typescript-eslint/no-empty-function': 'off',
    '@typescript-eslint/no-unsafe-assignment': 'off',
    '@typescript-eslint/no-unsafe-member-access': 'off',
    '@typescript-eslint/no-unsafe-call': 'off',
    '@typescript-eslint/ban-types': 'off',
    '@typescript-eslint/restrict-template-expressions': 'off',
    '@typescript-eslint/no-unnecessary-type-assertion': 'off',
    '@typescript-eslint/no-floating-promises': 'error',
    '@typescript-eslint/explicit-member-accessibility': 'off',
    '@typescript-eslint/require-array-sort-compare': 'off',
    '@typescript-eslint/restrict-plus-operands': 'off',
    '@typescript-eslint/no-this-alias': 'off',
    '@typescript-eslint/prefer-nullish-coalescing': 'off',
    '@typescript-eslint/no-misused-promises': ['error', { checksVoidReturn: { arguments: false } }],
  },
  overrides: [{ // Specific overrides for JS files as some TS rules don't make sense there.
    files: ['3-runtime-html/generated/**'],
    rules: {
      '@typescript-eslint/quotes': 'off',
      '@typescript-eslint/indent': 'off',
      'no-template-curly-in-string': 'off'
    }
  }, {
    files: ['router/**'],
    rules: {
      'no-await-in-loop': 'off',
    }
  }]
};
