Files
super_video/eslint.config.ts
2026-06-23 10:15:57 +08:00

88 lines
2.5 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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 tsconfigRootDir = fileURLToPath(new URL('.', import.meta.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],
tsconfigRootDir,
},
},
rules: {
'@typescript-eslint/no-explicit-any': 'off',
},
},
pluginVue.configs['flat/essential'],
{
files: ['**/*.vue'],
languageOptions: {
parserOptions: {
parser: {
ts: tseslint.parser,
tsx: tseslint.parser,
},
project: [tsconfigEslintPath],
tsconfigRootDir,
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',
},
},
])