-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheslint.config.js
More file actions
95 lines (85 loc) · 2.35 KB
/
eslint.config.js
File metadata and controls
95 lines (85 loc) · 2.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import js from '@eslint/js'
import vue from 'eslint-plugin-vue'
import ts from 'typescript-eslint'
import globals from 'globals'
export default [
// 忽略文件
{
ignores: [
'**/dist/**',
'**/node_modules/**',
'**/.vitepress/cache/**',
'**/.vitepress/dist/**',
'**/*.md',
],
},
// 基础配置
js.configs.recommended,
// TypeScript 配置
...ts.configs.recommended,
// Vue 配置
...vue.configs['flat/recommended'],
// 通用规则
{
languageOptions: {
globals: {
...globals.browser,
...globals.node,
},
},
rules: {
// 基础规则
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-unused-vars': 'off', // 使用 TypeScript 的版本
'prefer-const': 'error',
'no-var': 'error',
// TypeScript 规则
'@typescript-eslint/no-unused-vars': ['error', { argsIgnorePattern: '^_' }],
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/explicit-function-return-type': 'off',
'@typescript-eslint/explicit-module-boundary-types': 'off',
'@typescript-eslint/no-empty-interface': 'off',
// Vue 规则
'vue/multi-word-component-names': 'off',
'vue/no-v-html': 'off',
'vue/require-default-prop': 'off',
'vue/require-prop-types': 'off',
// 禁用与 Prettier 冲突的格式规则
'vue/max-attributes-per-line': 'off',
'vue/singleline-html-element-content-newline': 'off',
'vue/html-self-closing': [
'error',
{
html: {
void: 'always',
normal: 'never',
component: 'always',
},
},
],
// 代码风格
eqeqeq: ['error', 'always', { null: 'ignore' }],
curly: ['error', 'multi-line', 'consistent'],
'brace-style': ['error', '1tbs', { allowSingleLine: true }],
},
},
// Vue 文件特殊配置
{
files: ['**/*.vue'],
languageOptions: {
parserOptions: {
parser: '@typescript-eslint/parser',
extraFileExtensions: ['.vue'],
},
},
},
// 类型定义文件配置
{
files: ['**/*.d.ts'],
rules: {
'@typescript-eslint/no-empty-object-type': 'off',
'@typescript-eslint/no-explicit-any': 'off',
},
},
]