import { fixupPluginRules } from '@eslint/compat';
import globals from 'globals';
import typescriptParser from '@typescript-eslint/parser';
import jsPlugin from '@eslint/js';
import stylisticPlugin from '@stylistic/eslint-plugin';
import filenamesPlugin from 'eslint-plugin-filenames';
import { importX as importPlugin } from 'eslint-plugin-import-x';
import barrelFilesPlugin from 'eslint-plugin-barrel-files';
import prettierPlugin from 'eslint-plugin-prettier';
import promisePlugin from 'eslint-plugin-promise';
import baseRules from '../rules/base.mjs';
import stylisticRules from '../rules/stylistic.mjs';
import promiseRules from '../rules/promise.mjs';
import filenameRules from '../rules/filenames.mjs';
import importRules from '../rules/import.mjs';
import barrelFilesRules from '../rules/barrel-files.mjs';

export default [
  {
    linterOptions: {
      reportUnusedDisableDirectives: 'error',
    },
    languageOptions: {
      sourceType: 'module',
      ecmaVersion: 2024,
      parser: typescriptParser,
      parserOptions: {
        requireConfigFile: false,
      },
      globals: {
        ...globals.es2024,
      },
    },
    settings: {
      'import-x/extensions': ['.js', '.jsx', '.mjs', '.cjs'],
    },
    plugins: {
      '@stylistic': stylisticPlugin,
      'barrel-files': barrelFilesPlugin,
      filenames: fixupPluginRules(filenamesPlugin),
      'import-x': importPlugin,
      js: jsPlugin,
      prettier: prettierPlugin,
      promise: promisePlugin,
    },
    rules: {
      ...baseRules,
      ...stylisticRules,
      ...barrelFilesRules,
      ...filenameRules,
      ...importRules,
      ...promiseRules,
      'prettier/prettier': 'error',
    },
  },
];
