import antfu from '@antfu/eslint-config';
import importX, { createNodeResolver } from 'eslint-plugin-import-x';

export default antfu(
	{
		ignores: [
			'common/**',
			'static/**',
		],
		vue: true,
		// jsonc/yaml/toml stay off: assets/*.yaml are data files, not source, and weren't linted before.
		jsonc: false,
		yaml: false,
		toml: false,
		stylistic: {
			indent: 'tab',
			quotes: 'single',
			semi: true,
		},
	},
	{
		plugins: { 'import-x': importX },
		languageOptions: {
			globals: {
				CONFIG: 'readonly',
			},
		},
		settings: {
			// mirrors the '#'/'#root' aliases in vite.config.js, which is what actually resolves these at build/runtime
			'import-x/resolver-next': [createNodeResolver({
				alias: {
					'#': [import.meta.dirname],
					'#root': [import.meta.dirname],
				},
			})],
		},
		rules: {
			'default-param-last': 'off',
			'no-underscore-dangle': 'off',
			'no-console': 'off',
			'style/arrow-parens': ['error', 'always'],
			'no-param-reassign': ['error', {
				props: true,
				ignorePropertyModificationsFor: ['state', 'acc', 'req'],
			}],
			'prefer-destructuring': 'off',
			'import-x/no-unresolved': 'error',
			'import/prefer-default-export': 'off',
			'unused-imports/no-unused-vars': ['error', {
				args: 'after-used',
				argsIgnorePattern: '^_',
				varsIgnorePattern: '^_',
				ignoreRestSiblings: true,
				caughtErrors: 'none',
			}],
			'vue/multi-word-component-names': 'off',
			'vue/no-reserved-component-names': 'off',
			'vue/multiline-html-element-content-newline': 'off',
			'vue/singleline-html-element-content-newline': 'off',
		},
	},
);
