import {FlatCompat} from '@eslint/eslintrc'
import {dirname} from 'path'
import {fileURLToPath} from 'url'

//import {plugins} from 'eslint-config-next'
//const {plugins} = require('eslint-config-next')

const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)

const compat = new FlatCompat({
	baseDirectory: __dirname
})

const eslintConfig = [
	...compat.extends(
		'next/core-web-vitals',
		'next/typescript',
		'plugin:prettier/recommended'
	),
	{
		plugins: ['validate-filename'],
		rules: {
			'validate-filename/naming-rules': [
				'error',
				{
					rules: [
						{
							case: 'kebab',
							target: '**/components/**',
							patterns: '^[a-z0-9-]+.tsx$'
						},
						{
							case: 'kebab',
							target: '**/app/**',
							patterns:
								'^(default|page|layout|loading|error|not-found|route|template).(tsx|ts)$'
						},
						{
							case: 'camel',
							target: '**/hooks/**',
							patterns: '^use'
						},
						{
							case: 'camel',
							target: '**/providers/**',
							patterns: '^[a-zA-Z]*Provider'
						}
					]
				}
			],
			'prettier/prettier': [
				'warn',
				{
					endOfLine: 'auto',
					semi: false
				}
			]
		}
	}
]

export default eslintConfig
