@longzai-intelligence-oxlint/utils 0.0.29 → 0.0.30

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 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(`node:path`);c=s(c,1);function l(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ImportDeclaration`&&`source`in e&&e.source!==null&&typeof e.source==`object`&&`value`in e.source&&typeof e.source.value==`string`&&`specifiers`in e&&Array.isArray(e.specifiers)}function u(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`ImportSpecifier`||e.type===`ImportDefaultSpecifier`||e.type===`ImportNamespaceSpecifier`)&&`imported`in e&&e.imported!==null&&typeof e.imported==`object`&&`name`in e.imported&&typeof e.imported.name==`string`&&`local`in e&&e.local!==null&&typeof e.local==`object`&&`name`in e.local&&typeof e.local.name==`string`}function d(e){return e.type===`ImportDefaultSpecifier`}function f(e){return e.type===`ImportNamespaceSpecifier`}function p(e){return e.specifiers.filter(u).map(e=>e.imported.name)}function m(e,t){return p(e).includes(t)}function h(e){return e.endsWith(`.test.ts`)||e.endsWith(`.spec.ts`)}function g(e,t){return e.endsWith(t)}function _(e,t){return t.some(t=>e.endsWith(t))}function v(e){return c.default.basename(e)}function y(e,t){let n=e.replace(/\\/g,`/`);return t.some(e=>n.endsWith(e))}function b(e){return/^I[A-Z]/.test(e)}function x(e){return e.endsWith(`DTO`)}function S(e){return e.endsWith(`Dto`)}function C(e){return b(e)?e.substring(1):e}function w(e){return e.replace(/DTO$/,`Dto`)}function T(e){return e.replace(/Dto$/,`DTO`)}function E(e){return typeof e==`object`&&!!e&&`id`in e&&e.id!==null&&typeof e.id==`object`&&`name`in e.id&&typeof e.id.name==`string`&&`type`in e&&typeof e.type==`string`}function D(e){return E(e)&&`range`in e.id&&Array.isArray(e.id.range)&&e.id.range.length===2}function O(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`CallExpression`&&`callee`in e&&typeof e.callee==`object`&&e.callee!==null&&`name`in e.callee}function k(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ObjectExpression`}function A(e){return typeof e==`object`&&!!e&&`meta`in e&&typeof e.meta==`object`&&e.meta!==null&&`name`in e.meta&&typeof e.meta.name==`string`}function j(e){if(!A(e))throw Error(`无效的 Oxlint 插件:插件对象必须包含 meta.name 属性`);return e.meta.name}exports.getFileName=v,exports.getImportedNames=p,exports.getPluginName=j,exports.hasAnyFileSuffix=_,exports.hasFileSuffix=g,exports.hasIPrefix=b,exports.hasIdWithName=E,exports.hasIdWithNameAndRange=D,exports.hasImportedName=m,exports.isCallExpressionNode=O,exports.isDefaultImport=d,exports.isImportDeclaration=l,exports.isImportSpecifier=u,exports.isInExcludedPath=y,exports.isNamespaceImport=f,exports.isObjectExpressionNode=k,exports.isPlugin=A,exports.isTestFile=h,exports.isValidDtoNameCamelCase=S,exports.isValidDtoNameUpperCase=x,exports.removeIPrefix=C,exports.toDtoCamelCase=w,exports.toDtoUpperCase=T;
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/types/ast.types.d.ts
14
- type NodeWithIdentifier = {
15
- id: {
16
- name: string;
17
- };
18
- type: string;
19
- };
20
- type NodeWithIdentifierAndRange = NodeWithIdentifier & {
21
- id: {
22
- name: string;
23
- range: [number, number];
24
- };
25
- };
26
- type ImportSpecifierNode = {
27
- type: 'ImportSpecifier' | 'ImportDefaultSpecifier' | 'ImportNamespaceSpecifier';
28
- imported: {
29
- name: string;
30
- };
31
- local: {
32
- name: string;
33
- };
34
- };
35
- type ImportDeclarationNode = {
36
- type: 'ImportDeclaration';
37
- source: {
38
- value: string;
39
- };
40
- specifiers: ImportSpecifierNode[];
41
- };
42
- type ExportDefaultDeclarationNode = {
43
- type: 'ExportDefaultDeclaration';
44
- declaration: {
45
- type: string;
46
- name?: string;
47
- callee?: {
48
- name?: string;
49
- };
50
- properties?: unknown[];
51
- };
52
- };
53
- type CallExpressionNode = {
54
- type: 'CallExpression';
55
- callee: {
56
- name?: string;
57
- };
58
- };
59
- type ObjectExpressionNode = {
60
- type: 'ObjectExpression';
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/types/ast.types.d.ts
14
- type NodeWithIdentifier = {
15
- id: {
16
- name: string;
17
- };
18
- type: string;
19
- };
20
- type NodeWithIdentifierAndRange = NodeWithIdentifier & {
21
- id: {
22
- name: string;
23
- range: [number, number];
24
- };
25
- };
26
- type ImportSpecifierNode = {
27
- type: 'ImportSpecifier' | 'ImportDefaultSpecifier' | 'ImportNamespaceSpecifier';
28
- imported: {
29
- name: string;
30
- };
31
- local: {
32
- name: string;
33
- };
34
- };
35
- type ImportDeclarationNode = {
36
- type: 'ImportDeclaration';
37
- source: {
38
- value: string;
39
- };
40
- specifiers: ImportSpecifierNode[];
41
- };
42
- type ExportDefaultDeclarationNode = {
43
- type: 'ExportDefaultDeclaration';
44
- declaration: {
45
- type: string;
46
- name?: string;
47
- callee?: {
48
- name?: string;
49
- };
50
- properties?: unknown[];
51
- };
52
- };
53
- type CallExpressionNode = {
54
- type: 'CallExpression';
55
- callee: {
56
- name?: string;
57
- };
58
- };
59
- type ObjectExpressionNode = {
60
- type: 'ObjectExpression';
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";function t(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ImportDeclaration`&&`source`in e&&e.source!==null&&typeof e.source==`object`&&`value`in e.source&&typeof e.source.value==`string`&&`specifiers`in e&&Array.isArray(e.specifiers)}function n(e){return typeof e==`object`&&!!e&&`type`in e&&(e.type===`ImportSpecifier`||e.type===`ImportDefaultSpecifier`||e.type===`ImportNamespaceSpecifier`)&&`imported`in e&&e.imported!==null&&typeof e.imported==`object`&&`name`in e.imported&&typeof e.imported.name==`string`&&`local`in e&&e.local!==null&&typeof e.local==`object`&&`name`in e.local&&typeof e.local.name==`string`}function r(e){return e.type===`ImportDefaultSpecifier`}function i(e){return e.type===`ImportNamespaceSpecifier`}function a(e){return e.specifiers.filter(n).map(e=>e.imported.name)}function o(e,t){return a(e).includes(t)}function s(e){return e.endsWith(`.test.ts`)||e.endsWith(`.spec.ts`)}function c(e,t){return e.endsWith(t)}function l(e,t){return t.some(t=>e.endsWith(t))}function u(t){return e.basename(t)}function d(e,t){let n=e.replace(/\\/g,`/`);return t.some(e=>n.endsWith(e))}function f(e){return/^I[A-Z]/.test(e)}function p(e){return e.endsWith(`DTO`)}function m(e){return e.endsWith(`Dto`)}function h(e){return f(e)?e.substring(1):e}function g(e){return e.replace(/DTO$/,`Dto`)}function _(e){return e.replace(/Dto$/,`DTO`)}function v(e){return typeof e==`object`&&!!e&&`id`in e&&e.id!==null&&typeof e.id==`object`&&`name`in e.id&&typeof e.id.name==`string`&&`type`in e&&typeof e.type==`string`}function y(e){return v(e)&&`range`in e.id&&Array.isArray(e.id.range)&&e.id.range.length===2}function b(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`CallExpression`&&`callee`in e&&typeof e.callee==`object`&&e.callee!==null&&`name`in e.callee}function x(e){return typeof e==`object`&&!!e&&`type`in e&&e.type===`ObjectExpression`}function S(e){return typeof e==`object`&&!!e&&`meta`in e&&typeof e.meta==`object`&&e.meta!==null&&`name`in e.meta&&typeof e.meta.name==`string`}function C(e){if(!S(e))throw Error(`无效的 Oxlint 插件:插件对象必须包含 meta.name 属性`);return e.meta.name}export{u as getFileName,a as getImportedNames,C as getPluginName,l as hasAnyFileSuffix,c as hasFileSuffix,f as hasIPrefix,v as hasIdWithName,y as hasIdWithNameAndRange,o as hasImportedName,b as isCallExpressionNode,r as isDefaultImport,t as isImportDeclaration,n as isImportSpecifier,d as isInExcludedPath,i as isNamespaceImport,x as isObjectExpressionNode,S as isPlugin,s as isTestFile,m as isValidDtoNameCamelCase,p as isValidDtoNameUpperCase,h as removeIPrefix,g as toDtoCamelCase,_ as toDtoUpperCase};
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.29",
3
+ "version": "0.0.30",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist"
@@ -30,24 +30,26 @@
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.66.0"
39
+ "@oxlint/plugins": "^1.66.0",
40
+ "zod": "^4.4.3"
39
41
  },
40
42
  "devDependencies": {
41
- "@longzai-intelligence-oxlint/oxlint-config": "0.0.29",
42
- "@longzai-intelligence-oxlint/plugin-architecture": "0.0.29",
43
- "@longzai-intelligence-oxlint/plugin-code-style": "0.0.29",
44
- "@longzai-intelligence-oxlint/plugin-package-json": "0.0.29",
45
- "@longzai-intelligence-oxlint/plugin-perfectionist": "0.0.29",
46
- "@longzai-intelligence-oxlint/plugin-schema-type-separation": "0.0.29",
47
- "@longzai-intelligence-oxlint/plugin-stylistic": "0.0.29",
48
- "@longzai-intelligence-oxlint/plugin-tsdoc": "0.0.29",
49
- "@longzai-intelligence-oxlint/plugin-typescript-eslint": "0.0.29",
50
- "@longzai-intelligence-oxlint/plugin-zod": "0.0.29",
43
+ "@longzai-intelligence-oxlint/oxlint-config": "0.0.30",
44
+ "@longzai-intelligence-oxlint/plugin-architecture": "0.0.30",
45
+ "@longzai-intelligence-oxlint/plugin-code-style": "0.0.30",
46
+ "@longzai-intelligence-oxlint/plugin-package-json": "0.0.30",
47
+ "@longzai-intelligence-oxlint/plugin-perfectionist": "0.0.30",
48
+ "@longzai-intelligence-oxlint/plugin-schema-type-separation": "0.0.30",
49
+ "@longzai-intelligence-oxlint/plugin-stylistic": "0.0.30",
50
+ "@longzai-intelligence-oxlint/plugin-tsdoc": "0.0.30",
51
+ "@longzai-intelligence-oxlint/plugin-typescript-eslint": "0.0.30",
52
+ "@longzai-intelligence-oxlint/plugin-zod": "0.0.30",
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",