@truenine/eslint9-config 1.0.15 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +189 -92
- package/dist/defaults/index.d.ts +40 -0
- package/dist/defaults/index.d.ts.map +1 -0
- package/dist/defaults/index.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +0 -0
- package/package.json +18 -19
- package/dist/_virtual/rolldown_runtime.cjs +0 -25
- package/dist/defaults/index.cjs +0 -200
- package/dist/defaults/index.cjs.map +0 -1
- package/dist/index.cjs +0 -38
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.cts +0 -21
- package/dist/index.d.cts.map +0 -1
- package/dist/types/index.d.cts +0 -46
- package/dist/types/index.d.cts.map +0 -1
package/README.md
CHANGED
|
@@ -1,144 +1,241 @@
|
|
|
1
|
-
#
|
|
1
|
+
# ESLint 9 配置包
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
这是一个针对 Compose Client 项目优化的 ESLint 9 配置包,提供了缓存优化、性能调优和规则优化功能。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 功能特性
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
- 🎭 **UnoCSS** - Atomic CSS framework integration
|
|
13
|
-
- ⚡ **Performance** - Optimized for fast linting
|
|
7
|
+
### 🚀 性能优化
|
|
8
|
+
- **智能缓存**: 支持 metadata 和 content 两种缓存策略
|
|
9
|
+
- **并行处理**: 自动利用多核 CPU 进行并行检查
|
|
10
|
+
- **规则优化**: 可选择跳过性能影响大的规则
|
|
11
|
+
- **渐进式检查**: 优先检查关键文件
|
|
14
12
|
|
|
15
|
-
|
|
13
|
+
### 📋 预设配置
|
|
14
|
+
- **performance**: 性能优先,适用于大型项目或 CI 环境
|
|
15
|
+
- **quality**: 质量优先,适用于小型项目或开发环境
|
|
16
|
+
- **balanced**: 平衡配置,默认推荐
|
|
17
|
+
- **ci**: CI 环境专用配置
|
|
18
|
+
- **dev**: 开发环境友好配置
|
|
19
|
+
- **library**: 库项目严格配置
|
|
16
20
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# Using npm
|
|
22
|
-
npm install --save-dev @truenine/eslint9-config
|
|
23
|
-
|
|
24
|
-
# Using yarn
|
|
25
|
-
yarn add -D @truenine/eslint9-config
|
|
26
|
-
```
|
|
21
|
+
### 🎯 智能忽略
|
|
22
|
+
- 自动忽略构建产物、缓存目录、压缩文件等
|
|
23
|
+
- 可配置的关键文件优先检查
|
|
24
|
+
- 支持自定义忽略模式
|
|
27
25
|
|
|
28
|
-
##
|
|
26
|
+
## 使用方法
|
|
29
27
|
|
|
30
|
-
|
|
28
|
+
### 基础用法
|
|
31
29
|
|
|
32
30
|
```javascript
|
|
31
|
+
// eslint.config.mjs
|
|
33
32
|
import eslint9 from '@truenine/eslint9-config'
|
|
34
33
|
|
|
35
34
|
export default eslint9({
|
|
36
|
-
// Configuration options
|
|
37
|
-
// type: 'lib' for libraries, 'app' for applications
|
|
38
35
|
type: 'lib',
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
stylistic: true,
|
|
44
|
-
formatters: false
|
|
36
|
+
typescript: {
|
|
37
|
+
strictTypescriptEslint: true,
|
|
38
|
+
tsconfigPath: './tsconfig.json',
|
|
39
|
+
},
|
|
45
40
|
})
|
|
46
41
|
```
|
|
47
42
|
|
|
48
|
-
###
|
|
49
|
-
|
|
50
|
-
| Option | Type | Default | Description |
|
|
51
|
-
|--------|------|---------|-------------|
|
|
52
|
-
| `type` | `'app' \| 'lib'` | `'lib'` | Project type |
|
|
53
|
-
| `vue` | `boolean \| VueConfig` | `false` | Enable Vue.js support |
|
|
54
|
-
| `typescript` | `boolean \| TsConfig` | `true` | Enable TypeScript support |
|
|
55
|
-
| `test` | `boolean \| TestConfig` | `true` | Enable testing support |
|
|
56
|
-
| `unocss` | `boolean \| UnocssConfig` | `false` | Enable UnoCSS support |
|
|
57
|
-
| `stylistic` | `boolean \| StylisticConfig` | `true` | Enable stylistic rules |
|
|
58
|
-
| `formatters` | `boolean \| FormatterConfig` | `false` | Enable formatters |
|
|
59
|
-
| `jsx` | `boolean` | `false` | Enable JSX support |
|
|
60
|
-
| `pnpm` | `boolean` | `false` | Enable pnpm-specific rules |
|
|
61
|
-
| `ignores` | `string[]` | `[]` | Additional ignore patterns |
|
|
62
|
-
|
|
63
|
-
### Examples
|
|
64
|
-
|
|
65
|
-
#### Basic Library Configuration
|
|
43
|
+
### 使用预设配置
|
|
66
44
|
|
|
67
45
|
```javascript
|
|
68
|
-
|
|
46
|
+
// eslint.config.mjs
|
|
47
|
+
import eslint9, { applyPreset } from '@truenine/eslint9-config'
|
|
69
48
|
|
|
70
49
|
export default eslint9({
|
|
71
50
|
type: 'lib',
|
|
72
|
-
typescript:
|
|
73
|
-
|
|
51
|
+
typescript: {
|
|
52
|
+
strictTypescriptEslint: true,
|
|
53
|
+
tsconfigPath: './tsconfig.json',
|
|
54
|
+
},
|
|
55
|
+
// 使用平衡预设
|
|
56
|
+
...applyPreset('balanced'),
|
|
74
57
|
})
|
|
75
58
|
```
|
|
76
59
|
|
|
77
|
-
|
|
60
|
+
### 自定义配置
|
|
78
61
|
|
|
79
62
|
```javascript
|
|
80
|
-
|
|
63
|
+
// eslint.config.mjs
|
|
64
|
+
import eslint9, { applyPreset } from '@truenine/eslint9-config'
|
|
81
65
|
|
|
82
66
|
export default eslint9({
|
|
83
|
-
type: '
|
|
67
|
+
type: 'lib',
|
|
84
68
|
vue: true,
|
|
85
|
-
typescript:
|
|
86
|
-
|
|
87
|
-
|
|
69
|
+
typescript: {
|
|
70
|
+
strictTypescriptEslint: true,
|
|
71
|
+
tsconfigPath: './tsconfig.json',
|
|
72
|
+
},
|
|
73
|
+
// 自定义缓存配置
|
|
74
|
+
cache: {
|
|
75
|
+
location: '.eslintcache',
|
|
76
|
+
strategy: 'metadata',
|
|
77
|
+
},
|
|
78
|
+
// 性能优化配置
|
|
79
|
+
performance: {
|
|
80
|
+
parallel: true,
|
|
81
|
+
skipExpensiveRules: false,
|
|
82
|
+
},
|
|
83
|
+
// 规则优化配置
|
|
84
|
+
ruleOptimization: {
|
|
85
|
+
progressive: true,
|
|
86
|
+
criticalFirst: true,
|
|
87
|
+
customOverrides: {
|
|
88
|
+
'ts/no-explicit-any': 'warn',
|
|
89
|
+
'complexity': ['warn', { max: 15 }],
|
|
90
|
+
},
|
|
91
|
+
},
|
|
88
92
|
})
|
|
89
93
|
```
|
|
90
94
|
|
|
91
|
-
|
|
95
|
+
## 配置选项
|
|
92
96
|
|
|
93
|
-
|
|
94
|
-
import eslint9 from '@truenine/eslint9-config'
|
|
97
|
+
### 缓存配置 (cache)
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
99
|
+
```typescript
|
|
100
|
+
cache?: boolean | {
|
|
101
|
+
/** 缓存位置,默认为 .eslintcache */
|
|
102
|
+
location?: string
|
|
103
|
+
/** 缓存策略,默认为 metadata */
|
|
104
|
+
strategy?: 'metadata' | 'content'
|
|
105
|
+
}
|
|
102
106
|
```
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
### 性能配置 (performance)
|
|
105
109
|
|
|
106
|
-
|
|
110
|
+
```typescript
|
|
111
|
+
performance?: {
|
|
112
|
+
/** 启用并行处理,默认为 true */
|
|
113
|
+
parallel?: boolean
|
|
114
|
+
/** 最大并行数,默认为 CPU 核心数 */
|
|
115
|
+
maxParallel?: number
|
|
116
|
+
/** 忽略性能影响大的规则 */
|
|
117
|
+
skipExpensiveRules?: boolean
|
|
118
|
+
}
|
|
119
|
+
```
|
|
107
120
|
|
|
108
|
-
|
|
121
|
+
### 规则优化配置 (ruleOptimization)
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
ruleOptimization?: {
|
|
125
|
+
/** 是否启用渐进式检查 */
|
|
126
|
+
progressive?: boolean
|
|
127
|
+
/** 关键文件优先检查 */
|
|
128
|
+
criticalFirst?: boolean
|
|
129
|
+
/** 跳过性能影响大的规则 */
|
|
130
|
+
skipExpensive?: boolean
|
|
131
|
+
/** 自定义规则覆盖 */
|
|
132
|
+
customOverrides?: Record<string, string>
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## 预设配置详情
|
|
137
|
+
|
|
138
|
+
### Performance 预设
|
|
139
|
+
适用于大型项目或 CI 环境,优先考虑检查速度:
|
|
140
|
+
- 启用 metadata 缓存策略
|
|
141
|
+
- 跳过性能影响大的规则
|
|
142
|
+
- 启用渐进式检查
|
|
143
|
+
|
|
144
|
+
### Quality 预设
|
|
145
|
+
适用于小型项目或开发环境,优先考虑代码质量:
|
|
146
|
+
- 启用 content 缓存策略
|
|
147
|
+
- 保留所有质量检查规则
|
|
148
|
+
- 严格的错误级别
|
|
149
|
+
|
|
150
|
+
### Balanced 预设
|
|
151
|
+
默认推荐配置,平衡性能和质量:
|
|
152
|
+
- metadata 缓存策略
|
|
153
|
+
- 适中的规则严格程度
|
|
154
|
+
- 启用关键文件优先检查
|
|
155
|
+
|
|
156
|
+
### CI 预设
|
|
157
|
+
专为持续集成环境优化:
|
|
158
|
+
- 跳过耗时规则
|
|
159
|
+
- 只保留关键错误检查
|
|
160
|
+
- 忽略测试文件
|
|
161
|
+
|
|
162
|
+
### Dev 预设
|
|
163
|
+
开发环境友好配置:
|
|
164
|
+
- 更宽松的规则设置
|
|
165
|
+
- 允许 console 和 debugger
|
|
166
|
+
- 警告级别而非错误级别
|
|
167
|
+
|
|
168
|
+
### Library 预设
|
|
169
|
+
适用于开源库或组件库:
|
|
170
|
+
- 最严格的规则设置
|
|
171
|
+
- 要求完整的类型注解
|
|
172
|
+
- 强制文档注释
|
|
173
|
+
|
|
174
|
+
## 性能优化建议
|
|
175
|
+
|
|
176
|
+
### 1. 启用缓存
|
|
177
|
+
```bash
|
|
178
|
+
# package.json
|
|
109
179
|
{
|
|
110
180
|
"scripts": {
|
|
111
|
-
"lint": "eslint ."
|
|
112
|
-
"lint:fix": "eslint . --fix"
|
|
181
|
+
"lint": "eslint --fix --cache --cache-location .eslintcache"
|
|
113
182
|
}
|
|
114
183
|
}
|
|
115
184
|
```
|
|
116
185
|
|
|
117
|
-
|
|
186
|
+
### 2. 使用合适的预设
|
|
187
|
+
- 开发环境使用 `dev` 预设
|
|
188
|
+
- CI 环境使用 `ci` 预设
|
|
189
|
+
- 生产库使用 `library` 预设
|
|
118
190
|
|
|
119
|
-
###
|
|
120
|
-
|
|
121
|
-
|
|
191
|
+
### 3. 配置忽略模式
|
|
192
|
+
确保 `.eslintignore` 或配置中包含不需要检查的文件:
|
|
193
|
+
```
|
|
194
|
+
dist/
|
|
195
|
+
build/
|
|
196
|
+
coverage/
|
|
197
|
+
.turbo/
|
|
198
|
+
node_modules/
|
|
199
|
+
*.min.js
|
|
200
|
+
```
|
|
122
201
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
"typescript",
|
|
130
|
-
"typescriptreact",
|
|
131
|
-
"vue"
|
|
132
|
-
]
|
|
202
|
+
### 4. 渐进式检查
|
|
203
|
+
对于大型项目,启用渐进式检查:
|
|
204
|
+
```javascript
|
|
205
|
+
ruleOptimization: {
|
|
206
|
+
progressive: true,
|
|
207
|
+
criticalFirst: true,
|
|
133
208
|
}
|
|
134
209
|
```
|
|
135
210
|
|
|
136
|
-
##
|
|
211
|
+
## 故障排除
|
|
212
|
+
|
|
213
|
+
### 缓存问题
|
|
214
|
+
如果遇到缓存相关问题,可以清理缓存:
|
|
215
|
+
```bash
|
|
216
|
+
rm -rf .eslintcache
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### 性能问题
|
|
220
|
+
如果检查速度过慢,可以:
|
|
221
|
+
1. 启用 `skipExpensiveRules` 选项
|
|
222
|
+
2. 使用 `performance` 预设
|
|
223
|
+
3. 增加忽略模式
|
|
137
224
|
|
|
138
|
-
|
|
225
|
+
### 规则冲突
|
|
226
|
+
如果遇到规则冲突,可以通过 `customOverrides` 覆盖:
|
|
227
|
+
```javascript
|
|
228
|
+
ruleOptimization: {
|
|
229
|
+
customOverrides: {
|
|
230
|
+
'conflicting-rule': 'off',
|
|
231
|
+
},
|
|
232
|
+
}
|
|
233
|
+
```
|
|
139
234
|
|
|
140
|
-
##
|
|
235
|
+
## 更新日志
|
|
141
236
|
|
|
142
|
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
237
|
+
### v1.0.0
|
|
238
|
+
- 初始版本
|
|
239
|
+
- 支持缓存优化
|
|
240
|
+
- 提供预设配置
|
|
241
|
+
- 集成规则优化器
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { AntFuFormatterConfig, AntFuJsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from "../types/index.js";
|
|
2
|
+
|
|
3
|
+
//#region src/defaults/index.d.ts
|
|
4
|
+
declare const defaultUnocssConfig: AntFuUnocssConfig;
|
|
5
|
+
declare const defaultVueConfig: AntFuVueConfig;
|
|
6
|
+
declare const defaultJsConfig: AntFuJsConfig;
|
|
7
|
+
declare const defaultTsConfig: AntFuTsConfig;
|
|
8
|
+
declare const defaultFormatterConfig: AntFuFormatterConfig;
|
|
9
|
+
/**
|
|
10
|
+
* 严格 ts 模式 的默认配置
|
|
11
|
+
*
|
|
12
|
+
* 这些配置需要 配置 parserOptions 和 tsconfigPath 等
|
|
13
|
+
* @see https://typescript-eslint.io/getting-started/typed-linting
|
|
14
|
+
*/
|
|
15
|
+
declare const defaultStrictTsConfig: AntFuTsConfig;
|
|
16
|
+
declare const defaultStylisticConfig: AntFuStylisticConfig;
|
|
17
|
+
declare const defaultTestConfig: AntFuTestConfig;
|
|
18
|
+
/**
|
|
19
|
+
* 合并配置项,支持以下场景:
|
|
20
|
+
* 1. 布尔值与对象配置的混合
|
|
21
|
+
* 2. 使用 vite 的 mergeConfig 进行对象合并
|
|
22
|
+
* 3. 处理 undefined 和 null 的默认值
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // 场景1: 布尔值转换为默认对象
|
|
27
|
+
* mergeWithDefaults(true, { foo: 'bar' }) // => { foo: 'bar' }
|
|
28
|
+
*
|
|
29
|
+
* // 场景2: vite配置合并
|
|
30
|
+
* mergeWithDefaults({ plugins: [vue()] }, { plugins: [unocss()] })
|
|
31
|
+
*
|
|
32
|
+
* // 场景3: undefined/null/false 处理
|
|
33
|
+
* mergeWithDefaults(false, true) // => false
|
|
34
|
+
* ```
|
|
35
|
+
*/
|
|
36
|
+
declare function mergeWithDefaults<T extends object>(value?: boolean | T | null, defaults?: T): T;
|
|
37
|
+
declare function mergeWithDefaults<T extends object>(value?: boolean | T | null, defaults?: boolean): boolean | T;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { defaultFormatterConfig, defaultJsConfig, defaultStrictTsConfig, defaultStylisticConfig, defaultTestConfig, defaultTsConfig, defaultUnocssConfig, defaultVueConfig, mergeWithDefaults };
|
|
40
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["defaultUnocssConfig: AntFuUnocssConfig","defaultVueConfig: AntFuVueConfig","defaultJsConfig: AntFuJsConfig","defaultTsConfig: AntFuTsConfig","defaultFormatterConfig: AntFuFormatterConfig","defaultStrictTsConfig: AntFuTsConfig","defaultStylisticConfig: AntFuStylisticConfig","defaultTestConfig: AntFuTestConfig"],"sources":["../../src/defaults/index.ts"],"sourcesContent":[],"mappings":";;;cAEaA,qBAAqB;cAKrBC,kBAAkB;AALlBD,cAyEAE,eAzEqB,EAyEJ,aAzEI;AAKrBD,cA2FAE,eA3FkB,EA2FD,aA3FC;AAoElBD,cAgDAE,sBAhDiB,EAgDO,oBAhDP;AAuB9B;AAyBA;AAsBA;AAUA;AAYA;AA8BA;AAAgB,cApDHC,qBAoDG,EApDoB,aAoDpB;AACI,cA3CPC,sBA2CO,EA3CiB,oBA2CjB;AACP,cAhCAC,iBAgCA,EAhCmB,eAgCnB;;;AAEb;;;;;;;;;;;;;;;;iBAJgB,sDACI,qBACP,IACV;iBACa,sDACI,yCAEP"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["defaultUnocssConfig: AntFuUnocssConfig","defaultVueConfig: AntFuVueConfig","defaultJsConfig: AntFuJsConfig","defaultTsConfig: AntFuTsConfig","defaultFormatterConfig: AntFuFormatterConfig","defaultStrictTsConfig: AntFuTsConfig","defaultStylisticConfig: AntFuStylisticConfig","defaultTestConfig: AntFuTestConfig"
|
|
1
|
+
{"version":3,"file":"index.js","names":["defaultUnocssConfig: AntFuUnocssConfig","defaultVueConfig: AntFuVueConfig","defaultJsConfig: AntFuJsConfig","defaultTsConfig: AntFuTsConfig","defaultFormatterConfig: AntFuFormatterConfig","defaultStrictTsConfig: AntFuTsConfig","defaultStylisticConfig: AntFuStylisticConfig","defaultTestConfig: AntFuTestConfig"],"sources":["../../src/defaults/index.ts"],"sourcesContent":["import type { AntFuFormatterConfig, AntFuJsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from '../types'\n\nexport const defaultUnocssConfig: AntFuUnocssConfig = {\n attributify: true,\n strict: true,\n}\n\nexport const defaultVueConfig: AntFuVueConfig = {\n vueVersion: 3,\n overrides: {\n 'vue/html-self-closing': ['error', {\n html: {\n void: 'always',\n normal: 'always',\n component: 'always',\n },\n }],\n 'vue/html-comment-content-spacing': ['error', 'always', { exceptions: [] }],\n 'vue/html-comment-indent': ['error', 2],\n 'vue/html-indent': ['error', 2, {\n baseIndent: 0,\n alignAttributesVertically: true,\n }],\n 'vue/define-emits-declaration': ['error', 'type-literal'],\n 'vue/define-props-declaration': ['error', 'type-based'],\n 'vue/define-macros-order': [\n 'error',\n {\n order: [\n 'defineProps',\n 'defineEmits',\n 'defineModel',\n 'defineSlots',\n ],\n defineExposeLast: true,\n },\n ],\n 'vue/block-order': [\n 'error',\n {\n order: ['script', 'template', 'style'],\n },\n ],\n 'vue/attributes-order': [\n 'error',\n {\n order: ['DEFINITION', 'LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'OTHER_DIRECTIVES', 'OTHER_ATTR', 'EVENTS', 'CONTENT'],\n },\n ],\n 'vue/v-on-event-hyphenation': [\n 'error',\n 'never',\n {\n autofix: true,\n },\n ],\n 'vue/attribute-hyphenation': [\n 'error',\n 'never',\n {\n ignoreTags: ['i-', 'v-', 'v-bind'],\n },\n ],\n 'vue/prop-name-casing': ['error', 'camelCase'],\n 'vue/component-name-in-template-casing': [\n 'error',\n 'PascalCase',\n {\n ignores: ['router-view', 'router-link', 'scroll-view'],\n registeredComponentsOnly: false,\n },\n ],\n },\n}\n\nexport const defaultJsConfig: AntFuJsConfig = {\n overrides: {\n 'no-inline-comments': 'error',\n 'unicorn/no-useless-spread': 'error',\n\n 'curly': ['error', 'all'],\n 'no-undefined': 'error',\n 'no-cond-assign': ['error', 'always'],\n 'no-constant-condition': 'error',\n 'no-restricted-syntax': 'error',\n 'no-global-assign': 'error',\n 'no-unused-vars': 'error',\n 'no-var': 'error',\n 'prefer-const': [\n 'error',\n {\n destructuring: 'any',\n ignoreReadBeforeAssign: false,\n },\n ],\n },\n}\n\nexport const defaultTsConfig: AntFuTsConfig = {\n overrides: {\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-return': 'off',\n 'ts/member-ordering': ['error'],\n 'ts/no-extra-non-null-assertion': 'error',\n 'ts/no-non-null-assertion': 'error',\n 'ts/no-explicit-any': ['error', {\n fixToUnknown: true,\n ignoreRestArgs: true,\n }],\n 'ts/no-namespace': 'error',\n 'ts/no-unused-vars': [\n 'error',\n {\n vars: 'all',\n args: 'after-used',\n ignoreRestSiblings: false,\n },\n ],\n },\n}\n\nexport const defaultFormatterConfig: AntFuFormatterConfig = {\n css: 'prettier',\n html: 'prettier',\n prettierOptions: {\n printWidth: 160,\n tabWidth: 2,\n arrowParens: 'always',\n vueIndentScriptAndStyle: true,\n useTabs: false,\n singleQuote: true,\n jsxSingleQuote: true,\n trailingComma: 'all',\n bracketSpacing: true,\n },\n}\n\n/**\n * 严格 ts 模式 的默认配置\n *\n * 这些配置需要 配置 parserOptions 和 tsconfigPath 等\n * @see https://typescript-eslint.io/getting-started/typed-linting\n */\nexport const defaultStrictTsConfig: AntFuTsConfig = {\n overrides: {\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-return': 'off',\n 'ts/no-floating-promises': 'error',\n },\n}\n\nexport const defaultStylisticConfig: AntFuStylisticConfig = {\n jsx: true,\n indent: 2,\n quotes: 'single',\n semi: false,\n overrides: {\n 'style/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],\n 'style/brace-style': ['error', '1tbs'],\n 'style/arrow-parens': ['error', 'always'],\n },\n}\n\nexport const defaultTestConfig: AntFuTestConfig = {\n overrides: {\n 'no-console': 'off',\n 'ts/unbound-method': 'off',\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-member-access': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-return': 'off',\n },\n}\n\n/**\n * 合并配置项,支持以下场景:\n * 1. 布尔值与对象配置的混合\n * 2. 使用 vite 的 mergeConfig 进行对象合并\n * 3. 处理 undefined 和 null 的默认值\n *\n * @example\n * ```ts\n * // 场景1: 布尔值转换为默认对象\n * mergeWithDefaults(true, { foo: 'bar' }) // => { foo: 'bar' }\n *\n * // 场景2: vite配置合并\n * mergeWithDefaults({ plugins: [vue()] }, { plugins: [unocss()] })\n *\n * // 场景3: undefined/null/false 处理\n * mergeWithDefaults(false, true) // => false\n * ```\n */\nexport function mergeWithDefaults<T extends object>(\n value?: boolean | T | null,\n defaults?: T\n): T\nexport function mergeWithDefaults<T extends object>(\n value?: boolean | T | null,\n defaults?: boolean\n): boolean | T\nexport function mergeWithDefaults<T extends object>(\n value?: boolean | T | null,\n defaults?: boolean | T | null,\n): boolean | T {\n // 处理无默认值的情况\n if (defaults === false || defaults === null || defaults === void 0) {\n if (value === true) {\n return true\n }\n if (value === false || value === null) {\n return false\n }\n return value as T\n }\n\n // 处理 value 为 undefined 的情况\n if (value === void 0) {\n return defaults\n }\n\n // 处理 value 为 false/null 的情况\n if (value === false || value === null) {\n return false\n }\n\n // 处理 value 为 true 的情况\n if (value === true) {\n return defaults\n }\n\n // 如果都是对象,使用 vite 的 mergeConfig 进行合并\n if (typeof value === 'object' && typeof defaults === 'object') {\n return {\n ...defaults,\n ...value,\n }\n }\n\n // 其他情况返回 value\n return value\n}\n"],"mappings":"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"}
|
package/dist/index.d.ts
CHANGED
|
@@ -15,7 +15,8 @@ interface ConfigOptions {
|
|
|
15
15
|
unocss?: boolean | AntFuUnocssConfig;
|
|
16
16
|
stylistic?: boolean | AntFuStylisticConfig;
|
|
17
17
|
}
|
|
18
|
+
declare function applyPreset(options?: ConfigOptions): Promise<ReturnType<typeof antfu>>;
|
|
18
19
|
declare function eslint9(options?: ConfigOptions): Promise<ReturnType<typeof antfu>>;
|
|
19
20
|
//#endregion
|
|
20
|
-
export { eslint9 as default };
|
|
21
|
+
export { ConfigOptions, applyPreset, eslint9 as default };
|
|
21
22
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;UAKiB,aAAA;;EAAjB,IAAiB,CAAA,EAAA,OAAA;EAAA,IAAA,CAAA,EAAA,OAAA,GAGE,eAHF;SAGE,CAAA,EAAA,MAAA,EAAA;QAGD,OAAA;QACO,OAAA,GADP,cACO;YACV,CAAA,EAAA,OAAA,GADU,oBACV;YACU,CAAA,EADV,aACU;YAAsB,CAAA,EAAA,OAAA,GAAtB,mBAAsB,GAAA,aAAA;QAC1B,CAAA,EAAA,OAAA,GAAA,iBAAA;WACG,CAAA,EAAA,OAAA,GAAA,oBAAA;;AAGF,iBAAA,WAAA,CAAA,OAAA,CAAA,EAAqB,aAArB,CAAA,EAA0C,OAA1C,CAAkD,UAAlD,CAAA,OAAoE,KAApE,CAAA,CAAA;AAAA,iBAIQ,OAAA,CAJR,OAAA,CAAA,EAIyB,aAJzB,CAAA,EAI8C,OAJ9C,CAIsD,UAJtD,CAAA,OAIwE,KAJxE,CAAA,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -2,6 +2,9 @@ import { defaultFormatterConfig, defaultJsConfig, defaultStrictTsConfig, default
|
|
|
2
2
|
import { antfu } from "@antfu/eslint-config";
|
|
3
3
|
|
|
4
4
|
//#region src/index.ts
|
|
5
|
+
async function applyPreset(options = {}) {
|
|
6
|
+
return eslint9(options);
|
|
7
|
+
}
|
|
5
8
|
async function eslint9(options = {}) {
|
|
6
9
|
const { type = "lib", ignores = [], test = true, unocss = false, vue = false, jsx = false, pnpm = false, stylistic = true, javascript = defaultJsConfig, typescript = defaultTsConfig, formatters = false } = options;
|
|
7
10
|
const _test = mergeWithDefaults(test, defaultTestConfig);
|
|
@@ -33,5 +36,5 @@ async function eslint9(options = {}) {
|
|
|
33
36
|
}
|
|
34
37
|
|
|
35
38
|
//#endregion
|
|
36
|
-
export { eslint9 as default };
|
|
39
|
+
export { applyPreset, eslint9 as default };
|
|
37
40
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/index.ts"],"sourcesContent":["import type { OptionsTypeScriptParserOptions } from '@antfu/eslint-config'\nimport type { AntFuFormatterConfig, AntFuJsConfig, AntFuStrictTsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from './types/index'\nimport { antfu } from '@antfu/eslint-config'\nimport { defaultFormatterConfig, defaultJsConfig, defaultStrictTsConfig, defaultStylisticConfig, defaultTestConfig, defaultTsConfig, defaultUnocssConfig, defaultVueConfig, mergeWithDefaults } from './defaults/index'\n\nexport interface ConfigOptions {\n type?: 'app' | 'lib'\n pnpm?: boolean\n test?: boolean | AntFuTestConfig\n ignores?: string[]\n jsx?: boolean\n vue?: boolean | AntFuVueConfig\n formatters?: boolean | AntFuFormatterConfig\n javascript?: AntFuJsConfig\n typescript?: boolean | AntFuStrictTsConfig | AntFuTsConfig\n unocss?: boolean | AntFuUnocssConfig\n stylistic?: boolean | AntFuStylisticConfig\n}\n\nexport async function applyPreset(options: ConfigOptions = {}): Promise<ReturnType<typeof antfu>> {\n return eslint9(options)\n}\n\nexport default async function eslint9(options: ConfigOptions = {}): Promise<ReturnType<typeof antfu>> {\n const {\n type = 'lib',\n ignores = [],\n test = true,\n unocss = false,\n vue = false,\n jsx = false,\n pnpm = false,\n stylistic = true,\n javascript = defaultJsConfig,\n typescript = defaultTsConfig,\n formatters = false,\n } = options\n\n const _test = mergeWithDefaults(test, defaultTestConfig)\n const _unocss = mergeWithDefaults(unocss, defaultUnocssConfig)\n const _vue = mergeWithDefaults(vue, defaultVueConfig)\n const _javascript = mergeWithDefaults(javascript, defaultJsConfig)\n const _stylistic = mergeWithDefaults(stylistic, defaultStylisticConfig)\n const _formatters = mergeWithDefaults(formatters, defaultFormatterConfig)\n let _typescript = typescript\n\n // 如果 type 为 'app',强制 pnpm 为 false\n let _pnpm = pnpm\n if (type === 'app') {\n _pnpm = false\n }\n\n // 严格 ts 模式\n if (\n _typescript !== null\n && typeof _typescript === 'object'\n && 'strictTypescriptEslint' in _typescript\n && _typescript.strictTypescriptEslint === true\n ) {\n _typescript = mergeWithDefaults(typescript, defaultStrictTsConfig)\n if (typeof _typescript === 'object' && 'tsconfigPath' in _typescript) {\n (_typescript as OptionsTypeScriptParserOptions).parserOptions = {\n projectService: true,\n }\n }\n }\n\n return antfu({\n type,\n ignores,\n pnpm: _pnpm,\n test: _test,\n unocss: _unocss,\n vue: _vue,\n jsx,\n typescript: _typescript,\n javascript: _javascript,\n stylistic: _stylistic,\n formatters: _formatters,\n })\n}\n"],"mappings":";;;;AAmBA,eAAsB,YAAY,UAAyB,EAAE,EAAqC;AAChG,QAAO,QAAQ,QAAQ;;AAGzB,eAA8B,QAAQ,UAAyB,EAAE,EAAqC;CACpG,MAAM,EACJ,OAAO,OACP,UAAU,EAAE,EACZ,OAAO,MACP,SAAS,OACT,MAAM,OACN,MAAM,OACN,OAAO,OACP,YAAY,MACZ,aAAa,iBACb,aAAa,iBACb,aAAa,UACX;CAEJ,MAAM,QAAQ,kBAAkB,MAAM,kBAAkB;CACxD,MAAM,UAAU,kBAAkB,QAAQ,oBAAoB;CAC9D,MAAM,OAAO,kBAAkB,KAAK,iBAAiB;CACrD,MAAM,cAAc,kBAAkB,YAAY,gBAAgB;CAClE,MAAM,aAAa,kBAAkB,WAAW,uBAAuB;CACvE,MAAM,cAAc,kBAAkB,YAAY,uBAAuB;CACzE,IAAI,cAAc;CAGlB,IAAI,QAAQ;AACZ,KAAI,SAAS,MACX,SAAQ;AAIV,KACE,gBAAgB,QACb,OAAO,gBAAgB,YACvB,4BAA4B,eAC5B,YAAY,2BAA2B,MAC1C;AACA,gBAAc,kBAAkB,YAAY,sBAAsB;AAClE,MAAI,OAAO,gBAAgB,YAAY,kBAAkB,YACvD,CAAC,YAA+C,gBAAgB,EAC9D,gBAAgB,MACjB;;AAIL,QAAO,MAAM;EACX;EACA;EACA,MAAM;EACN,MAAM;EACN,QAAQ;EACR,KAAK;EACL;EACA,YAAY;EACZ,YAAY;EACZ,WAAW;EACX,YAAY;EACb,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -42,5 +42,5 @@ type AntFuStrictTsConfig = AntFuTsConfig & {
|
|
|
42
42
|
tsconfigPath: string;
|
|
43
43
|
};
|
|
44
44
|
//#endregion
|
|
45
|
-
export { AntFuFormatterConfig, AntFuJsConfig, AntFuStrictTsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig };
|
|
45
|
+
export { AntFuConfig, AntFuFormatterConfig, AntFuJsConfig, AntFuStrictTsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig };
|
|
46
46
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAAY,KAAA,WAAA,GAAc,WAAd,CAA0B,UAA1B,CAAA,OAA4C,OAA5C,CAAA,CAAA,CAAA,CAAA,CAAA;;;;AAAc,KAKd,aAAA,GAAgB,OALF,CAKU,WALV,CAAA,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;AAK1B;;;AAA4B,KAKhB,aAAA,GAAgB,OALA,CAKQ,WALR,CAAA,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAAY,KAAA,WAAA,GAAc,WAAd,CAA0B,UAA1B,CAAA,OAA4C,OAA5C,CAAA,CAAA,CAAA,CAAA,CAAA;;;;AAAc,KAKd,aAAA,GAAgB,OALF,CAKU,WALV,CAAA,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;AAK1B;;;AAA4B,KAKhB,aAAA,GAAgB,OALA,CAKQ,WALR,CAAA,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;;AAK5B;;AAAoC,KAKxB,cAAA,GAAiB,OALO,CAKC,WALD,CAAA,KAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;;;AAKpC;AAAY,KAKA,iBAAA,GAAoB,OALpB,CAK4B,WAL5B,CAAA,QAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;;;;AAKA,KAKA,oBAAA,GAAuB,OALvB,CAK+B,WAL/B,CAAA,WAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;;;;AAAoB,KAUpB,oBAAA,GAAuB,OAVH,CAUW,WAVX,CAAA,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;AAKhC;;;AAAmC,KAUvB,eAAA,GAAkB,OAVK,CAUG,WAVH,CAAA,MAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;;AAKnC;;AAA2C,KAS/B,mBAAA,GAAsB,aATS,GAAA;wBAAR,EAAA,IAAA;EAAA,YAAA,EAAA,MAAA;AAKnC,CAAA"}
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@truenine/eslint9-config",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.17",
|
|
5
5
|
"description": "ESLint 9 configuration package for Compose Client projects with TypeScript, Vue, and modern JavaScript support",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "TrueNine",
|
|
@@ -56,36 +56,35 @@
|
|
|
56
56
|
"registry": "https://registry.npmjs.org/"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@antfu/eslint-config": "^5.
|
|
60
|
-
"@eslint/js": "^9.
|
|
61
|
-
"@unocss/eslint-config": "^66.
|
|
59
|
+
"@antfu/eslint-config": "^5.4.1",
|
|
60
|
+
"@eslint/js": "^9.36.0",
|
|
61
|
+
"@unocss/eslint-config": "^66.5.2",
|
|
62
62
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
63
63
|
"@vue/eslint-config-typescript": "^14.6.0",
|
|
64
|
-
"eslint": "^9.
|
|
65
|
-
"eslint-plugin-format": "^1.0.
|
|
66
|
-
"eslint-plugin-prettier": "^5.5.
|
|
67
|
-
"eslint-plugin-vue": "^10.
|
|
64
|
+
"eslint": "^9.37.0",
|
|
65
|
+
"eslint-plugin-format": "^1.0.2",
|
|
66
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
67
|
+
"eslint-plugin-vue": "^10.5.0",
|
|
68
68
|
"prettier": "^3.6.2",
|
|
69
|
-
"typescript-eslint": "^8.
|
|
69
|
+
"typescript-eslint": "^8.45.0"
|
|
70
70
|
},
|
|
71
71
|
"dependencies": {
|
|
72
|
-
"@antfu/eslint-config": "^5.
|
|
73
|
-
"@eslint/js": "^9.
|
|
74
|
-
"@unocss/eslint-config": "^66.
|
|
72
|
+
"@antfu/eslint-config": "^5.4.1",
|
|
73
|
+
"@eslint/js": "^9.36.0",
|
|
74
|
+
"@unocss/eslint-config": "^66.5.2",
|
|
75
75
|
"@vue/eslint-config-prettier": "^10.2.0",
|
|
76
76
|
"@vue/eslint-config-typescript": "^14.6.0",
|
|
77
|
-
"eslint": "^9.
|
|
78
|
-
"eslint-plugin-format": "^1.0.
|
|
79
|
-
"eslint-plugin-prettier": "^5.5.
|
|
80
|
-
"eslint-plugin-vue": "^10.
|
|
77
|
+
"eslint": "^9.37.0",
|
|
78
|
+
"eslint-plugin-format": "^1.0.2",
|
|
79
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
80
|
+
"eslint-plugin-vue": "^10.5.0",
|
|
81
81
|
"prettier": "^3.6.2",
|
|
82
|
-
"typescript-eslint": "^8.
|
|
82
|
+
"typescript-eslint": "^8.45.0"
|
|
83
83
|
},
|
|
84
84
|
"scripts": {
|
|
85
85
|
"build": "tsdown",
|
|
86
|
-
"build-c": "vite build",
|
|
87
86
|
"lint": "eslint --fix",
|
|
88
|
-
"type-check": "
|
|
87
|
+
"type-check": "tsc --noEmit -p tsconfig.lib.json",
|
|
89
88
|
"test": "vitest run",
|
|
90
89
|
"copy-license": "node -e \"require('fs').copyFileSync('../../LICENSE', './LICENSE')\""
|
|
91
90
|
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
//#region rolldown:runtime
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
-
key = keys[i];
|
|
11
|
-
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
-
get: ((k) => from[k]).bind(null, key),
|
|
13
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
-
value: mod,
|
|
20
|
-
enumerable: true
|
|
21
|
-
}) : target, mod));
|
|
22
|
-
|
|
23
|
-
//#endregion
|
|
24
|
-
|
|
25
|
-
exports.__toESM = __toESM;
|
package/dist/defaults/index.cjs
DELETED
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
//#region src/defaults/index.ts
|
|
3
|
-
const defaultUnocssConfig = {
|
|
4
|
-
attributify: true,
|
|
5
|
-
strict: true
|
|
6
|
-
};
|
|
7
|
-
const defaultVueConfig = {
|
|
8
|
-
vueVersion: 3,
|
|
9
|
-
overrides: {
|
|
10
|
-
"vue/html-self-closing": ["error", { html: {
|
|
11
|
-
void: "always",
|
|
12
|
-
normal: "always",
|
|
13
|
-
component: "always"
|
|
14
|
-
} }],
|
|
15
|
-
"vue/html-comment-content-spacing": [
|
|
16
|
-
"error",
|
|
17
|
-
"always",
|
|
18
|
-
{ exceptions: [] }
|
|
19
|
-
],
|
|
20
|
-
"vue/html-comment-indent": ["error", 2],
|
|
21
|
-
"vue/html-indent": [
|
|
22
|
-
"error",
|
|
23
|
-
2,
|
|
24
|
-
{
|
|
25
|
-
baseIndent: 0,
|
|
26
|
-
alignAttributesVertically: true
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"vue/define-emits-declaration": ["error", "type-literal"],
|
|
30
|
-
"vue/define-props-declaration": ["error", "type-based"],
|
|
31
|
-
"vue/define-macros-order": ["error", {
|
|
32
|
-
order: [
|
|
33
|
-
"defineProps",
|
|
34
|
-
"defineEmits",
|
|
35
|
-
"defineModel",
|
|
36
|
-
"defineSlots"
|
|
37
|
-
],
|
|
38
|
-
defineExposeLast: true
|
|
39
|
-
}],
|
|
40
|
-
"vue/block-order": ["error", { order: [
|
|
41
|
-
"script",
|
|
42
|
-
"template",
|
|
43
|
-
"style"
|
|
44
|
-
] }],
|
|
45
|
-
"vue/attributes-order": ["error", { order: [
|
|
46
|
-
"DEFINITION",
|
|
47
|
-
"LIST_RENDERING",
|
|
48
|
-
"CONDITIONALS",
|
|
49
|
-
"RENDER_MODIFIERS",
|
|
50
|
-
"GLOBAL",
|
|
51
|
-
"UNIQUE",
|
|
52
|
-
"TWO_WAY_BINDING",
|
|
53
|
-
"OTHER_DIRECTIVES",
|
|
54
|
-
"OTHER_ATTR",
|
|
55
|
-
"EVENTS",
|
|
56
|
-
"CONTENT"
|
|
57
|
-
] }],
|
|
58
|
-
"vue/v-on-event-hyphenation": [
|
|
59
|
-
"error",
|
|
60
|
-
"never",
|
|
61
|
-
{ autofix: true }
|
|
62
|
-
],
|
|
63
|
-
"vue/attribute-hyphenation": [
|
|
64
|
-
"error",
|
|
65
|
-
"never",
|
|
66
|
-
{ ignoreTags: [
|
|
67
|
-
"i-",
|
|
68
|
-
"v-",
|
|
69
|
-
"v-bind"
|
|
70
|
-
] }
|
|
71
|
-
],
|
|
72
|
-
"vue/prop-name-casing": ["error", "camelCase"],
|
|
73
|
-
"vue/component-name-in-template-casing": [
|
|
74
|
-
"error",
|
|
75
|
-
"PascalCase",
|
|
76
|
-
{
|
|
77
|
-
ignores: [
|
|
78
|
-
"router-view",
|
|
79
|
-
"router-link",
|
|
80
|
-
"scroll-view"
|
|
81
|
-
],
|
|
82
|
-
registeredComponentsOnly: false
|
|
83
|
-
}
|
|
84
|
-
]
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
const defaultJsConfig = { overrides: {
|
|
88
|
-
"no-inline-comments": "error",
|
|
89
|
-
"unicorn/no-useless-spread": "error",
|
|
90
|
-
"curly": ["error", "all"],
|
|
91
|
-
"no-undefined": "error",
|
|
92
|
-
"no-cond-assign": ["error", "always"],
|
|
93
|
-
"no-constant-condition": "error",
|
|
94
|
-
"no-restricted-syntax": "error",
|
|
95
|
-
"no-global-assign": "error",
|
|
96
|
-
"no-unused-vars": "error",
|
|
97
|
-
"no-var": "error",
|
|
98
|
-
"prefer-const": ["error", {
|
|
99
|
-
destructuring: "any",
|
|
100
|
-
ignoreReadBeforeAssign: false
|
|
101
|
-
}]
|
|
102
|
-
} };
|
|
103
|
-
const defaultTsConfig = { overrides: {
|
|
104
|
-
"ts/no-unsafe-assignment": "off",
|
|
105
|
-
"ts/no-unsafe-call": "off",
|
|
106
|
-
"ts/no-unsafe-argument": "off",
|
|
107
|
-
"ts/no-unsafe-return": "off",
|
|
108
|
-
"ts/member-ordering": ["error"],
|
|
109
|
-
"ts/no-extra-non-null-assertion": "error",
|
|
110
|
-
"ts/no-non-null-assertion": "error",
|
|
111
|
-
"ts/no-explicit-any": ["error", {
|
|
112
|
-
fixToUnknown: true,
|
|
113
|
-
ignoreRestArgs: true
|
|
114
|
-
}],
|
|
115
|
-
"ts/no-namespace": "error",
|
|
116
|
-
"ts/no-unused-vars": ["error", {
|
|
117
|
-
vars: "all",
|
|
118
|
-
args: "after-used",
|
|
119
|
-
ignoreRestSiblings: false
|
|
120
|
-
}]
|
|
121
|
-
} };
|
|
122
|
-
const defaultFormatterConfig = {
|
|
123
|
-
css: "prettier",
|
|
124
|
-
html: "prettier",
|
|
125
|
-
prettierOptions: {
|
|
126
|
-
printWidth: 160,
|
|
127
|
-
tabWidth: 2,
|
|
128
|
-
arrowParens: "always",
|
|
129
|
-
vueIndentScriptAndStyle: true,
|
|
130
|
-
useTabs: false,
|
|
131
|
-
singleQuote: true,
|
|
132
|
-
jsxSingleQuote: true,
|
|
133
|
-
trailingComma: "all",
|
|
134
|
-
bracketSpacing: true
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* 严格 ts 模式 的默认配置
|
|
139
|
-
*
|
|
140
|
-
* 这些配置需要 配置 parserOptions 和 tsconfigPath 等
|
|
141
|
-
* @see https://typescript-eslint.io/getting-started/typed-linting
|
|
142
|
-
*/
|
|
143
|
-
const defaultStrictTsConfig = { overrides: {
|
|
144
|
-
"ts/no-unsafe-assignment": "off",
|
|
145
|
-
"ts/no-unsafe-call": "off",
|
|
146
|
-
"ts/no-unsafe-argument": "off",
|
|
147
|
-
"ts/no-unsafe-return": "off",
|
|
148
|
-
"ts/no-floating-promises": "error"
|
|
149
|
-
} };
|
|
150
|
-
const defaultStylisticConfig = {
|
|
151
|
-
jsx: true,
|
|
152
|
-
indent: 2,
|
|
153
|
-
quotes: "single",
|
|
154
|
-
semi: false,
|
|
155
|
-
overrides: {
|
|
156
|
-
"style/no-multiple-empty-lines": ["error", {
|
|
157
|
-
max: 1,
|
|
158
|
-
maxBOF: 0,
|
|
159
|
-
maxEOF: 0
|
|
160
|
-
}],
|
|
161
|
-
"style/brace-style": ["error", "1tbs"],
|
|
162
|
-
"style/arrow-parens": ["error", "always"]
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
const defaultTestConfig = { overrides: {
|
|
166
|
-
"no-console": "off",
|
|
167
|
-
"ts/unbound-method": "off",
|
|
168
|
-
"ts/no-unsafe-argument": "off",
|
|
169
|
-
"ts/no-unsafe-assignment": "off",
|
|
170
|
-
"ts/no-unsafe-member-access": "off",
|
|
171
|
-
"ts/no-unsafe-call": "off",
|
|
172
|
-
"ts/no-unsafe-return": "off"
|
|
173
|
-
} };
|
|
174
|
-
function mergeWithDefaults(value, defaults) {
|
|
175
|
-
if (defaults === false || defaults === null || defaults === void 0) {
|
|
176
|
-
if (value === true) return true;
|
|
177
|
-
if (value === false || value === null) return false;
|
|
178
|
-
return value;
|
|
179
|
-
}
|
|
180
|
-
if (value === void 0) return defaults;
|
|
181
|
-
if (value === false || value === null) return false;
|
|
182
|
-
if (value === true) return defaults;
|
|
183
|
-
if (typeof value === "object" && typeof defaults === "object") return {
|
|
184
|
-
...defaults,
|
|
185
|
-
...value
|
|
186
|
-
};
|
|
187
|
-
return value;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
//#endregion
|
|
191
|
-
exports.defaultFormatterConfig = defaultFormatterConfig;
|
|
192
|
-
exports.defaultJsConfig = defaultJsConfig;
|
|
193
|
-
exports.defaultStrictTsConfig = defaultStrictTsConfig;
|
|
194
|
-
exports.defaultStylisticConfig = defaultStylisticConfig;
|
|
195
|
-
exports.defaultTestConfig = defaultTestConfig;
|
|
196
|
-
exports.defaultTsConfig = defaultTsConfig;
|
|
197
|
-
exports.defaultUnocssConfig = defaultUnocssConfig;
|
|
198
|
-
exports.defaultVueConfig = defaultVueConfig;
|
|
199
|
-
exports.mergeWithDefaults = mergeWithDefaults;
|
|
200
|
-
//# sourceMappingURL=index.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["defaultUnocssConfig: AntFuUnocssConfig","defaultVueConfig: AntFuVueConfig","defaultJsConfig: AntFuJsConfig","defaultTsConfig: AntFuTsConfig","defaultFormatterConfig: AntFuFormatterConfig","defaultStrictTsConfig: AntFuTsConfig","defaultStylisticConfig: AntFuStylisticConfig","defaultTestConfig: AntFuTestConfig","value?: boolean | T | null","defaults?: boolean | T | null"],"sources":["../../src/defaults/index.ts"],"sourcesContent":["import type { AntFuFormatterConfig, AntFuJsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from '../types'\n\nexport const defaultUnocssConfig: AntFuUnocssConfig = {\n attributify: true,\n strict: true,\n}\n\nexport const defaultVueConfig: AntFuVueConfig = {\n vueVersion: 3,\n overrides: {\n 'vue/html-self-closing': ['error', {\n html: {\n void: 'always',\n normal: 'always',\n component: 'always',\n },\n }],\n 'vue/html-comment-content-spacing': ['error', 'always', { exceptions: [] }],\n 'vue/html-comment-indent': ['error', 2],\n 'vue/html-indent': ['error', 2, {\n baseIndent: 0,\n alignAttributesVertically: true,\n }],\n 'vue/define-emits-declaration': ['error', 'type-literal'],\n 'vue/define-props-declaration': ['error', 'type-based'],\n 'vue/define-macros-order': [\n 'error',\n {\n order: [\n 'defineProps',\n 'defineEmits',\n 'defineModel',\n 'defineSlots',\n ],\n defineExposeLast: true,\n },\n ],\n 'vue/block-order': [\n 'error',\n {\n order: ['script', 'template', 'style'],\n },\n ],\n 'vue/attributes-order': [\n 'error',\n {\n order: ['DEFINITION', 'LIST_RENDERING', 'CONDITIONALS', 'RENDER_MODIFIERS', 'GLOBAL', 'UNIQUE', 'TWO_WAY_BINDING', 'OTHER_DIRECTIVES', 'OTHER_ATTR', 'EVENTS', 'CONTENT'],\n },\n ],\n 'vue/v-on-event-hyphenation': [\n 'error',\n 'never',\n {\n autofix: true,\n },\n ],\n 'vue/attribute-hyphenation': [\n 'error',\n 'never',\n {\n ignoreTags: ['i-', 'v-', 'v-bind'],\n },\n ],\n 'vue/prop-name-casing': ['error', 'camelCase'],\n 'vue/component-name-in-template-casing': [\n 'error',\n 'PascalCase',\n {\n ignores: ['router-view', 'router-link', 'scroll-view'],\n registeredComponentsOnly: false,\n },\n ],\n },\n}\n\nexport const defaultJsConfig: AntFuJsConfig = {\n overrides: {\n 'no-inline-comments': 'error',\n 'unicorn/no-useless-spread': 'error',\n\n 'curly': ['error', 'all'],\n 'no-undefined': 'error',\n 'no-cond-assign': ['error', 'always'],\n 'no-constant-condition': 'error',\n 'no-restricted-syntax': 'error',\n 'no-global-assign': 'error',\n 'no-unused-vars': 'error',\n 'no-var': 'error',\n 'prefer-const': [\n 'error',\n {\n destructuring: 'any',\n ignoreReadBeforeAssign: false,\n },\n ],\n },\n}\n\nexport const defaultTsConfig: AntFuTsConfig = {\n overrides: {\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-return': 'off',\n 'ts/member-ordering': ['error'],\n 'ts/no-extra-non-null-assertion': 'error',\n 'ts/no-non-null-assertion': 'error',\n 'ts/no-explicit-any': ['error', {\n fixToUnknown: true,\n ignoreRestArgs: true,\n }],\n 'ts/no-namespace': 'error',\n 'ts/no-unused-vars': [\n 'error',\n {\n vars: 'all',\n args: 'after-used',\n ignoreRestSiblings: false,\n },\n ],\n },\n}\n\nexport const defaultFormatterConfig: AntFuFormatterConfig = {\n css: 'prettier',\n html: 'prettier',\n prettierOptions: {\n printWidth: 160,\n tabWidth: 2,\n arrowParens: 'always',\n vueIndentScriptAndStyle: true,\n useTabs: false,\n singleQuote: true,\n jsxSingleQuote: true,\n trailingComma: 'all',\n bracketSpacing: true,\n },\n}\n\n/**\n * 严格 ts 模式 的默认配置\n *\n * 这些配置需要 配置 parserOptions 和 tsconfigPath 等\n * @see https://typescript-eslint.io/getting-started/typed-linting\n */\nexport const defaultStrictTsConfig: AntFuTsConfig = {\n overrides: {\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-return': 'off',\n 'ts/no-floating-promises': 'error',\n },\n}\n\nexport const defaultStylisticConfig: AntFuStylisticConfig = {\n jsx: true,\n indent: 2,\n quotes: 'single',\n semi: false,\n overrides: {\n 'style/no-multiple-empty-lines': ['error', { max: 1, maxBOF: 0, maxEOF: 0 }],\n 'style/brace-style': ['error', '1tbs'],\n 'style/arrow-parens': ['error', 'always'],\n },\n}\n\nexport const defaultTestConfig: AntFuTestConfig = {\n overrides: {\n 'no-console': 'off',\n 'ts/unbound-method': 'off',\n 'ts/no-unsafe-argument': 'off',\n 'ts/no-unsafe-assignment': 'off',\n 'ts/no-unsafe-member-access': 'off',\n 'ts/no-unsafe-call': 'off',\n 'ts/no-unsafe-return': 'off',\n },\n}\n\n/**\n * 合并配置项,支持以下场景:\n * 1. 布尔值与对象配置的混合\n * 2. 使用 vite 的 mergeConfig 进行对象合并\n * 3. 处理 undefined 和 null 的默认值\n *\n * @example\n * ```ts\n * // 场景1: 布尔值转换为默认对象\n * mergeWithDefaults(true, { foo: 'bar' }) // => { foo: 'bar' }\n *\n * // 场景2: vite配置合并\n * mergeWithDefaults({ plugins: [vue()] }, { plugins: [unocss()] })\n *\n * // 场景3: undefined/null/false 处理\n * mergeWithDefaults(false, true) // => false\n * ```\n */\nexport function mergeWithDefaults<T extends object>(\n value?: boolean | T | null,\n defaults?: T\n): T\nexport function mergeWithDefaults<T extends object>(\n value?: boolean | T | null,\n defaults?: boolean\n): boolean | T\nexport function mergeWithDefaults<T extends object>(\n value?: boolean | T | null,\n defaults?: boolean | T | null,\n): boolean | T {\n // 处理无默认值的情况\n if (defaults === false || defaults === null || defaults === void 0) {\n if (value === true) {\n return true\n }\n if (value === false || value === null) {\n return false\n }\n return value as T\n }\n\n // 处理 value 为 undefined 的情况\n if (value === void 0) {\n return defaults\n }\n\n // 处理 value 为 false/null 的情况\n if (value === false || value === null) {\n return false\n }\n\n // 处理 value 为 true 的情况\n if (value === true) {\n return defaults\n }\n\n // 如果都是对象,使用 vite 的 mergeConfig 进行合并\n if (typeof value === 'object' && typeof defaults === 'object') {\n return {\n ...defaults,\n ...value,\n }\n }\n\n // 其他情况返回 value\n return value\n}\n"],"mappings":"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"}
|
package/dist/index.cjs
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
-
const require_index = require('./defaults/index.cjs');
|
|
3
|
-
const __antfu_eslint_config = require_rolldown_runtime.__toESM(require("@antfu/eslint-config"));
|
|
4
|
-
|
|
5
|
-
//#region src/index.ts
|
|
6
|
-
async function eslint9(options = {}) {
|
|
7
|
-
const { type = "lib", ignores = [], test = true, unocss = false, vue = false, jsx = false, pnpm = false, stylistic = true, javascript = require_index.defaultJsConfig, typescript = require_index.defaultTsConfig, formatters = false } = options;
|
|
8
|
-
const _test = require_index.mergeWithDefaults(test, require_index.defaultTestConfig);
|
|
9
|
-
const _unocss = require_index.mergeWithDefaults(unocss, require_index.defaultUnocssConfig);
|
|
10
|
-
const _vue = require_index.mergeWithDefaults(vue, require_index.defaultVueConfig);
|
|
11
|
-
const _javascript = require_index.mergeWithDefaults(javascript, require_index.defaultJsConfig);
|
|
12
|
-
const _stylistic = require_index.mergeWithDefaults(stylistic, require_index.defaultStylisticConfig);
|
|
13
|
-
const _formatters = require_index.mergeWithDefaults(formatters, require_index.defaultFormatterConfig);
|
|
14
|
-
let _typescript = typescript;
|
|
15
|
-
let _pnpm = pnpm;
|
|
16
|
-
if (type === "app") _pnpm = false;
|
|
17
|
-
if (_typescript !== null && typeof _typescript === "object" && "strictTypescriptEslint" in _typescript && _typescript.strictTypescriptEslint === true) {
|
|
18
|
-
_typescript = require_index.mergeWithDefaults(typescript, require_index.defaultStrictTsConfig);
|
|
19
|
-
if (typeof _typescript === "object" && "tsconfigPath" in _typescript) _typescript.parserOptions = { projectService: true };
|
|
20
|
-
}
|
|
21
|
-
return (0, __antfu_eslint_config.antfu)({
|
|
22
|
-
type,
|
|
23
|
-
ignores,
|
|
24
|
-
pnpm: _pnpm,
|
|
25
|
-
test: _test,
|
|
26
|
-
unocss: _unocss,
|
|
27
|
-
vue: _vue,
|
|
28
|
-
jsx,
|
|
29
|
-
typescript: _typescript,
|
|
30
|
-
javascript: _javascript,
|
|
31
|
-
stylistic: _stylistic,
|
|
32
|
-
formatters: _formatters
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
//#endregion
|
|
37
|
-
module.exports = eslint9;
|
|
38
|
-
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["options: ConfigOptions","defaultJsConfig","defaultTsConfig","mergeWithDefaults","defaultTestConfig","defaultUnocssConfig","defaultVueConfig","defaultStylisticConfig","defaultFormatterConfig","defaultStrictTsConfig"],"sources":["../src/index.ts"],"sourcesContent":["import type { OptionsTypeScriptParserOptions } from '@antfu/eslint-config'\nimport type { AntFuFormatterConfig, AntFuJsConfig, AntFuStrictTsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from './types'\nimport { antfu } from '@antfu/eslint-config'\nimport { defaultFormatterConfig, defaultJsConfig, defaultStrictTsConfig, defaultStylisticConfig, defaultTestConfig, defaultTsConfig, defaultUnocssConfig, defaultVueConfig, mergeWithDefaults } from './defaults'\n\ninterface ConfigOptions {\n type?: 'app' | 'lib'\n pnpm?: boolean\n test?: boolean | AntFuTestConfig\n ignores?: string[]\n jsx?: boolean\n vue?: boolean | AntFuVueConfig\n formatters?: boolean | AntFuFormatterConfig\n javascript?: AntFuJsConfig\n typescript?: boolean | AntFuStrictTsConfig | AntFuTsConfig\n unocss?: boolean | AntFuUnocssConfig\n stylistic?: boolean | AntFuStylisticConfig\n}\n\nexport default async function eslint9(options: ConfigOptions = {}): Promise<ReturnType<typeof antfu>> {\n const {\n type = 'lib',\n ignores = [],\n test = true,\n unocss = false,\n vue = false,\n jsx = false,\n pnpm = false,\n stylistic = true,\n javascript = defaultJsConfig,\n typescript = defaultTsConfig,\n formatters = false,\n } = options\n\n const _test = mergeWithDefaults(test, defaultTestConfig)\n const _unocss = mergeWithDefaults(unocss, defaultUnocssConfig)\n const _vue = mergeWithDefaults(vue, defaultVueConfig)\n const _javascript = mergeWithDefaults(javascript, defaultJsConfig)\n const _stylistic = mergeWithDefaults(stylistic, defaultStylisticConfig)\n const _formatters = mergeWithDefaults(formatters, defaultFormatterConfig)\n let _typescript = typescript\n\n // 如果 type 为 'app',强制 pnpm 为 false\n let _pnpm = pnpm\n if (type === 'app') {\n _pnpm = false\n }\n\n // 严格 ts 模式\n if (\n _typescript !== null\n && typeof _typescript === 'object'\n && 'strictTypescriptEslint' in _typescript\n && _typescript.strictTypescriptEslint === true\n ) {\n _typescript = mergeWithDefaults(typescript, defaultStrictTsConfig)\n if (typeof _typescript === 'object' && 'tsconfigPath' in _typescript) {\n (_typescript as OptionsTypeScriptParserOptions).parserOptions = {\n projectService: true,\n }\n }\n }\n\n return antfu({\n type,\n ignores,\n pnpm: _pnpm,\n test: _test,\n unocss: _unocss,\n vue: _vue,\n jsx,\n typescript: _typescript,\n javascript: _javascript,\n stylistic: _stylistic,\n formatters: _formatters,\n })\n}\n"],"mappings":";;;;;AAmBA,eAA8B,QAAQA,UAAyB,CAAE,GAAqC;CACpG,MAAM,EACJ,OAAO,OACP,UAAU,CAAE,GACZ,OAAO,MACP,SAAS,OACT,MAAM,OACN,MAAM,OACN,OAAO,OACP,YAAY,MACZ,aAAaC,+BACb,aAAaC,+BACb,aAAa,OACd,GAAG;CAEJ,MAAM,QAAQC,gCAAkB,MAAMC,gCAAkB;CACxD,MAAM,UAAUD,gCAAkB,QAAQE,kCAAoB;CAC9D,MAAM,OAAOF,gCAAkB,KAAKG,+BAAiB;CACrD,MAAM,cAAcH,gCAAkB,YAAYF,8BAAgB;CAClE,MAAM,aAAaE,gCAAkB,WAAWI,qCAAuB;CACvE,MAAM,cAAcJ,gCAAkB,YAAYK,qCAAuB;CACzE,IAAI,cAAc;CAGlB,IAAI,QAAQ;AACZ,KAAI,SAAS,OACX,QAAQ;AAIV,KACE,gBAAgB,QACb,OAAO,gBAAgB,YACvB,4BAA4B,eAC5B,YAAY,2BAA2B,MAC1C;EACA,cAAcL,gCAAkB,YAAYM,oCAAsB;AAClE,MAAI,OAAO,gBAAgB,YAAY,kBAAkB,aACtD,YAA+C,gBAAgB,EAC9D,gBAAgB,KACjB;CAEJ;AAED,yCAAa;EACX;EACA;EACA,MAAM;EACN,MAAM;EACN,QAAQ;EACR,KAAK;EACL;EACA,YAAY;EACZ,YAAY;EACZ,WAAW;EACX,YAAY;CACb,EAAC;AACH"}
|
package/dist/index.d.cts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { AntFuFormatterConfig, AntFuJsConfig, AntFuStrictTsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from "./types/index.cjs";
|
|
2
|
-
import { antfu } from "@antfu/eslint-config";
|
|
3
|
-
|
|
4
|
-
//#region src/index.d.ts
|
|
5
|
-
interface ConfigOptions {
|
|
6
|
-
type?: "app" | "lib";
|
|
7
|
-
pnpm?: boolean;
|
|
8
|
-
test?: boolean | AntFuTestConfig;
|
|
9
|
-
ignores?: string[];
|
|
10
|
-
jsx?: boolean;
|
|
11
|
-
vue?: boolean | AntFuVueConfig;
|
|
12
|
-
formatters?: boolean | AntFuFormatterConfig;
|
|
13
|
-
javascript?: AntFuJsConfig;
|
|
14
|
-
typescript?: boolean | AntFuStrictTsConfig | AntFuTsConfig;
|
|
15
|
-
unocss?: boolean | AntFuUnocssConfig;
|
|
16
|
-
stylistic?: boolean | AntFuStylisticConfig;
|
|
17
|
-
}
|
|
18
|
-
declare function eslint9(options?: ConfigOptions): Promise<ReturnType<typeof antfu>>;
|
|
19
|
-
//#endregion
|
|
20
|
-
export { eslint9 as default };
|
|
21
|
-
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":["options: ConfigOptions"],"sources":["../src/index.ts"],"sourcesContent":[],"mappings":";;;;UAKU,aAAA;;EAHkC,IAGlC,CAAA,EAAA,OAAA;EAAA,IAAA,CAAA,EAAA,OAAA,GAGS,eAHT;EAAA,OAGS,CAAA,EAAA,MAAA,EAAA;EAAA,GAAA,CAAA,EAGD,OAAA;EAAA,GAAA,CAAA,EACO,OAAA,GADP,cACO;EAAA,UACV,CAAA,EAAA,OAAA,GADU,oBACV;EAAA,UACU,CAAA,EADV,aACU;EAAA,UAAsB,CAAA,EAAA,OAAA,GAAtB,mBAAsB,GAAA,aAAA;EAAA,MAC1B,CAAA,EAAA,OAAA,GAAA,iBAAA;EAAA,SACG,CAAA,EAAA,OAAA,GAAA,oBAAA;AAAA;AAGM,iBAAA,OAAA,CAAA,OAAA,CAAA,EAAiB,aAAjB,CAAA,EAAsC,OAAtC,CAA8C,UAA9C,CAAA,OAAgE,KAAhE,CAAA,CAAA"}
|
package/dist/types/index.d.cts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import antfu$1 from "@antfu/eslint-config";
|
|
2
|
-
|
|
3
|
-
//#region src/types/index.d.ts
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* AntFu Config
|
|
7
|
-
*/
|
|
8
|
-
type AntFuConfig = NonNullable<Parameters<typeof antfu$1>[0]>;
|
|
9
|
-
/**
|
|
10
|
-
* typescript config options
|
|
11
|
-
*/
|
|
12
|
-
type AntFuTsConfig = Exclude<AntFuConfig["typescript"], boolean | undefined>;
|
|
13
|
-
/**
|
|
14
|
-
* javascript config options
|
|
15
|
-
*/
|
|
16
|
-
type AntFuJsConfig = Exclude<AntFuConfig["javascript"], boolean | undefined>;
|
|
17
|
-
/**
|
|
18
|
-
* vue config options
|
|
19
|
-
*/
|
|
20
|
-
type AntFuVueConfig = Exclude<AntFuConfig["vue"], boolean | undefined>;
|
|
21
|
-
/**
|
|
22
|
-
* unocss config options
|
|
23
|
-
*/
|
|
24
|
-
type AntFuUnocssConfig = Exclude<AntFuConfig["unocss"], boolean | undefined>;
|
|
25
|
-
/**
|
|
26
|
-
* stylistic config options
|
|
27
|
-
*/
|
|
28
|
-
type AntFuStylisticConfig = Exclude<AntFuConfig["stylistic"], boolean | undefined>;
|
|
29
|
-
/**
|
|
30
|
-
* formatter config options
|
|
31
|
-
*/
|
|
32
|
-
type AntFuFormatterConfig = Exclude<AntFuConfig["formatters"], boolean | undefined>;
|
|
33
|
-
/**
|
|
34
|
-
* test config options
|
|
35
|
-
*/
|
|
36
|
-
type AntFuTestConfig = Exclude<AntFuConfig["test"], boolean | undefined>;
|
|
37
|
-
/**
|
|
38
|
-
* 严格的 typescript config
|
|
39
|
-
*/
|
|
40
|
-
type AntFuStrictTsConfig = AntFuTsConfig & {
|
|
41
|
-
strictTypescriptEslint: true;
|
|
42
|
-
tsconfigPath: string;
|
|
43
|
-
};
|
|
44
|
-
//#endregion
|
|
45
|
-
export { AntFuFormatterConfig, AntFuJsConfig, AntFuStrictTsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig };
|
|
46
|
-
//# sourceMappingURL=index.d.cts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;AAKA;AAAY,KAAA,WAAA,GAAc,WAAd,CAA0B,UAA1B,CAAA,OAA4C,OAA5C,CAAA,CAAA,CAAA,CAAA,CAAA;;;;AAAc,KAKd,aAAA,GAAgB,OALF,CAKU,WALV,CAAA,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;AAK1B;;;AAA4B,KAKhB,aAAA,GAAgB,OALA,CAKQ,WALR,CAAA,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;AAAA;AAK5B;;AAAoC,KAKxB,cAAA,GAAiB,OALO,CAKC,WALD,CAAA,KAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;;AAAR;AAK5B;AAAY,KAKA,iBAAA,GAAoB,OALpB,CAK4B,WAL5B,CAAA,QAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;;;AAAiB;AAKjB,KAKA,oBAAA,GAAuB,OALvB,CAK+B,WAL/B,CAAA,WAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;;;;AAAoB,KAUpB,oBAAA,GAAuB,OAVH,CAUW,WAVX,CAAA,YAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;AAKhC;;;AAAmC,KAUvB,eAAA,GAAkB,OAVK,CAUG,WAVH,CAAA,MAAA,CAAA,EAAA,OAAA,GAAA,SAAA,CAAA;AAAA;AAKnC;;AAA2C,KAS/B,mBAAA,GAAsB,aATS,GAAA;EAAA,sBAAR,EAAA,IAAA;EAAA,YAAA,EAAA,MAAA;AAKnC,CAAA"}
|