-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy patheslint.config.js
More file actions
200 lines (168 loc) · 4.09 KB
/
eslint.config.js
File metadata and controls
200 lines (168 loc) · 4.09 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
import js from '@eslint/js';
import prettier from 'eslint-config-prettier';
import simpleImportSort from 'eslint-plugin-simple-import-sort';
import tseslint from 'typescript-eslint';
export default tseslint.config(
// 基础推荐配置
js.configs.recommended,
// TypeScript 推荐配置
...tseslint.configs.recommended,
// Prettier 配置(禁用与 Prettier 冲突的规则)
prettier,
// 自定义配置
{
plugins: {
'simple-import-sort': simpleImportSort,
},
languageOptions: {
parser: tseslint.parser,
parserOptions: {
ecmaVersion: 'latest',
sourceType: 'module',
ecmaFeatures: {
jsx: true,
},
},
globals: {
// Browser globals
window: 'readonly',
document: 'readonly',
console: 'readonly',
// Node.js globals
process: 'readonly',
Buffer: 'readonly',
__dirname: 'readonly',
__filename: 'readonly',
module: 'readonly',
require: 'readonly',
exports: 'readonly',
global: 'readonly',
// Jest globals
describe: 'readonly',
it: 'readonly',
test: 'readonly',
expect: 'readonly',
beforeEach: 'readonly',
afterEach: 'readonly',
beforeAll: 'readonly',
afterAll: 'readonly',
jest: 'readonly',
// Vue 3 Composition API globals
defineProps: 'readonly',
defineEmits: 'readonly',
defineExpose: 'readonly',
withDefaults: 'readonly',
},
},
rules: {
// TypeScript 规则
'@typescript-eslint/consistent-type-imports': 'warn',
'@typescript-eslint/no-explicit-any': 'warn',
'@typescript-eslint/no-unused-vars': [
'warn',
{
argsIgnorePattern: '^_',
varsIgnorePattern: '^_',
},
],
// Import 排序规则
'simple-import-sort/imports': 'warn',
'simple-import-sort/exports': 'warn',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-unused-expressions': 'off',
// 其他推荐规则
'prefer-const': 'warn',
'no-var': 'error',
},
settings: {
'import/extensions': ['.js', '.jsx', '.ts', '.tsx'],
},
},
// 针对特定文件类型的配置
{
files: ['**/*.test.{js,ts,jsx,tsx}', '**/*.spec.{js,ts,jsx,tsx}'],
rules: {},
},
// 忽略的文件
{
ignores: [
// 依赖目录
'node_modules/',
'**/node_modules/',
// 构建输出目录
'dist/',
'**/dist/',
'build/',
'**/build/',
'lib/',
'**/lib/',
'es/',
'**/es/',
'cjs/',
'**/cjs/',
// 临时文件和缓存
'.cache/',
'.temp/',
'.tmp/',
'*.tmp',
'*.temp',
// 日志文件
'logs/',
'*.log',
'npm-debug.log*',
'yarn-debug.log*',
'yarn-error.log*',
'pnpm-debug.log*',
'lerna-debug.log*',
// 锁文件
'package-lock.json',
'yarn.lock',
'pnpm-lock.yaml',
// 环境配置文件
'.env',
'.env.*',
// IDE和编辑器文件
'.vscode/',
'.idea/',
'*.swp',
'*.swo',
// 系统文件
'.DS_Store',
'Thumbs.db',
// 代码覆盖率报告
'coverage/',
'*.lcov',
'.nyc_output/',
// 测试相关
'__tests__/fixtures/',
'**/__tests__/fixtures/',
'test/fixtures/',
'**/test/fixtures/',
// 文档生成
'docs/dist/',
'docs/build/',
// Changeset相关文件
'.changeset/',
// TypeScript声明文件输出
'*.d.ts',
// 特定于此项目的忽略项
'BUILD.md',
// Rollup插件生成的文件
'.rollup.cache/',
// 压缩和打包文件
'*.min.js',
'*.bundle.js',
'*.umd.js',
// 第三方库和供应商代码
'vendor/',
'**/vendor/',
'public/libs/',
'**/public/libs/',
// 生成的文件
'generated/',
'**/generated/',
'auto-generated/',
'**/auto-generated/',
],
},
);