@longzai-intelligence-oxlint/utils 0.0.36 → 0.0.37

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/dist/index.d.cts CHANGED
@@ -2,22 +2,51 @@ import { Context } from "@oxlint/plugins";
2
2
  import * as z from "zod/mini";
3
3
 
4
4
  //#region src/types/rule.types.d.ts
5
+ /**
6
+ * Oxlint 规则上下文类型
7
+ */
5
8
  type OxlintContext = Context;
9
+ /**
10
+ * 规则状态类型
11
+ *
12
+ * 用于在规则执行过程中跟踪状态
13
+ */
6
14
  type RuleState = {
15
+ /**
16
+ * 是否有有效的导入
17
+ */
7
18
  hasValidImport: boolean;
19
+ /**
20
+ * 是否有禁止的导入
21
+ */
8
22
  hasForbiddenImport: boolean;
23
+ /**
24
+ * 是否有默认导出
25
+ */
9
26
  hasExportDefault: boolean;
27
+ /**
28
+ * 禁止导入的节点
29
+ */
10
30
  forbiddenImportNode: unknown | null;
31
+ /**
32
+ * 禁止导入的名称
33
+ */
11
34
  forbiddenImportName: string;
12
35
  };
13
36
  //#endregion
14
37
  //#region src/schemas/ast.schemas.d.ts
38
+ /**
39
+ * 带有标识符的节点 schema
40
+ */
15
41
  declare const NodeWithIdentifierSchema: z.ZodMiniObject<{
16
42
  id: z.ZodMiniObject<{
17
43
  name: z.ZodMiniString<string>;
18
44
  }, z.core.$strip>;
19
45
  type: z.ZodMiniString<string>;
20
46
  }, z.core.$strip>;
