import js from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
import pluginJs from '@eslint/js';
import pluginPrettier from 'eslint-plugin-prettier';

export default tseslint.config(
    { 
        ignores: ['dist'], 
        ignorePatterns: [
            "**/*.wxs" // 忽略所有 wxs 文件
        ] 
    },
    {
        extends: [js.configs.recommended, ...tseslint.configs.recommended],
        files: ['**/*.{ts,tsx}'],
        languageOptions: {
            ecmaVersion: 2020,
            globals: {
                ...globals.browser,
                ...globals.node,
                ...globals.es2021,
                wx: true,
                App: true,
                Page: true,
                getCurrentPages: true,
                getApp: true,
                Component: true,
                requirePlugin: true,
                requireMiniProgram: true,
            },
        },
        plugins: {
            ...pluginJs.configs.recommended,
            pluginPrettier,
        },
        rules: {
            // 'prettier/prettier': 'error',
            'no-console': 'off',
            '@typescript-eslint/no-require-imports': 'warn',
            '@typescript-eslint/no-explicit-any': 'warn',
            '@typescript-eslint/ban-ts-comment': 'off',
            'no-unused-vars': ['error', { vars: 'all', varsIgnorePattern: '_', args: 'after-used', argsIgnorePattern: '_' }],
        },
    },
);
