Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
78 lines
2.3 KiB
TypeScript
78 lines
2.3 KiB
TypeScript
import globals from 'globals'
|
||
import tseslint from 'typescript-eslint'
|
||
import pluginVue from 'eslint-plugin-vue'
|
||
import { defineConfig } from 'eslint/config'
|
||
import { fileURLToPath } from 'node:url'
|
||
|
||
// 直接使用 tsconfig 的绝对路径,避免中文路径在 URL/路径互转时被编码导致读取失败
|
||
const tsconfigEslintPath = fileURLToPath(new URL('./tsconfig.eslint.json', import.meta.url))
|
||
|
||
export default defineConfig([
|
||
// 全局忽略:自身配置文件、产物、第三方静态资源等不参与 lint
|
||
{
|
||
ignores: [
|
||
'eslint.config.ts',
|
||
'eslint.config.*',
|
||
'dist/**',
|
||
'node_modules/**',
|
||
'public/**',
|
||
'vite.config.*',
|
||
'postcss.config.*',
|
||
'tailwind.config.*'
|
||
]
|
||
},
|
||
{
|
||
files: ['**/*.{js,mjs,cjs,ts,mts,cts,tsx,vue}'],
|
||
languageOptions: { globals: globals.browser }
|
||
},
|
||
tseslint.configs.recommended,
|
||
{
|
||
languageOptions: {
|
||
parserOptions: {
|
||
// 让 typescript-eslint 使用专用 tsconfig(显式 include .vue)
|
||
project: [tsconfigEslintPath]
|
||
}
|
||
},
|
||
rules: {
|
||
'@typescript-eslint/no-explicit-any': 'off'
|
||
}
|
||
},
|
||
pluginVue.configs['flat/essential'],
|
||
{
|
||
files: ['**/*.vue'],
|
||
languageOptions: {
|
||
parserOptions: {
|
||
parser: {
|
||
ts: tseslint.parser,
|
||
tsx: tseslint.parser
|
||
},
|
||
project: [tsconfigEslintPath],
|
||
extraFileExtensions: ['.vue'],
|
||
ecmaFeatures: {
|
||
jsx: true
|
||
}
|
||
}
|
||
},
|
||
rules: {
|
||
'vue/multi-word-component-names': 'off',
|
||
'vue/no-undef-components': [
|
||
'error',
|
||
{
|
||
ignorePatterns: ['router-view', 'router-link', 'RouterView', 'RouterLink']
|
||
}
|
||
],
|
||
'@typescript-eslint/no-unused-vars': 'warn',
|
||
'@typescript-eslint/no-explicit-any': 'off', // 完全禁用 any 检查
|
||
// 关闭所有需要类型信息的规则
|
||
'@typescript-eslint/no-unsafe-assignment': 'off',
|
||
'@typescript-eslint/no-unsafe-member-access': 'off',
|
||
'@typescript-eslint/no-unsafe-call': 'off',
|
||
'@typescript-eslint/no-unsafe-return': 'off',
|
||
'@typescript-eslint/no-unsafe-argument': 'off',
|
||
'@typescript-eslint/no-empty-object-type': 'off', // 允许空接口
|
||
'@typescript-eslint/no-unused-expressions': 'warn', // 改为警告而非错误
|
||
'no-unused-expressions': 'off'
|
||
}
|
||
}
|
||
])
|