80 lines
2.5 KiB
TypeScript
80 lines
2.5 KiB
TypeScript
import js from "@eslint/js";
|
|
import globals from "globals";
|
|
import tseslint from "typescript-eslint";
|
|
import pluginVue from "eslint-plugin-vue";
|
|
import markdown from "@eslint/markdown";
|
|
import css from "@eslint/css";
|
|
import { defineConfig } from "eslint/config";
|
|
|
|
export default defineConfig([
|
|
// 解决TypeScript-ESLint与ESLint 9.x类型不兼容问题
|
|
{ settings: {} },
|
|
// 基础配置
|
|
{
|
|
files: ["**/*.{js,mjs,cjs,ts,mts,cts,vue}"],
|
|
plugins: { js },
|
|
extends: ["js/recommended"],
|
|
languageOptions: {
|
|
globals: { ...globals.browser, ...globals.node },
|
|
ecmaVersion: 'latest',
|
|
sourceType: 'module'
|
|
}
|
|
},
|
|
|
|
// TypeScript配置
|
|
...tseslint.configs.recommended.map(config => ({
|
|
...config,
|
|
// 显式指定parser以解决类型不兼容问题
|
|
languageOptions: { ...config.languageOptions, parser: tseslint.parser }
|
|
})),
|
|
|
|
// Vue 3配置
|
|
...pluginVue.configs['flat/recommended'],
|
|
|
|
// Vue文件特定配置
|
|
{
|
|
files: ["**/*.vue"],
|
|
languageOptions: {
|
|
parserOptions: {
|
|
parser: tseslint.parser,
|
|
project: './tsconfig.json'
|
|
}
|
|
}
|
|
},
|
|
|
|
// Markdown配置
|
|
{
|
|
files: ["**/*.md"],
|
|
plugins: { markdown },
|
|
language: "markdown/commonmark",
|
|
extends: ["markdown/recommended"]
|
|
},
|
|
|
|
// CSS配置
|
|
{
|
|
files: ["**/*.css"],
|
|
plugins: { css },
|
|
language: "css/css",
|
|
extends: ["css/recommended"]
|
|
},
|
|
|
|
// 自定义规则
|
|
{
|
|
rules: {
|
|
'vue/multi-word-component-names': 'off', // 允许单字组件名
|
|
'@typescript-eslint/no-explicit-any': 'warn',
|
|
'@typescript-eslint/no-unused-vars': 'off', // 关闭未使用变量检查
|
|
'@typescript-eslint/no-unused-vars-experimental': 'off', // 关闭实验性检查
|
|
'vue/no-unused-vars': 'off', // 关闭Vue未使用变量检查
|
|
'vue/no-v-model-argument': 'off', // 允许v-model参数
|
|
'vue/no-async-in-computed-properties': 'off', // 禁用有问题的规则
|
|
'vue/no-child-content': 'off'// 禁用另一个有问题的规则
|
|
}
|
|
},
|
|
|
|
// 忽略node_modules和dist目录
|
|
{
|
|
ignores: ['node_modules/**', 'dist/**', 'public/**', , 'src/components/chat/ChatAi.ts', 'src/components/chat/MockSSEResponse.ts', 'src/components/chat/ChatAi.vue', 'src/components/chat/ChatAi.tsx', 'src/components/chat/ChatAi.jsx', 'src/components/chat/ChatAi.js', 'src/components/chat/**', 'src/components/chat/ChatAi.js']
|
|
}
|
|
]);
|