Files
2026-04-30 09:17:31 +08:00

48 lines
1.4 KiB
TypeScript

import path from 'node:path'
import { fileURLToPath } from 'node:url'
import js from '@eslint/js'
import globals from 'globals'
import reactHooks from 'eslint-plugin-react-hooks'
import reactRefresh from 'eslint-plugin-react-refresh'
import tseslint from 'typescript-eslint'
import eslintPluginPrettierRecommended from 'eslint-plugin-prettier/recommended'
const tsconfigRootDir = path.dirname(fileURLToPath(import.meta.url))
export default tseslint.config(
{
ignores: ['dist', 'node_modules', 'vite.config.ts', '.claude/worktrees/**', 'public/**'],
},
{
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
eslintPluginPrettierRecommended, // Prettier + ESLint 整合
],
files: ['**/*.{ts,tsx}'],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
parserOptions: {
tsconfigRootDir,
},
},
plugins: {
'react-hooks': reactHooks,
'react-refresh': reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
'react-refresh/only-export-components': ['warn', { allowConstantExport: true }],
'@typescript-eslint/no-unused-vars': [
'warn',
{ varsIgnorePattern: '^_', argsIgnorePattern: '^_' },
],
'@typescript-eslint/no-explicit-any': 'off',
// 禁用可能与 Prettier 冲突的 ESLint 规则
quotes: 'off',
semi: 'off',
},
}
)