@longzai-intelligence-oxlint/utils 0.0.29 → 0.0.31
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.cjs +1 -1
- package/dist/index.d.cts +87 -56
- package/dist/index.d.mts +87 -56
- package/dist/index.mjs +1 -1
- package/package.json +17 -15
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`zod/mini`);c=s(c,1);let l=require(`node:path`);l=s(l,1);const u=c.object({id:c.object({name:c.string()}),type:c.string()}),d=c.object({id:c.object({name:c.string(),range:c.tuple([c.number(),c.number()])}),type:c.string()}),f=c.object({type:c.enum([`ImportSpecifier`,`ImportDefaultSpecifier`,`ImportNamespaceSpecifier`]),imported:c.object({name:c.string()}),local:c.object({name:c.string()})}),p=c.object({type:c.literal(`ImportDeclaration`),source:c.object({value:c.string()}),specifiers:c.array(f)}),m=c.object({type:c.literal(`ExportDefaultDeclaration`),declaration:c.object({type:c.string(),name:c.optional(c.string()),callee:c.optional(c.object({name:c.optional(c.string())})),properties:c.optional(c.array(c.unknown()))})}),h=c.object({type:c.literal(`CallExpression`),callee:c.object({name:c.union([c.string(),c.undefined()])})}),g=c.object({type:c.literal(`ObjectExpression`)}),_=c.object({name:c.string()}),v=c.object({meta:_});function y(e){return p.safeParse(e).success}function b(e){return f.safeParse(e).success}function x(e){return e.type===`ImportDefaultSpecifier`}function S(e){return e.type===`ImportNamespaceSpecifier`}function C(e){return e.specifiers.filter(b).map(e=>e.imported.name)}function w(e,t){return C(e).includes(t)}function T(e){return e.endsWith(`.test.ts`)||e.endsWith(`.spec.ts`)}function E(e,t){return e.endsWith(t)}function D(e,t){return t.some(t=>e.endsWith(t))}function O(e){return l.default.basename(e)}function k(e,t){let n=e.replace(/\\/g,`/`);return t.some(e=>n.endsWith(e))}function A(e){return/^I[A-Z]/.test(e)}function j(e){return e.endsWith(`DTO`)}function M(e){return e.endsWith(`Dto`)}function N(e){return A(e)?e.substring(1):e}function P(e){return e.replace(/DTO$/,`Dto`)}function F(e){return e.replace(/Dto$/,`DTO`)}function I(e){return u.safeParse(e).success}function L(e){return d.safeParse(e).success}function R(e){return h.safeParse(e).success}function z(e){return g.safeParse(e).success}function B(e){return v.safeParse(e).success}function V(e){let t=v.safeParse(e);if(!t.success)throw Error(`无效的 Oxlint 插件:插件对象必须包含 meta.name 属性`);return t.data.meta.name}exports.CallExpressionSchema=h,exports.ExportDefaultDeclarationSchema=m,exports.ImportDeclarationSchema=p,exports.ImportSpecifierSchema=f,exports.NodeWithIdentifierAndRangeSchema=d,exports.NodeWithIdentifierSchema=u,exports.ObjectExpressionSchema=g,exports.PluginMetaSchema=_,exports.PluginSchema=v,exports.getFileName=O,exports.getImportedNames=C,exports.getPluginName=V,exports.hasAnyFileSuffix=D,exports.hasFileSuffix=E,exports.hasIPrefix=A,exports.hasIdWithName=I,exports.hasIdWithNameAndRange=L,exports.hasImportedName=w,exports.isCallExpressionNode=R,exports.isDefaultImport=x,exports.isImportDeclaration=y,exports.isImportSpecifier=b,exports.isInExcludedPath=k,exports.isNamespaceImport=S,exports.isObjectExpressionNode=z,exports.isPlugin=B,exports.isTestFile=T,exports.isValidDtoNameCamelCase=M,exports.isValidDtoNameUpperCase=j,exports.removeIPrefix=N,exports.toDtoCamelCase=P,exports.toDtoUpperCase=F;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Context } from "@oxlint/plugins";
|
|
2
|
+
import * as z from "zod/mini";
|
|
2
3
|
|
|
3
4
|
//#region src/types/rule.types.d.ts
|
|
4
5
|
type OxlintContext = Context;
|
|
@@ -10,55 +11,91 @@ type RuleState = {
|
|
|
10
11
|
forbiddenImportName: string;
|
|
11
12
|
};
|
|
12
13
|
//#endregion
|
|
13
|
-
//#region src/
|
|
14
|
-
|
|
15
|
-
id: {
|
|
16
|
-
name: string
|
|
17
|
-
}
|
|
18
|
-
type: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
id: {
|
|
22
|
-
name: string
|
|
23
|
-
range: [number
|
|
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
|
-
type:
|
|
61
|
-
|
|
14
|
+
//#region src/schemas/ast.schemas.d.ts
|
|
15
|
+
declare const NodeWithIdentifierSchema: z.ZodMiniObject<{
|
|
16
|
+
id: z.ZodMiniObject<{
|
|
17
|
+
name: z.ZodMiniString<string>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
type: z.ZodMiniString<string>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
declare const NodeWithIdentifierAndRangeSchema: z.ZodMiniObject<{
|
|
22
|
+
id: z.ZodMiniObject<{
|
|
23
|
+
name: z.ZodMiniString<string>;
|
|
24
|
+
range: z.ZodMiniTuple<readonly [z.ZodMiniNumber<number>, z.ZodMiniNumber<number>], null>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
type: z.ZodMiniString<string>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
declare const ImportSpecifierSchema: z.ZodMiniObject<{
|
|
29
|
+
type: z.ZodMiniEnum<{
|
|
30
|
+
ImportSpecifier: "ImportSpecifier";
|
|
31
|
+
ImportDefaultSpecifier: "ImportDefaultSpecifier";
|
|
32
|
+
ImportNamespaceSpecifier: "ImportNamespaceSpecifier";
|
|
33
|
+
}>;
|
|
34
|
+
imported: z.ZodMiniObject<{
|
|
35
|
+
name: z.ZodMiniString<string>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
local: z.ZodMiniObject<{
|
|
38
|
+
name: z.ZodMiniString<string>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
declare const ImportDeclarationSchema: z.ZodMiniObject<{
|
|
42
|
+
type: z.ZodMiniLiteral<"ImportDeclaration">;
|
|
43
|
+
source: z.ZodMiniObject<{
|
|
44
|
+
value: z.ZodMiniString<string>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
specifiers: z.ZodMiniArray<z.ZodMiniObject<{
|
|
47
|
+
type: z.ZodMiniEnum<{
|
|
48
|
+
ImportSpecifier: "ImportSpecifier";
|
|
49
|
+
ImportDefaultSpecifier: "ImportDefaultSpecifier";
|
|
50
|
+
ImportNamespaceSpecifier: "ImportNamespaceSpecifier";
|
|
51
|
+
}>;
|
|
52
|
+
imported: z.ZodMiniObject<{
|
|
53
|
+
name: z.ZodMiniString<string>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
local: z.ZodMiniObject<{
|
|
56
|
+
name: z.ZodMiniString<string>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
declare const ExportDefaultDeclarationSchema: z.ZodMiniObject<{
|
|
61
|
+
type: z.ZodMiniLiteral<"ExportDefaultDeclaration">;
|
|
62
|
+
declaration: z.ZodMiniObject<{
|
|
63
|
+
type: z.ZodMiniString<string>;
|
|
64
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
65
|
+
callee: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
66
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
properties: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
declare const CallExpressionSchema: z.ZodMiniObject<{
|
|
72
|
+
type: z.ZodMiniLiteral<"CallExpression">;
|
|
73
|
+
callee: z.ZodMiniObject<{
|
|
74
|
+
name: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniUndefined]>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
declare const ObjectExpressionSchema: z.ZodMiniObject<{
|
|
78
|
+
type: z.ZodMiniLiteral<"ObjectExpression">;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
type NodeWithIdentifier = z.infer<typeof NodeWithIdentifierSchema>;
|
|
81
|
+
type NodeWithIdentifierAndRange = z.infer<typeof NodeWithIdentifierAndRangeSchema>;
|
|
82
|
+
type ImportSpecifierNode = z.infer<typeof ImportSpecifierSchema>;
|
|
83
|
+
type ImportDeclarationNode = z.infer<typeof ImportDeclarationSchema>;
|
|
84
|
+
type ExportDefaultDeclarationNode = z.infer<typeof ExportDefaultDeclarationSchema>;
|
|
85
|
+
type CallExpressionNode = z.infer<typeof CallExpressionSchema>;
|
|
86
|
+
type ObjectExpressionNode = z.infer<typeof ObjectExpressionSchema>;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/schemas/plugin.schemas.d.ts
|
|
89
|
+
declare const PluginMetaSchema: z.ZodMiniObject<{
|
|
90
|
+
name: z.ZodMiniString<string>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
declare const PluginSchema: z.ZodMiniObject<{
|
|
93
|
+
meta: z.ZodMiniObject<{
|
|
94
|
+
name: z.ZodMiniString<string>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
type PluginMeta = z.infer<typeof PluginMetaSchema>;
|
|
98
|
+
type Plugin = z.infer<typeof PluginSchema>;
|
|
62
99
|
//#endregion
|
|
63
100
|
//#region src/utils/import.utils.d.ts
|
|
64
101
|
declare function isImportDeclaration(node: unknown): node is ImportDeclarationNode;
|
|
@@ -90,13 +127,7 @@ declare function isCallExpressionNode(obj: unknown): obj is CallExpressionNode;
|
|
|
90
127
|
declare function isObjectExpressionNode(obj: unknown): obj is ObjectExpressionNode;
|
|
91
128
|
//#endregion
|
|
92
129
|
//#region src/guards/plugin.guards.d.ts
|
|
93
|
-
type PluginMeta = {
|
|
94
|
-
name: string;
|
|
95
|
-
};
|
|
96
|
-
type Plugin = {
|
|
97
|
-
meta: PluginMeta;
|
|
98
|
-
};
|
|
99
130
|
declare function isPlugin(obj: unknown): obj is Plugin;
|
|
100
131
|
declare function getPluginName(plugin: unknown): string;
|
|
101
132
|
//#endregion
|
|
102
|
-
export { CallExpressionNode, ExportDefaultDeclarationNode, ImportDeclarationNode, ImportSpecifierNode, NodeWithIdentifier, NodeWithIdentifierAndRange, ObjectExpressionNode, OxlintContext, Plugin, PluginMeta, RuleState, getFileName, getImportedNames, getPluginName, hasAnyFileSuffix, hasFileSuffix, hasIPrefix, hasIdWithName, hasIdWithNameAndRange, hasImportedName, isCallExpressionNode, isDefaultImport, isImportDeclaration, isImportSpecifier, isInExcludedPath, isNamespaceImport, isObjectExpressionNode, isPlugin, isTestFile, isValidDtoNameCamelCase, isValidDtoNameUpperCase, removeIPrefix, toDtoCamelCase, toDtoUpperCase };
|
|
133
|
+
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
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as z from "zod/mini";
|
|
1
2
|
import { Context } from "@oxlint/plugins";
|
|
2
3
|
|
|
3
4
|
//#region src/types/rule.types.d.ts
|
|
@@ -10,55 +11,91 @@ type RuleState = {
|
|
|
10
11
|
forbiddenImportName: string;
|
|
11
12
|
};
|
|
12
13
|
//#endregion
|
|
13
|
-
//#region src/
|
|
14
|
-
|
|
15
|
-
id: {
|
|
16
|
-
name: string
|
|
17
|
-
}
|
|
18
|
-
type: string
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
id: {
|
|
22
|
-
name: string
|
|
23
|
-
range: [number
|
|
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
|
-
type:
|
|
61
|
-
|
|
14
|
+
//#region src/schemas/ast.schemas.d.ts
|
|
15
|
+
declare const NodeWithIdentifierSchema: z.ZodMiniObject<{
|
|
16
|
+
id: z.ZodMiniObject<{
|
|
17
|
+
name: z.ZodMiniString<string>;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
type: z.ZodMiniString<string>;
|
|
20
|
+
}, z.core.$strip>;
|
|
21
|
+
declare const NodeWithIdentifierAndRangeSchema: z.ZodMiniObject<{
|
|
22
|
+
id: z.ZodMiniObject<{
|
|
23
|
+
name: z.ZodMiniString<string>;
|
|
24
|
+
range: z.ZodMiniTuple<readonly [z.ZodMiniNumber<number>, z.ZodMiniNumber<number>], null>;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
type: z.ZodMiniString<string>;
|
|
27
|
+
}, z.core.$strip>;
|
|
28
|
+
declare const ImportSpecifierSchema: z.ZodMiniObject<{
|
|
29
|
+
type: z.ZodMiniEnum<{
|
|
30
|
+
ImportSpecifier: "ImportSpecifier";
|
|
31
|
+
ImportDefaultSpecifier: "ImportDefaultSpecifier";
|
|
32
|
+
ImportNamespaceSpecifier: "ImportNamespaceSpecifier";
|
|
33
|
+
}>;
|
|
34
|
+
imported: z.ZodMiniObject<{
|
|
35
|
+
name: z.ZodMiniString<string>;
|
|
36
|
+
}, z.core.$strip>;
|
|
37
|
+
local: z.ZodMiniObject<{
|
|
38
|
+
name: z.ZodMiniString<string>;
|
|
39
|
+
}, z.core.$strip>;
|
|
40
|
+
}, z.core.$strip>;
|
|
41
|
+
declare const ImportDeclarationSchema: z.ZodMiniObject<{
|
|
42
|
+
type: z.ZodMiniLiteral<"ImportDeclaration">;
|
|
43
|
+
source: z.ZodMiniObject<{
|
|
44
|
+
value: z.ZodMiniString<string>;
|
|
45
|
+
}, z.core.$strip>;
|
|
46
|
+
specifiers: z.ZodMiniArray<z.ZodMiniObject<{
|
|
47
|
+
type: z.ZodMiniEnum<{
|
|
48
|
+
ImportSpecifier: "ImportSpecifier";
|
|
49
|
+
ImportDefaultSpecifier: "ImportDefaultSpecifier";
|
|
50
|
+
ImportNamespaceSpecifier: "ImportNamespaceSpecifier";
|
|
51
|
+
}>;
|
|
52
|
+
imported: z.ZodMiniObject<{
|
|
53
|
+
name: z.ZodMiniString<string>;
|
|
54
|
+
}, z.core.$strip>;
|
|
55
|
+
local: z.ZodMiniObject<{
|
|
56
|
+
name: z.ZodMiniString<string>;
|
|
57
|
+
}, z.core.$strip>;
|
|
58
|
+
}, z.core.$strip>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
declare const ExportDefaultDeclarationSchema: z.ZodMiniObject<{
|
|
61
|
+
type: z.ZodMiniLiteral<"ExportDefaultDeclaration">;
|
|
62
|
+
declaration: z.ZodMiniObject<{
|
|
63
|
+
type: z.ZodMiniString<string>;
|
|
64
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
65
|
+
callee: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
66
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
properties: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniUnknown>>;
|
|
69
|
+
}, z.core.$strip>;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
declare const CallExpressionSchema: z.ZodMiniObject<{
|
|
72
|
+
type: z.ZodMiniLiteral<"CallExpression">;
|
|
73
|
+
callee: z.ZodMiniObject<{
|
|
74
|
+
name: z.ZodMiniUnion<readonly [z.ZodMiniString<string>, z.ZodMiniUndefined]>;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
}, z.core.$strip>;
|
|
77
|
+
declare const ObjectExpressionSchema: z.ZodMiniObject<{
|
|
78
|
+
type: z.ZodMiniLiteral<"ObjectExpression">;
|
|
79
|
+
}, z.core.$strip>;
|
|
80
|
+
type NodeWithIdentifier = z.infer<typeof NodeWithIdentifierSchema>;
|
|
81
|
+
type NodeWithIdentifierAndRange = z.infer<typeof NodeWithIdentifierAndRangeSchema>;
|
|
82
|
+
type ImportSpecifierNode = z.infer<typeof ImportSpecifierSchema>;
|
|
83
|
+
type ImportDeclarationNode = z.infer<typeof ImportDeclarationSchema>;
|
|
84
|
+
type ExportDefaultDeclarationNode = z.infer<typeof ExportDefaultDeclarationSchema>;
|
|
85
|
+
type CallExpressionNode = z.infer<typeof CallExpressionSchema>;
|
|
86
|
+
type ObjectExpressionNode = z.infer<typeof ObjectExpressionSchema>;
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/schemas/plugin.schemas.d.ts
|
|
89
|
+
declare const PluginMetaSchema: z.ZodMiniObject<{
|
|
90
|
+
name: z.ZodMiniString<string>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
declare const PluginSchema: z.ZodMiniObject<{
|
|
93
|
+
meta: z.ZodMiniObject<{
|
|
94
|
+
name: z.ZodMiniString<string>;
|
|
95
|
+
}, z.core.$strip>;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
type PluginMeta = z.infer<typeof PluginMetaSchema>;
|
|
98
|
+
type Plugin = z.infer<typeof PluginSchema>;
|
|
62
99
|
//#endregion
|
|
63
100
|
//#region src/utils/import.utils.d.ts
|
|
64
101
|
declare function isImportDeclaration(node: unknown): node is ImportDeclarationNode;
|
|
@@ -90,13 +127,7 @@ declare function isCallExpressionNode(obj: unknown): obj is CallExpressionNode;
|
|
|
90
127
|
declare function isObjectExpressionNode(obj: unknown): obj is ObjectExpressionNode;
|
|
91
128
|
//#endregion
|
|
92
129
|
//#region src/guards/plugin.guards.d.ts
|
|
93
|
-
type PluginMeta = {
|
|
94
|
-
name: string;
|
|
95
|
-
};
|
|
96
|
-
type Plugin = {
|
|
97
|
-
meta: PluginMeta;
|
|
98
|
-
};
|
|
99
130
|
declare function isPlugin(obj: unknown): obj is Plugin;
|
|
100
131
|
declare function getPluginName(plugin: unknown): string;
|
|
101
132
|
//#endregion
|
|
102
|
-
export { CallExpressionNode, ExportDefaultDeclarationNode, ImportDeclarationNode, ImportSpecifierNode, NodeWithIdentifier, NodeWithIdentifierAndRange, ObjectExpressionNode, OxlintContext, Plugin, PluginMeta, RuleState, getFileName, getImportedNames, getPluginName, hasAnyFileSuffix, hasFileSuffix, hasIPrefix, hasIdWithName, hasIdWithNameAndRange, hasImportedName, isCallExpressionNode, isDefaultImport, isImportDeclaration, isImportSpecifier, isInExcludedPath, isNamespaceImport, isObjectExpressionNode, isPlugin, isTestFile, isValidDtoNameCamelCase, isValidDtoNameUpperCase, removeIPrefix, toDtoCamelCase, toDtoUpperCase };
|
|
133
|
+
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.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"node:path";
|
|
1
|
+
import*as e from"zod/mini";import t from"node:path";const n=e.object({id:e.object({name:e.string()}),type:e.string()}),r=e.object({id:e.object({name:e.string(),range:e.tuple([e.number(),e.number()])}),type:e.string()}),i=e.object({type:e.enum([`ImportSpecifier`,`ImportDefaultSpecifier`,`ImportNamespaceSpecifier`]),imported:e.object({name:e.string()}),local:e.object({name:e.string()})}),a=e.object({type:e.literal(`ImportDeclaration`),source:e.object({value:e.string()}),specifiers:e.array(i)}),o=e.object({type:e.literal(`ExportDefaultDeclaration`),declaration:e.object({type:e.string(),name:e.optional(e.string()),callee:e.optional(e.object({name:e.optional(e.string())})),properties:e.optional(e.array(e.unknown()))})}),s=e.object({type:e.literal(`CallExpression`),callee:e.object({name:e.union([e.string(),e.undefined()])})}),c=e.object({type:e.literal(`ObjectExpression`)}),l=e.object({name:e.string()}),u=e.object({meta:l});function d(e){return a.safeParse(e).success}function f(e){return i.safeParse(e).success}function p(e){return e.type===`ImportDefaultSpecifier`}function m(e){return e.type===`ImportNamespaceSpecifier`}function h(e){return e.specifiers.filter(f).map(e=>e.imported.name)}function g(e,t){return h(e).includes(t)}function _(e){return e.endsWith(`.test.ts`)||e.endsWith(`.spec.ts`)}function v(e,t){return e.endsWith(t)}function y(e,t){return t.some(t=>e.endsWith(t))}function b(e){return t.basename(e)}function x(e,t){let n=e.replace(/\\/g,`/`);return t.some(e=>n.endsWith(e))}function S(e){return/^I[A-Z]/.test(e)}function C(e){return e.endsWith(`DTO`)}function w(e){return e.endsWith(`Dto`)}function T(e){return S(e)?e.substring(1):e}function E(e){return e.replace(/DTO$/,`Dto`)}function D(e){return e.replace(/Dto$/,`DTO`)}function O(e){return n.safeParse(e).success}function k(e){return r.safeParse(e).success}function A(e){return s.safeParse(e).success}function j(e){return c.safeParse(e).success}function M(e){return u.safeParse(e).success}function N(e){let t=u.safeParse(e);if(!t.success)throw Error(`无效的 Oxlint 插件:插件对象必须包含 meta.name 属性`);return t.data.meta.name}export{s as CallExpressionSchema,o as ExportDefaultDeclarationSchema,a as ImportDeclarationSchema,i as ImportSpecifierSchema,r as NodeWithIdentifierAndRangeSchema,n as NodeWithIdentifierSchema,c as ObjectExpressionSchema,l as PluginMetaSchema,u as PluginSchema,b as getFileName,h as getImportedNames,N as getPluginName,y as hasAnyFileSuffix,v as hasFileSuffix,S as hasIPrefix,O as hasIdWithName,k as hasIdWithNameAndRange,g as hasImportedName,A as isCallExpressionNode,p as isDefaultImport,d as isImportDeclaration,f as isImportSpecifier,x as isInExcludedPath,m as isNamespaceImport,j as isObjectExpressionNode,M as isPlugin,_ as isTestFile,w as isValidDtoNameCamelCase,C as isValidDtoNameUpperCase,T as removeIPrefix,E as toDtoCamelCase,D as toDtoUpperCase};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-oxlint/utils",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.31",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -30,31 +30,33 @@
|
|
|
30
30
|
"test:coverage": "vitest run --coverage",
|
|
31
31
|
"lint": "oxlint && oxfmt --check",
|
|
32
32
|
"lint:fix": "oxlint --fix && oxfmt",
|
|
33
|
-
"typecheck": "bun run typecheck:app && bun run typecheck:node",
|
|
33
|
+
"typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
|
|
34
34
|
"typecheck:app": "tsgo --noEmit -p tsconfig/app.json",
|
|
35
|
-
"typecheck:node": "tsgo --noEmit -p tsconfig/node.json"
|
|
35
|
+
"typecheck:node": "tsgo --noEmit -p tsconfig/node.json",
|
|
36
|
+
"typecheck:test": "tsgo --noEmit -p tsconfig/test.json"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
|
-
"@oxlint/plugins": "^1.
|
|
39
|
+
"@oxlint/plugins": "^1.67.0",
|
|
40
|
+
"zod": "^4.4.3"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
41
|
-
"@longzai-intelligence-oxlint/oxlint-config": "0.0.
|
|
42
|
-
"@longzai-intelligence-oxlint/plugin-architecture": "0.0.
|
|
43
|
-
"@longzai-intelligence-oxlint/plugin-code-style": "0.0.
|
|
44
|
-
"@longzai-intelligence-oxlint/plugin-package-json": "0.0.
|
|
45
|
-
"@longzai-intelligence-oxlint/plugin-perfectionist": "0.0.
|
|
46
|
-
"@longzai-intelligence-oxlint/plugin-schema-type-separation": "0.0.
|
|
47
|
-
"@longzai-intelligence-oxlint/plugin-stylistic": "0.0.
|
|
48
|
-
"@longzai-intelligence-oxlint/plugin-tsdoc": "0.0.
|
|
49
|
-
"@longzai-intelligence-oxlint/plugin-typescript-eslint": "0.0.
|
|
50
|
-
"@longzai-intelligence-oxlint/plugin-zod": "0.0.
|
|
43
|
+
"@longzai-intelligence-oxlint/oxlint-config": "0.0.31",
|
|
44
|
+
"@longzai-intelligence-oxlint/plugin-architecture": "0.0.31",
|
|
45
|
+
"@longzai-intelligence-oxlint/plugin-code-style": "0.0.31",
|
|
46
|
+
"@longzai-intelligence-oxlint/plugin-package-json": "0.0.31",
|
|
47
|
+
"@longzai-intelligence-oxlint/plugin-perfectionist": "0.0.31",
|
|
48
|
+
"@longzai-intelligence-oxlint/plugin-schema-type-separation": "0.0.31",
|
|
49
|
+
"@longzai-intelligence-oxlint/plugin-stylistic": "0.0.31",
|
|
50
|
+
"@longzai-intelligence-oxlint/plugin-tsdoc": "0.0.31",
|
|
51
|
+
"@longzai-intelligence-oxlint/plugin-typescript-eslint": "0.0.31",
|
|
52
|
+
"@longzai-intelligence-oxlint/plugin-zod": "0.0.31",
|
|
51
53
|
"@longzai-intelligence/tsdown-config": "0.0.1",
|
|
52
54
|
"@longzai-intelligence/typescript-config": "0.0.3",
|
|
53
55
|
"@longzai-intelligence/vitest-config": "0.0.12",
|
|
54
56
|
"@types/node": "^25.9.1",
|
|
55
57
|
"@typescript/native-preview": "beta",
|
|
56
58
|
"@vitest/coverage-v8": "^4.1.7",
|
|
57
|
-
"oxlint": "^1.
|
|
59
|
+
"oxlint": "^1.67.0",
|
|
58
60
|
"rimraf": "^6.1.3",
|
|
59
61
|
"tsdown": "^0.21.10",
|
|
60
62
|
"vitest": "^4.1.7"
|