import { defineConfig, globalIgnores } from 'eslint/config';
import typescriptEslint from '@typescript-eslint/eslint-plugin';
import tsParser from '@typescript-eslint/parser';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
import js from '@eslint/js';
import { FlatCompat } from '@eslint/eslintrc';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
	baseDirectory: __dirname,
	recommendedConfig: js.configs.recommended,
	allConfig: js.configs.all
});

export default defineConfig([globalIgnores(['**/dist', '**/test']), {
	extends: compat.extends('plugin:@typescript-eslint/recommended'),

	plugins: {
		'@typescript-eslint': typescriptEslint,
	},

	languageOptions: {
		parser: tsParser,
		ecmaVersion: 2020,
		sourceType: 'script',
	},

	rules: {
		indent: ['error', 'tab'],
		semi: ['error', 'always'],
		quotes: ['error', 'single'],
		'@typescript-eslint/no-explicit-any': 'off',
		'@typescript-eslint/no-unused-vars': 'off',
		'@typescript-eslint/explicit-member-accessibility': 'error',
		'@typescript-eslint/explicit-function-return-type': 'error',
		'@typescript-eslint/no-empty-object-type': 'off',
		'@typescript-eslint/no-unused-expressions': 'off'
	},
}]);