@truenine/eslint9-config 1.0.14 → 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 CHANGED
@@ -1,144 +1,241 @@
1
- # @truenine/eslint9-config
1
+ # ESLint 9 配置包
2
2
 
3
- ESLint 9 configuration package for Compose Client projects with TypeScript, Vue, and modern JavaScript support.
3
+ 这是一个针对 Compose Client 项目优化的 ESLint 9 配置包,提供了缓存优化、性能调优和规则优化功能。
4
4
 
5
- ## Features
5
+ ## 功能特性
6
6
 
7
- - 🚀 **ESLint 9** - Latest ESLint version with flat config
8
- - 🎯 **TypeScript** - Full TypeScript support with strict rules
9
- - 🖖 **Vue 3** - Vue.js 3 specific linting rules
10
- - 🎨 **Stylistic** - Code formatting and style consistency
11
- - 🧪 **Testing** - Vitest and testing library support
12
- - 🎭 **UnoCSS** - Atomic CSS framework integration
13
- - ⚡ **Performance** - Optimized for fast linting
7
+ ### 🚀 性能优化
8
+ - **智能缓存**: 支持 metadata content 两种缓存策略
9
+ - **并行处理**: 自动利用多核 CPU 进行并行检查
10
+ - **规则优化**: 可选择跳过性能影响大的规则
11
+ - **渐进式检查**: 优先检查关键文件
14
12
 
15
- ## Installation
13
+ ### 📋 预设配置
14
+ - **performance**: 性能优先,适用于大型项目或 CI 环境
15
+ - **quality**: 质量优先,适用于小型项目或开发环境
16
+ - **balanced**: 平衡配置,默认推荐
17
+ - **ci**: CI 环境专用配置
18
+ - **dev**: 开发环境友好配置
19
+ - **library**: 库项目严格配置
16
20
 
17
- ```bash
18
- # Using pnpm (recommended)
19
- pnpm add -D @truenine/eslint9-config
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
- ## Usage
26
+ ## 使用方法
29
27
 
30
- Create an `eslint.config.mjs` file in your project root:
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
- vue: true,
40
- typescript: true,
41
- test: true,
42
- unocss: false,
43
- stylistic: true,
44
- formatters: false
36
+ typescript: {
37
+ strictTypescriptEslint: true,
38
+ tsconfigPath: './tsconfig.json',
39
+ },
45
40
  })
46
41
  ```
47
42
 
48
- ### Configuration Options
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
- import eslint9 from '@truenine/eslint9-config'
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: true,
73
- test: true
51
+ typescript: {
52
+ strictTypescriptEslint: true,
53
+ tsconfigPath: './tsconfig.json',
54
+ },
55
+ // 使用平衡预设
56
+ ...applyPreset('balanced'),
74
57
  })
75
58
  ```
76
59
 
77
- #### Vue Application Configuration
60
+ ### 自定义配置
78
61
 
79
62
  ```javascript
80
- import eslint9 from '@truenine/eslint9-config'
63
+ // eslint.config.mjs
64
+ import eslint9, { applyPreset } from '@truenine/eslint9-config'
81
65
 
