import prettierPlugin from 'eslint-plugin-prettier' import typescriptPlugin from '@typescript-eslint/eslint-plugin' import typescriptParser from '@typescript-eslint/parser' export default [ { files: [ '**/*.ts', '**/*.mts', ], // 指定文件类型 languageOptions: { ecmaVersion: 2020, // 使用 ECMAScript 2020 语法 sourceType: 'module', parser: typescriptParser, parserOptions: { project: './tsconfig.json', // 指定 TypeScript 配置文件 }, }, plugins: { '@typescript-eslint': typescriptPlugin, prettier: prettierPlugin, }, rules: { // Prettier 配置规则 'prettier/prettier': [ 'error', {}, { usePrettierrc: true, // 读取 .prettierrc 配置 }, ], // TypeScript 规则 '@typescript-eslint/no-inferrable-types': 'off', '@typescript-eslint/no-unused-vars': 'warn', '@typescript-eslint/no-var-requires': 'off', '@typescript-eslint/no-explicit-any': 'off', // 关闭 unused-vars 的基础规则(避免冲突) 'no-unused-vars': 'off', }, ignores: [ // 替代 .eslintignore 的配置 'node_modules', 'dist/', '*.log', '/**/*.js', ], }, ]