|
|
@@ -1,32 +1,41 @@
|
|
|
-import { globalIgnores } from 'eslint/config'
|
|
|
+// eslint.config.js
|
|
|
import { defineConfigWithVueTs, vueTsConfigs } from '@vue/eslint-config-typescript'
|
|
|
import pluginVue from 'eslint-plugin-vue'
|
|
|
+import eslintPluginJs from '@eslint/js'
|
|
|
import skipFormatting from '@vue/eslint-config-prettier/skip-formatting'
|
|
|
-
|
|
|
-// To allow more languages other than `ts` in `.vue` files, uncomment the following lines:
|
|
|
-// import { configureVueProject } from '@vue/eslint-config-typescript'
|
|
|
-// configureVueProject({ scriptLangs: ['ts', 'tsx'] })
|
|
|
-// More info at https://github.com/vuejs/eslint-config-typescript/#advanced-setup
|
|
|
+import { globalIgnores } from 'eslint/config'
|
|
|
|
|
|
export default defineConfigWithVueTs(
|
|
|
- {
|
|
|
- name: 'app/files-to-lint',
|
|
|
- files: ['**/*.{ts,mts,tsx,vue}'],
|
|
|
- },
|
|
|
-
|
|
|
- globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
|
|
|
+ // ✅ 基础推荐规则(提供语法检测能力)
|
|
|
+ eslintPluginJs.configs.recommended,
|
|
|
|
|
|
+ // ✅ Vue 规则
|
|
|
pluginVue.configs['flat/essential'],
|
|
|
+
|
|
|
+ // ✅ TypeScript 推荐规则
|
|
|
vueTsConfigs.recommended,
|
|
|
+
|
|
|
+ // ✅ 跳过格式化冲突(Prettier)
|
|
|
skipFormatting,
|
|
|
+
|
|
|
+ // ✅ 忽略目录
|
|
|
+ globalIgnores(['**/dist/**', '**/dist-ssr/**', '**/coverage/**']),
|
|
|
+
|
|
|
+ // ✅ 项目自定义规则
|
|
|
{
|
|
|
name: 'app/files-to-lint',
|
|
|
files: ['**/*.{ts,mts,tsx,vue}'],
|
|
|
rules: {
|
|
|
- // 禁用 vue/multi-word-component-names 规则(已存在)
|
|
|
+ // 🚫 关闭常用约束
|
|
|
'vue/multi-word-component-names': 'off',
|
|
|
- // 禁用 @typescript-eslint/no-explicit-any 规则
|
|
|
'@typescript-eslint/no-explicit-any': 'off',
|
|
|
+
|
|
|
+ // ✅ 强化语法检测
|
|
|
+ 'no-unexpected-multiline': 'error',
|
|
|
+ 'no-unreachable': 'error',
|
|
|
+ 'no-empty': 'error',
|
|
|
+ 'no-extra-parens': 'error',
|
|
|
+ 'no-fallthrough': 'error',
|
|
|
},
|
|
|
},
|
|
|
)
|