82
66
  export default eslint9({
83
- type: 'app',
67
+ type: 'lib',
84
68
  vue: true,
85
- typescript: true,
86
- unocss: true,
87
- formatters: true
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
- #### Strict TypeScript Configuration
95
+ ## 配置选项
92
96
 
93
- ```javascript
94
- import eslint9 from '@truenine/eslint9-config'
97
+ ### 缓存配置 (cache)
95
98
 
96
- export default eslint9({
97
- typescript: {
98
- strictTypescriptEslint: true,
99
- tsconfigPath: './tsconfig.json'
100
- }
101
- })
99
+ ```typescript
100
+ cache?: boolean | {
101
+ /** 缓存位置,默认为 .eslintcache */
102
+ location?: string
103
+ /** 缓存策略,默认为 metadata */
104
+ strategy?: 'metadata' | 'content'
105
+ }
102
106
  ```
103
107
 
104
- ## Package Scripts
108
+ ### 性能配置 (performance)
105
109
 
106
- Add these scripts to your `package.json`:
110
+ ```typescript
111
+ performance?: {
112
+ /** 启用并行处理,默认为 true */
113
+ parallel?: boolean
114
+ /** 最大并行数,默认为 CPU 核心数 */
115
+ maxParallel?: number
116
+ /** 忽略性能影响大的规则 */
117
+ skipExpensiveRules?: boolean
118
+ }
119
+ ```
107
120
 
108
- ```json
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
- ## IDE Integration
186
+ ### 2. 使用合适的预设
187
+ - 开发环境使用 `dev` 预设
188
+ - CI 环境使用 `ci` 预设
189
+ - 生产库使用 `library` 预设
118
190
 
119
- ### VS Code
120
-
121
- Install the [ESLint extension](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) and add to your `.vscode/settings.json`:
191
+ ### 3. 配置忽略模式
192
+ 确保 `.eslintignore` 或配置中包含不需要检查的文件:
193
+ ```
194
+ dist/
195
+ build/
196
+ coverage/
197
+ .turbo/
198
+ node_modules/
199
+ *.min.js
200
+ ```
122
201
 
123
- ```json
124
- {
125
- "eslint.experimental.useFlatConfig": true,
126
- "eslint.validate": [
127
- "javascript",
128
- "javascriptreact",
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
- ## Contributing
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
- Contributions are welcome! Please read our [contributing guidelines](../../README.md) for details.
225
+ ### 规则冲突
226
+ 如果遇到规则冲突,可以通过 `customOverrides` 覆盖:
227
+ ```javascript
228
+ ruleOptimization: {
229
+ customOverrides: {
230
+ 'conflicting-rule': 'off',
231
+ },
232
+ }
233
+ ```
139
234
 
140
- ## Support
235
+ ## 更新日志
141
236
 
142
- - 🐛 [Report Issues](https://github.com/TrueNine/compose-client/issues)
143
- - 💬 [Discussions](https://github.com/TrueNine/compose-client/discussions)
144
- - 📖 [Documentation](https://github.com/TrueNine/compose-client#readme)
237
+ ### v1.0.0
238
+ - 初始版本
239
+ - 支持缓存优化
240
+ - 提供预设配置
241
+ - 集成规则优化器
@@ -1,35 +1,40 @@
1
- import { AntFuFormatterConfig, AntFuJsConfig, AntFuStylisticConfig, AntFuTestConfig, AntFuTsConfig, AntFuUnocssConfig, AntFuVueConfig } from '../types';
2
- export declare const defaultUnocssConfig: AntFuUnocssConfig;
3
- export declare const defaultVueConfig: AntFuVueConfig;
4
- export declare const defaultJsConfig: AntFuJsConfig;
5
- export declare const defaultTsConfig: AntFuTsConfig;
6
- export declare const defaultFormatterConfig: AntFuFormatterConfig;
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;
7
9
  /**
8
- * 严格 ts 模式 的默认配置
9
- *
10
- * 这些配置需要 配置 parserOptions 和 tsconfigPath 等
11
- * @see https://typescript-eslint.io/getting-started/typed-linting
12
- */
13
- export declare const defaultStrictTsConfig: AntFuTsConfig;
14
- export declare const defaultStylisticConfig: AntFuStylisticConfig;
15
- export declare const defaultTestConfig: AntFuTestConfig;
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;
16
18
  /**
17
- * 合并配置项,支持以下场景:
18
- * 1. 布尔值与对象配置的混合
19
- * 2. 使用 vite 的 mergeConfig 进行对象合并
20
- * 3. 处理 undefined 和 null 的默认值
21
- *
22
- * @example
23
- * ```ts
24
- * // 场景1: 布尔值转换为默认对象
25
- * mergeWithDefaults(true, { foo: 'bar' }) // => { foo: 'bar' }
26
- *
27
- * // 场景2: vite配置合并
28
- * mergeWithDefaults({ plugins: [vue()] }, { plugins: [unocss()] })
29
- *
30
- * // 场景3: undefined/null/false 处理
31
- * mergeWithDefaults(false, true) // => false
32
- * ```
33
- */
34
- export declare function mergeWithDefaults<T extends object>(value?: boolean | T | null, defaults?: T): T;
35
- export declare function mergeWithDefaults<T extends object>(value?: boolean | T | null, defaults?: boolean): boolean | T;
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"}