47
+ /**
48
+ * 带有标识符和范围的节点 schema
49
+ */
21
50
  declare const NodeWithIdentifierAndRangeSchema: z.ZodMiniObject<{
22
51
  id: z.ZodMiniObject<{
23
52
  name: z.ZodMiniString<string>;
@@ -25,6 +54,9 @@ declare const NodeWithIdentifierAndRangeSchema: z.ZodMiniObject<{
25
54
  }, z.core.$strip>;
26
55
  type: z.ZodMiniString<string>;
27
56
  }, z.core.$strip>;
57
+ /**
58
+ * Import 说明符 schema
59
+ */
28
60
  declare const ImportSpecifierSchema: z.ZodMiniObject<{
29
61
  type: z.ZodMiniEnum<{
30
62
  ImportSpecifier: "ImportSpecifier";
@@ -38,6 +70,9 @@ declare const ImportSpecifierSchema: z.ZodMiniObject<{
38
70
  name: z.ZodMiniString<string>;
39
71
  }, z.core.$strip>;
40
72
  }, z.core.$strip>;
73
+ /**
74
+ * Import 声明 schema
75
+ */
41
76
  declare const ImportDeclarationSchema: z.ZodMiniObject<{
42
77
  type: z.ZodMiniLiteral<"ImportDeclaration">;
43
78
  source: z.ZodMiniObject<{
@@ -57,6 +92,9 @@ declare const ImportDeclarationSchema: z.ZodMiniObject<{
57
92
  }, z.core.$strip>;
58
93
  }, z.core.$strip>>;
59
94
  }, z.core.$strip>;
95
+ /**
96
+ * Export Default 声明 schema
97
+ */
60
98
  declare const ExportDefaultDeclarationSchema: z.ZodMiniObject<{
61
99
  type: z.ZodMiniLiteral<"ExportDefaultDeclaration">;
62
100
  declaration: z.ZodMiniObject<{
@@ -68,66 +106,255 @@ declare const ExportDefaultDeclarationSchema: z.ZodMiniObject<{
68
106
  properties: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
69
107
  }, z.core.$strip>;
70
108
  }, z.core.$strip>;
109
+ /**
110
+ * CallExpression 节点 schema
111
+ */
71
112
  declare const CallExpressionSchema: z.ZodMiniObject<{
72
113
  type: z.ZodMiniLiteral<"CallExpression">;
73
114
  callee: z.ZodMiniObject<{
74
115
  name: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniUndefined]>;
75
116
  }, z.core.$strip>;
76
117
  }, z.core.$strip>;
118
+ /**
119
+ * ObjectExpression 节点 schema
120
+ */
77
121
  declare const ObjectExpressionSchema: z.ZodMiniObject<{
78
122
  type: z.ZodMiniLiteral<"ObjectExpression">;
79
123
  }, z.core.$strip>;
124
+ /**
125
+ * 从 schema 推导的类型
126
+ */
80
127
  type NodeWithIdentifier = z.infer<typeof NodeWithIdentifierSchema>;
128
+ /**
129
+ * 带有标识符和范围的 AST 节点类型
130
+ */
81
131
  type NodeWithIdentifierAndRange = z.infer<typeof NodeWithIdentifierAndRangeSchema>;
132
+ /**
133
+ * Import 说明符节点类型
134
+ */
82
135
  type ImportSpecifierNode = z.infer<typeof ImportSpecifierSchema>;
136
+ /**
137
+ * Import 声明节点类型
138
+ */
83
139
  type ImportDeclarationNode = z.infer<typeof ImportDeclarationSchema>;
140
+ /**
141
+ * Export Default 声明节点类型
142
+ */
84
143
  type ExportDefaultDeclarationNode = z.infer<typeof ExportDefaultDeclarationSchema>;
144
+ /**
145
+ * CallExpression 节点类型
146
+ */
85
147
  type CallExpressionNode = z.infer<typeof CallExpressionSchema>;
148
+ /**
149
+ * ObjectExpression 节点类型
150
+ */
86
151
  type ObjectExpressionNode = z.infer<typeof ObjectExpressionSchema>;
87
152
  //#endregion
88
153
  //#region src/schemas/plugin.schemas.d.ts
154
+ /**
155
+ * 插件元信息 schema
156
+ */
89
157
  declare const PluginMetaSchema: z.ZodMiniObject<{
90
158
  name: z.ZodMiniString<string>;
91
159
  }, z.core.$strip>;
160
+ /**
161
+ * 插件 schema
162
+ */
92
163
  declare const PluginSchema: z.ZodMiniObject<{
93
164
  meta: z.ZodMiniObject<{
94
165
  name: z.ZodMiniString<string>;
95
166
  }, z.core.$strip>;
96
167
  }, z.core.$strip>;
168
+ /**
169
+ * 从 schema 推导的类型
170
+ */
97
171
  type PluginMeta = z.infer<typeof PluginMetaSchema>;
172
+ /**
173
+ * 插件配置类型
174
+ */
98
175
  type Plugin = z.infer<typeof PluginSchema>;
99
176
  //#endregion
100
177
  //#region src/utils/import.utils.d.ts
178
+ /**
179
+ * 检查节点是否为 ImportDeclaration
180
+ *
181
+ * @param node - AST 节点
182
+ * @returns 是否为 ImportDeclaration
183
+ */
101
184
  declare function isImportDeclaration(node: unknown): node is ImportDeclarationNode;
185
+ /**
186
+ * 检查说明符是否为 ImportSpecifier
187
+ *
188
+ * @param specifier - Import 说明符
189
+ * @returns 是否为 ImportSpecifier
190
+ */
102
191
  declare function isImportSpecifier(specifier: unknown): specifier is ImportSpecifierNode;
192
+ /**
193
+ * 检查是否为默认导入
194
+ *
195
+ * @param specifier - Import 说明符
196
+ * @returns 是否为默认导入
197
+ */
103
198
  declare function isDefaultImport(specifier: ImportSpecifierNode): boolean;
199
+ /**
200
+ * 检查是否为命名空间导入
201
+ *
202
+ * @param specifier - Import 说明符
203
+ * @returns 是否为命名空间导入
204
+ */
104
205
  declare function isNamespaceImport(specifier: ImportSpecifierNode): boolean;
206
+ /**
207
+ * 从 ImportDeclaration 中提取所有导入的名称
208
+ *
209
+ * @param node - Import 声明节点
210
+ * @returns 导入的名称列表
211
+ */
105
212
  declare function getImportedNames(node: ImportDeclarationNode): string[];
213
+ /**
214
+ * 检查 ImportDeclaration 是否导入了指定名称
215
+ *
216
+ * @param node - Import 声明节点
217
+ * @param name - 要检查的名称
218
+ * @returns 是否导入了指定名称
219
+ */
106
220
  declare function hasImportedName(node: ImportDeclarationNode, name: string): boolean;
107
221
  //#endregion
108
222
  //#region src/utils/file.utils.d.ts
223
+ /**
224
+ * 检查文件是否为测试文件
225
+ *
226
+ * @param fileName - 文件名
227
+ * @returns 是否为测试文件
228
+ */
109
229
  declare function isTestFile(fileName: string): boolean;
230
+ /**
231
+ * 检查文件是否匹配指定后缀
232
+ *
233
+ * @param fileName - 文件名
234
+ * @param suffix - 文件后缀
235
+ * @returns 是否匹配
236
+ */
110
237
  declare function hasFileSuffix(fileName: string, suffix: string): boolean;
238
+ /**
239
+ * 检查文件是否匹配任意后缀
240
+ *
241
+ * @param fileName - 文件名
242
+ * @param suffixes - 文件后缀列表
243
+ * @returns 是否匹配任意后缀
244
+ */
111
245
  declare function hasAnyFileSuffix(fileName: string, suffixes: string[]): boolean;
246
+ /**
247
+ * 获取文件名(不含路径)
248
+ *
249
+ * @param filePath - 文件路径
250
+ * @returns 文件名
251
+ */
112
252
  declare function getFileName(filePath: string): string;
253
+ /**
254
+ * 检查文件是否在排除路径中
255
+ *
256
+ * @param filePath - 文件路径
257
+ * @param excludedPaths - 排除路径列表
258
+ * @returns 是否在排除路径中
259
+ */
113
260
  declare function isInExcludedPath(filePath: string, excludedPaths: string[]): boolean;
114
261
  //#endregion
115
262
  //#region src/utils/naming.utils.d.ts
263
+ /**
264
+ * 命名工具函数
265
+ *
266
+ * 提供命名检查和转换的工具函数
267
+ */
268
+ /**
269
+ * 检查名称是否使用 I 前缀(匈牙利命名法)
270
+ *
271
+ * @param name - 要检查的名称
272
+ * @returns 是否使用 I 前缀
273
+ */
116
274
  declare function hasIPrefix(name: string): boolean;
275
+ /**
276
+ * 检查名称是否符合 DTO 命名规范(DTO 全大写)
277
+ *
278
+ * @param name - 要检查的名称
279
+ * @returns 是否符合 DTO 命名规范
280
+ */
117
281
  declare function isValidDtoNameUpperCase(name: string): boolean;
282
+ /**
283
+ * 检查名称是否符合 DTO 命名规范(Dto 驼峰式)
284
+ *
285
+ * @param name - 要检查的名称
286
+ * @returns 是否符合 DTO 命名规范
287
+ */
118
288
  declare function isValidDtoNameCamelCase(name: string): boolean;
289
+ /**
290
+ * 移除 I 前缀
291
+ *
292
+ * @param name - 原始名称
293
+ * @returns 移除 I 前缀后的名称
294
+ */
119
295
  declare function removeIPrefix(name: string): string;
296
+ /**
297
+ * 将 DTO 后缀转换为驼峰式
298
+ *
299
+ * @param name - 原始名称
300
+ * @returns 转换后的名称
301
+ */
120
302
  declare function toDtoCamelCase(name: string): string;
303
+ /**
304
+ * 将 DTO 后缀转换为大写
305
+ *
306
+ * @param name - 原始名称
307
+ * @returns 转换后的名称
308
+ */
121
309
  declare function toDtoUpperCase(name: string): string;
122
310
  //#endregion
123
311
  //#region src/guards/ast.guards.d.ts
312
+ /**
313
+ * 检查节点是否有 id 属性且 id 有 name 属性
314
+ *
315
+ * @param node - AST 节点
316
+ * @returns 如果有则返回 true
317
+ */
124
318
  declare function hasIdWithName(node: unknown): node is NodeWithIdentifier;
319
+ /**
320
+ * 检查节点是否有 id 属性且 id 有 name 和 range 属性
321
+ *
322
+ * @param node - AST 节点
323
+ * @returns 如果有则返回 true
324
+ */
125
325
  declare function hasIdWithNameAndRange(node: unknown): node is NodeWithIdentifierAndRange;
326
+ /**
327
+ * 检查节点是否为 CallExpression
328
+ *
329
+ * @param obj - 待检查的对象
330
+ * @returns 是否为 CallExpression
331
+ */
126
332
  declare function isCallExpressionNode(obj: unknown): obj is CallExpressionNode;
333
+ /**
334
+ * 检查节点是否为 ObjectExpression
335
+ *
336
+ * @param obj - 待检查的对象
337
+ * @returns 是否为 ObjectExpression
338
+ */
127
339
  declare function isObjectExpressionNode(obj: unknown): obj is ObjectExpressionNode;
128
340
  //#endregion
129
341
  //#region src/guards/plugin.guards.d.ts
342
+ /**
343
+ * 检查对象是否为有效的 Oxlint 插件
344
+ *
345
+ * @param obj - 待检查的对象
346
+ * @returns 是否为有效的 Oxlint 插件
347
+ */
130
348
  declare function isPlugin(obj: unknown): obj is Plugin;
349
+ /**
350
+ * 获取插件名称
351
+ *
352
+ * 如果插件无效则抛出错误,确保返回值一定是 string
353
+ *
354
+ * @param plugin - Oxlint 插件
355
+ * @returns 插件名称
356
+ * @throws {@link Error} 如果插件无效或插件名称未定义
357
+ */
131
358
  declare function getPluginName(plugin: unknown): string;
132
359
  //#endregion
133
360
  export { type CallExpressionNode, CallExpressionSchema, type ExportDefaultDeclarationNode, ExportDefaultDeclarationSchema, type ImportDeclarationNode, ImportDeclarationSchema, type ImportSpecifierNode, ImportSpecifierSchema, type NodeWithIdentifier, type NodeWithIdentifierAndRange, NodeWithIdentifierAndRangeSchema, NodeWithIdentifierSchema, type ObjectExpressionNode, ObjectExpressionSchema, OxlintContext, Plugin, PluginMeta, PluginMetaSchema, PluginSchema, RuleState, getFileName, getImportedNames, getPluginName, hasAnyFileSuffix, hasFileSuffix, hasIPrefix, hasIdWithName, hasIdWithNameAndRange, hasImportedName, isCallExpressionNode, isDefaultImport, isImportDeclaration, isImportSpecifier, isInExcludedPath, isNamespaceImport, isObjectExpressionNode, isPlugin, isTestFile, isValidDtoNameCamelCase, isValidDtoNameUpperCase, removeIPrefix, toDtoCamelCase, toDtoUpperCase };
package/dist/index.d.mts CHANGED
@@ -2,22 +2,51 @@ import * as z from "zod/mini";
2
2
  import { Context } from "@oxlint/plugins";
3
3
 
4
4
  //#region src/types/rule.types.d.ts
5
+ /**
6
+ * Oxlint 规则上下文类型
7
+ */
5
8
  type OxlintContext = Context;
9
+ /**
10
+ * 规则状态类型
11
+ *
12
+ * 用于在规则执行过程中跟踪状态
13
+ */
6
14
  type RuleState = {
15
+ /**
16
+ * 是否有有效的导入
17
+ */
7
18
  hasValidImport: boolean;
19
+ /**
20
+ * 是否有禁止的导入
21
+ */
8
22
  hasForbiddenImport: boolean;
23
+ /**
24
+ * 是否有默认导出
25
+ */
9
26
  hasExportDefault: boolean;
27
+ /**
28
+ * 禁止导入的节点
29
+ */
10
30
  forbiddenImportNode: unknown | null;
31
+ /**
32
+ * 禁止导入的名称
33
+ */
11
34
  forbiddenImportName: string;
12
35
  };
13
36
  //#endregion
14
37
  //#region src/schemas/ast.schemas.d.ts
38
+ /**
39
+ * 带有标识符的节点 schema
40
+ */
15
41
  declare const NodeWithIdentifierSchema: z.ZodMiniObject<{
16
42
  id: z.ZodMiniObject<{
17
43
  name: z.ZodMiniString<string>;
18
44
  }, z.core.$strip>;
19
45
  type: z.ZodMiniString<string>;
20
46
  }, z.core.$strip>;
47
+ /**
48
+ * 带有标识符和范围的节点 schema
49
+ */
21
50
  declare const NodeWithIdentifierAndRangeSchema: z.ZodMiniObject<{
22
51
  id: z.ZodMiniObject<{
23
52
  name: z.ZodMiniString<string>;
@@ -25,6 +54,9 @@ declare const NodeWithIdentifierAndRangeSchema: z.ZodMiniObject<{
25
54
  }, z.core.$strip>;
26
55
  type: z.ZodMiniString<string>;
27
56
  }, z.core.$strip>;
57
+ /**
58
+ * Import 说明符 schema
59
+ */
28
60
  declare const ImportSpecifierSchema: z.ZodMiniObject<{
29
61
  type: z.ZodMiniEnum<{
30
62
  ImportSpecifier: "ImportSpecifier";
@@ -38,6 +70,9 @@ declare const ImportSpecifierSchema: z.ZodMiniObject<{
38
70
  name: z.ZodMiniString<string>;
39
71
  }, z.core.$strip>;
40
72
  }, z.core.$strip>;
73
+ /**
74
+ * Import 声明 schema
75
+ */
41
76
  declare const ImportDeclarationSchema: z.ZodMiniObject<{
42
77
  type: z.ZodMiniLiteral<"ImportDeclaration">;
43
78
  source: z.ZodMiniObject<{
@@ -57,6 +92,9 @@ declare const ImportDeclarationSchema: z.ZodMiniObject<{
57
92
  }, z.core.$strip>;
58
93
  }, z.core.$strip>>;
59
94
  }, z.core.$strip>;
95
+ /**
96
+ * Export Default 声明 schema
97
+ */
60
98
  declare const ExportDefaultDeclarationSchema: z.ZodMiniObject<{
61
99
  type: z.ZodMiniLiteral<"ExportDefaultDeclaration">;
62
100
  declaration: z.ZodMiniObject<{
@@ -68,66 +106,255 @@ declare const ExportDefaultDeclarationSchema: z.ZodMiniObject<{
68
106
  properties: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
69
107
  }, z.core.$strip>;
70
108
  }, z.core.$strip>;
109
+ /**
110
+ * CallExpression 节点 schema
111
+ */
71
112
  declare const CallExpressionSchema: z.ZodMiniObject<{
72
113
  type: z.ZodMiniLiteral<"CallExpression">;
73
114
  callee: z.ZodMiniObject<{
74
115
  name: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniUndefined]>;
75
116
  }, z.core.$strip>;
76
117
  }, z.core.$strip>;
118
+ /**
119
+ * ObjectExpression 节点 schema
120
+ */
77
121
  declare const ObjectExpressionSchema: z.ZodMiniObject<{
78
122
  type: z.ZodMiniLiteral<"ObjectExpression">;
79
123
  }, z.core.$strip>;
124
+ /**
125
+ * 从 schema 推导的类型
126
+ */
80
127
  type NodeWithIdentifier = z.infer<typeof NodeWithIdentifierSchema>;
128
+ /**
129
+ * 带有标识符和范围的 AST 节点类型
130
+ */
81
131
  type NodeWithIdentifierAndRange = z.infer<typeof NodeWithIdentifierAndRangeSchema>;
132
+ /**
133
+ * Import 说明符节点类型
134
+ */
82
135
  type ImportSpecifierNode = z.infer<typeof ImportSpecifierSchema>;
136
+ /**
137
+ * Import 声明节点类型
138
+ */
83
139
  type ImportDeclarationNode = z.infer<typeof ImportDeclarationSchema>;
140
+ /**
141
+ * Export Default 声明节点类型
142
+ */
84
143
  type ExportDefaultDeclarationNode = z.infer<typeof ExportDefaultDeclarationSchema>;
144
+ /**
145
+ * CallExpression 节点类型
146
+ */
85
147
  type CallExpressionNode = z.infer<typeof CallExpressionSchema>;
148
+ /**
149
+ * ObjectExpression 节点类型
150
+ */
86
151
  type ObjectExpressionNode = z.infer<typeof ObjectExpressionSchema>;
87
152
  //#endregion
88
153
  //#region src/schemas/plugin.schemas.d.ts
154
+ /**
155
+ * 插件元信息 schema
156
+ */
89
157
  declare const PluginMetaSchema: z.ZodMiniObject<{
90
158
  name: z.ZodMiniString<string>;
91
159
  }, z.core.$strip>;
160
+ /**
161
+ * 插件 schema
162
+ */
92
163
  declare const PluginSchema: z.ZodMiniObject<{
93
164
  meta: z.ZodMiniObject<{
94
165
  name: z.ZodMiniString<string>;
95
166
  }, z.core.$strip>;
96
167
  }, z.core.$strip>;
168
+ /**
169
+ * 从 schema 推导的类型
170
+ */
97
171
  type PluginMeta = z.infer<typeof PluginMetaSchema>;
172
+ /**
173
+ * 插件配置类型
174
+ */
98
175
  type Plugin = z.infer<typeof PluginSchema>;
99
176
  //#endregion
100
177
  //#region src/utils/import.utils.d.ts
178
+ /**
179
+ * 检查节点是否为 ImportDeclaration
180
+ *
181
+ * @param node - AST 节点
182
+ * @returns 是否为 ImportDeclaration
183
+ */
101
184
  declare function isImportDeclaration(node: unknown): node is ImportDeclarationNode;
185
+ /**
186
+ * 检查说明符是否为 ImportSpecifier
187
+ *
188
+ * @param specifier - Import 说明符
189
+ * @returns 是否为 ImportSpecifier
190
+ */
102
191
  declare function isImportSpecifier(specifier: unknown): specifier is ImportSpecifierNode;
192
+ /**
193
+ * 检查是否为默认导入
194
+ *
195
+ * @param specifier - Import 说明符
196
+ * @returns 是否为默认导入
197
+ */
103
198
  declare function isDefaultImport(specifier: ImportSpecifierNode): boolean;
199
+ /**
200
+ * 检查是否为命名空间导入
201
+ *
202
+ * @param specifier - Import 说明符
203
+ * @returns 是否为命名空间导入
204
+ */
104
205
  declare function isNamespaceImport(specifier: ImportSpecifierNode): boolean;
206
+ /**
207
+ * 从 ImportDeclaration 中提取所有导入的名称
208
+ *
209
+ * @param node - Import 声明节点
210
+ * @returns 导入的名称列表
211
+ */
105
212
  declare function getImportedNames(node: ImportDeclarationNode): string[];
213
+ /**
214
+ * 检查 ImportDeclaration 是否导入了指定名称
215
+ *
216
+ * @param node - Import 声明节点
217
+ * @param name - 要检查的名称
218
+ * @returns 是否导入了指定名称
219
+ */
106
220
  declare function hasImportedName(node: ImportDeclarationNode, name: string): boolean;
107
221
  //#endregion
108
222
  //#region src/utils/file.utils.d.ts
223
+ /**
224
+ * 检查文件是否为测试文件
225
+ *
226
+ * @param fileName - 文件名
227
+ * @returns 是否为测试文件
228
+ */
109
229
  declare function isTestFile(fileName: string): boolean;
230
+ /**
231
+ * 检查文件是否匹配指定后缀
232
+ *
233
+ * @param fileName - 文件名
234
+ * @param suffix - 文件后缀
235
+ * @returns 是否匹配
236
+ */
110
237
  declare function hasFileSuffix(fileName: string, suffix: string): boolean;
238
+ /**
239
+ * 检查文件是否匹配任意后缀
240
+ *
241
+ * @param fileName - 文件名
242
+ * @param suffixes - 文件后缀列表
243
+ * @returns 是否匹配任意后缀
244
+ */
111
245
  declare function hasAnyFileSuffix(fileName: string, suffixes: string[]): boolean;
246
+ /**
247
+ * 获取文件名(不含路径)
248
+ *
249
+ * @param filePath - 文件路径
250
+ * @returns 文件名
251
+ */
112
252
  declare function getFileName(filePath: string): string;
253
+ /**
254
+ * 检查文件是否在排除路径中
255
+ *
256
+ * @param filePath - 文件路径
257
+ * @param excludedPaths - 排除路径列表
258
+ * @returns 是否在排除路径中
259
+ */
113
260
  declare function isInExcludedPath(filePath: string, excludedPaths: string[]): boolean;
114
261
  //#endregion
115
262
  //#region src/utils/naming.utils.d.ts
263
+ /**
264
+ * 命名工具函数
265
+ *
266
+ * 提供命名检查和转换的工具函数
267
+ */
268
+ /**
269
+ * 检查名称是否使用 I 前缀(匈牙利命名法)
270
+ *
271
+ * @param name - 要检查的名称
272
+ * @returns 是否使用 I 前缀
273
+ */
116
274
  declare function hasIPrefix(name: string): boolean;
275
+ /**
276
+ * 检查名称是否符合 DTO 命名规范(DTO 全大写)
277
+ *
278
+ * @param name - 要检查的名称
279
+ * @returns 是否符合 DTO 命名规范
280
+ */
117
281
  declare function isValidDtoNameUpperCase(name: string): boolean;
282
+ /**
283
+ * 检查名称是否符合 DTO 命名规范(Dto 驼峰式)
284
+ *
285
+ * @param name - 要检查的名称
286
+ * @returns 是否符合 DTO 命名规范
287
+ */
118
288
  declare function isValidDtoNameCamelCase(name: string): boolean;
289
+ /**
290
+ * 移除 I 前缀
291
+ *
292
+ * @param name - 原始名称
293
+ * @returns 移除 I 前缀后的名称
294
+ */
119
295
  declare function removeIPrefix(name: string): string;
296
+ /**
297
+ * 将 DTO 后缀转换为驼峰式
298
+ *
299
+ * @param name - 原始名称
300
+ * @returns 转换后的名称
301
+ */
120
302
  declare function toDtoCamelCase(name: string): string;
303
+ /**
304
+ * 将 DTO 后缀转换为大写
305
+ *
306
+ * @param name - 原始名称
307
+ * @returns 转换后的名称
308
+ */
121
309
  declare function toDtoUpperCase(name: string): string;
122
310
  //#endregion
123
311
  //#region src/guards/ast.guards.d.ts
312
+ /**
313
+ * 检查节点是否有 id 属性且 id 有 name 属性
314
+ *
315
+ * @param node - AST 节点
316
+ * @returns 如果有则返回 true
317
+ */
124
318
  declare function hasIdWithName(node: unknown): node is NodeWithIdentifier;
319
+ /**
320
+ * 检查节点是否有 id 属性且 id 有 name 和 range 属性
321
+ *
322
+ * @param node - AST 节点
323
+ * @returns 如果有则返回 true
324
+ */
125
325
  declare function hasIdWithNameAndRange(node: unknown): node is NodeWithIdentifierAndRange;
326
+ /**
327
+ * 检查节点是否为 CallExpression
328
+ *
329
+ * @param obj - 待检查的对象
330
+ * @returns 是否为 CallExpression
331
+ */
126
332
  declare function isCallExpressionNode(obj: unknown): obj is CallExpressionNode;
333
+ /**
334
+ * 检查节点是否为 ObjectExpression
335
+ *
336
+ * @param obj - 待检查的对象
337
+ * @returns 是否为 ObjectExpression
338
+ */
127
339
  declare function isObjectExpressionNode(obj: unknown): obj is ObjectExpressionNode;
128
340
  //#endregion
129
341
  //#region src/guards/plugin.guards.d.ts
342
+ /**
343
+ * 检查对象是否为有效的 Oxlint 插件
344
+ *
345
+ * @param obj - 待检查的对象
346
+ * @returns 是否为有效的 Oxlint 插件
347
+ */
130
348
  declare function isPlugin(obj: unknown): obj is Plugin;
349
+ /**
350
+ * 获取插件名称
351
+ *
352
+ * 如果插件无效则抛出错误,确保返回值一定是 string
353
+ *
354
+ * @param plugin - Oxlint 插件
355
+ * @returns 插件名称
356
+ * @throws {@link Error} 如果插件无效或插件名称未定义
357
+ */
131
358
  declare function getPluginName(plugin: unknown): string;
132
359
  //#endregion
133
360
  export { type CallExpressionNode, CallExpressionSchema, type ExportDefaultDeclarationNode, ExportDefaultDeclarationSchema, type ImportDeclarationNode, ImportDeclarationSchema, type ImportSpecifierNode, ImportSpecifierSchema, type NodeWithIdentifier, type NodeWithIdentifierAndRange, NodeWithIdentifierAndRangeSchema, NodeWithIdentifierSchema, type ObjectExpressionNode, ObjectExpressionSchema, OxlintContext, Plugin, PluginMeta, PluginMetaSchema, PluginSchema, RuleState, getFileName, getImportedNames, getPluginName, hasAnyFileSuffix, hasFileSuffix, hasIPrefix, hasIdWithName, hasIdWithNameAndRange, hasImportedName, isCallExpressionNode, isDefaultImport, isImportDeclaration, isImportSpecifier, isInExcludedPath, isNamespaceImport, isObjectExpressionNode, isPlugin, isTestFile, isValidDtoNameCamelCase, isValidDtoNameUpperCase, removeIPrefix, toDtoCamelCase, toDtoUpperCase };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-oxlint/utils",
3
- "version": "0.0.36",
3
+ "version": "0.0.37",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist"