@longzai-intelligence/oxlint-plugin-schema-type-separation 0.0.1

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.
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e={"@longzai-intelligence/schema-type-separation/no-type-in-schema":`off`,"@longzai-intelligence/schema-type-separation/no-schema-in-types":`off`};exports.recommended=e;
@@ -0,0 +1,6 @@
1
+ import { OxlintRules } from "@longzai-intelligence/oxlint-core";
2
+
3
+ //#region src/configs/recommended.config.d.ts
4
+ declare const recommended: OxlintRules;
5
+ //#endregion
6
+ export { recommended };
@@ -0,0 +1,6 @@
1
+ import { OxlintRules } from "@longzai-intelligence/oxlint-core";
2
+
3
+ //#region src/configs/recommended.config.d.ts
4
+ declare const recommended: OxlintRules;
5
+ //#endregion
6
+ export { recommended };
@@ -0,0 +1 @@
1
+ const e={"@longzai-intelligence/schema-type-separation/no-type-in-schema":`off`,"@longzai-intelligence/schema-type-separation/no-schema-in-types":`off`};export{e as recommended};
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});let e=require(`@oxlint/plugins`);const t=new Set(`object.enum.string.number.boolean.array.record.tuple.union.intersection.literal.nativeEnum.any.unknown.void.never.date.bigint.map.set.nan.null.undefined.symbol.coerce.lazy.promise.function.branded.catch.default.describe.nullable.optional.transform.pipe.refine.superRefine.preprocess`.split(`.`));function n(e){return e.endsWith(`.types.ts`)}const r=(0,e.defineRule)({meta:{type:`problem`,docs:{description:`禁止在 *.types.ts 文件中包含 Zod Schema 运行时定义,允许 z.infer 类型推导`}},createOnce(e){return{before(){let t=e.filename;if(!n(t))return!1},CallExpression(n){if(n.callee.type!==`MemberExpression`||n.callee.object.type!==`Identifier`||n.callee.object.name!==`z`||n.callee.property.type!==`Identifier`)return;let r=n.callee.property.name;t.has(r)&&e.report({node:n,message:`*.types.ts 文件不允许包含 Zod Schema 定义。"z.${r}()" 是运行时验证逻辑,应放在 *.schema.ts 文件中。`})},ImportDeclaration(t){if(t.source.value===`zod`&&!(`importKind`in t&&t.importKind===`type`))for(let n of t.specifiers){if(n.type===`ImportNamespaceSpecifier`){e.report({node:t,message:`*.types.ts 文件不允许从 zod 进行值导入。如需引用 Zod 类型,请使用 import type 语法。`});return}if(!(`importKind`in n&&n.importKind===`type`)){e.report({node:t,message:`*.types.ts 文件不允许从 zod 进行值导入。如需引用 Zod 类型,请使用 import type 语法。`});return}}}}}});function i(e){return e.endsWith(`.schema.ts`)}function a(e){if(`id`in e&&e.id!==null&&typeof e.id==`object`&&`name`in e.id&&typeof e.id.name==`string`)return e.id.name}const o=(0,e.defineRule)({meta:{type:`problem`,docs:{description:`禁止在 *.schema.ts 文件中包含任何 type 定义,强制拆分到 *.types.ts 文件`}},createOnce(e){return{before(){let t=e.filename;if(!i(t))return!1},TSTypeAliasDeclaration(t){let n=a(t);e.report({node:t,message:`*.schema.ts 文件不允许包含 type 定义。类型 "${n??`未知类型`}" 应拆分到对应的 *.types.ts 文件中。`})}}}}),s=(0,e.eslintCompatPlugin)({meta:{name:`@longzai-intelligence/schema-type-separation`},rules:{"no-type-in-schema":o,"no-schema-in-types":r}});exports.ZOD_SCHEMA_METHODS=t,exports.default=s,exports.schemaTypeSeparationPlugin=s,exports.isSchemaFile=i,exports.isTypesFile=n,exports.noSchemaInTypesRule=r,exports.noTypeInSchemaRule=o;
@@ -0,0 +1,15 @@
1
+ import * as _$_oxlint_plugins0 from "@oxlint/plugins";
2
+
3
+ //#region src/rules/no-schema-in-types/index.d.ts
4
+ declare const ZOD_SCHEMA_METHODS: Set<string>;
5
+ declare function isTypesFile(filename: string): boolean;
6
+ declare const noSchemaInTypesRule: _$_oxlint_plugins0.Rule;
7
+ //#endregion
8
+ //#region src/rules/no-type-in-schema/index.d.ts
9
+ declare function isSchemaFile(filename: string): boolean;
10
+ declare const noTypeInSchemaRule: _$_oxlint_plugins0.Rule;
11
+ //#endregion
12
+ //#region src/index.d.ts
13
+ declare const schemaTypeSeparationPlugin: _$_oxlint_plugins0.Plugin;
14
+ //#endregion
15
+ export { ZOD_SCHEMA_METHODS, schemaTypeSeparationPlugin as default, schemaTypeSeparationPlugin, isSchemaFile, isTypesFile, noSchemaInTypesRule, noTypeInSchemaRule };
@@ -0,0 +1,15 @@
1
+ import * as _$_oxlint_plugins0 from "@oxlint/plugins";
2
+
3
+ //#region src/rules/no-schema-in-types/index.d.ts
4
+ declare const ZOD_SCHEMA_METHODS: Set<string>;
5
+ declare function isTypesFile(filename: string): boolean;
6
+ declare const noSchemaInTypesRule: _$_oxlint_plugins0.Rule;
7
+ //#endregion
8
+ //#region src/rules/no-type-in-schema/index.d.ts
9
+ declare function isSchemaFile(filename: string): boolean;
10
+ declare const noTypeInSchemaRule: _$_oxlint_plugins0.Rule;
11
+ //#endregion
12
+ //#region src/index.d.ts
13
+ declare const schemaTypeSeparationPlugin: _$_oxlint_plugins0.Plugin;
14
+ //#endregion
15
+ export { ZOD_SCHEMA_METHODS, schemaTypeSeparationPlugin as default, schemaTypeSeparationPlugin, isSchemaFile, isTypesFile, noSchemaInTypesRule, noTypeInSchemaRule };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=new Set(`object.enum.string.number.boolean.array.record.tuple.union.intersection.literal.nativeEnum.any.unknown.void.never.date.bigint.map.set.nan.null.undefined.symbol.coerce.lazy.promise.function.branded.catch.default.describe.nullable.optional.transform.pipe.refine.superRefine.preprocess`.split(`.`));function r(e){return e.endsWith(`.types.ts`)}const i=e({meta:{type:`problem`,docs:{description:`禁止在 *.types.ts 文件中包含 Zod Schema 运行时定义,允许 z.infer 类型推导`}},createOnce(e){return{before(){let t=e.filename;if(!r(t))return!1},CallExpression(t){if(t.callee.type!==`MemberExpression`||t.callee.object.type!==`Identifier`||t.callee.object.name!==`z`||t.callee.property.type!==`Identifier`)return;let r=t.callee.property.name;n.has(r)&&e.report({node:t,message:`*.types.ts 文件不允许包含 Zod Schema 定义。"z.${r}()" 是运行时验证逻辑,应放在 *.schema.ts 文件中。`})},ImportDeclaration(t){if(t.source.value===`zod`&&!(`importKind`in t&&t.importKind===`type`))for(let n of t.specifiers){if(n.type===`ImportNamespaceSpecifier`){e.report({node:t,message:`*.types.ts 文件不允许从 zod 进行值导入。如需引用 Zod 类型,请使用 import type 语法。`});return}if(!(`importKind`in n&&n.importKind===`type`)){e.report({node:t,message:`*.types.ts 文件不允许从 zod 进行值导入。如需引用 Zod 类型,请使用 import type 语法。`});return}}}}}});function a(e){return e.endsWith(`.schema.ts`)}function o(e){if(`id`in e&&e.id!==null&&typeof e.id==`object`&&`name`in e.id&&typeof e.id.name==`string`)return e.id.name}const s=e({meta:{type:`problem`,docs:{description:`禁止在 *.schema.ts 文件中包含任何 type 定义,强制拆分到 *.types.ts 文件`}},createOnce(e){return{before(){let t=e.filename;if(!a(t))return!1},TSTypeAliasDeclaration(t){let n=o(t);e.report({node:t,message:`*.schema.ts 文件不允许包含 type 定义。类型 "${n??`未知类型`}" 应拆分到对应的 *.types.ts 文件中。`})}}}}),c=t({meta:{name:`@longzai-intelligence/schema-type-separation`},rules:{"no-type-in-schema":s,"no-schema-in-types":i}});export{n as ZOD_SCHEMA_METHODS,c as default,c as schemaTypeSeparationPlugin,a as isSchemaFile,r as isTypesFile,i as noSchemaInTypesRule,s as noTypeInSchemaRule};
package/package.json ADDED
@@ -0,0 +1,88 @@
1
+ {
2
+ "name": "@longzai-intelligence/oxlint-plugin-schema-type-separation",
3
+ "version": "0.0.1",
4
+ "license": "UNLICENSED",
5
+ "files": [
6
+ "dist"
7
+ ],
8
+ "type": "module",
9
+ "main": "./dist/index.cjs",
10
+ "module": "./dist/index.mjs",
11
+ "types": "./dist/index.d.mts",
12
+ "exports": {
13
+ ".": {
14
+ "types": {
15
+ "import": "./dist/index.d.mts",
16
+ "require": "./dist/index.d.cts"
17
+ },
18
+ "import": "./dist/index.mjs",
19
+ "require": "./dist/index.cjs"
20
+ },
21
+ "./configs/recommended": {
22
+ "types": {
23
+ "import": "./dist/configs/recommended.d.mts",
24
+ "require": "./dist/configs/recommended.d.cts"
25
+ },
26
+ "import": "./dist/configs/recommended.mjs",
27
+ "require": "./dist/configs/recommended.cjs"
28
+ }
29
+ },
30
+ "scripts": {
31
+ "build": "tsdown",
32
+ "build:prod": "NODE_ENV=production tsdown",
33
+ "prepublishOnly": "bun run build:prod",
34
+ "dev": "tsdown --watch",
35
+ "clean": "rimraf dist",
36
+ "test": "vitest run",
37
+ "test:watch": "vitest",
38
+ "test:coverage": "vitest run --coverage",
39
+ "lint": "bun run lint:oxlint",
40
+ "lint:oxlint": "oxlint",
41
+ "lint:eslint": "eslint .",
42
+ "lint:fix": "bun run oxc:fix",
43
+ "lint:fix:oxlint": "oxlint --fix",
44
+ "lint:fix:eslint": "eslint . --fix",
45
+ "typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
46
+ "typecheck:app": "tsc --noEmit -p tsconfig/app.json",
47
+ "typecheck:node": "tsc --noEmit -p tsconfig/node.json",
48
+ "typecheck:test": "tsc --noEmit -p tsconfig/test.json",
49
+ "lint:file": "bun run lint:file:oxlint",
50
+ "lint:file:oxlint": "oxlint",
51
+ "lint:file:eslint": "eslint",
52
+ "fmt": "oxfmt",
53
+ "fmt:check": "oxfmt --check",
54
+ "oxc": "bun run lint:oxlint && bun run fmt:check",
55
+ "oxc:fix": "bun run lint:fix:oxlint && bun run fmt"
56
+ },
57
+ "dependencies": {
58
+ "@longzai-intelligence/oxlint-core": "0.0.1",
59
+ "@oxlint/plugins": "^1.64.0"
60
+ },
61
+ "devDependencies": {
62
+ "@longzai-intelligence/eslint-preset-library": "0.2.13",
63
+ "@longzai-intelligence/oxlint-config": "0.0.1",
64
+ "@longzai-intelligence/oxlint-plugin-architecture": "0.0.1",
65
+ "@longzai-intelligence/oxlint-plugin-code-style": "0.0.1",
66
+ "@longzai-intelligence/oxlint-plugin-package-json": "0.0.1",
67
+ "@longzai-intelligence/oxlint-plugin-perfectionist": "0.0.1",
68
+ "@longzai-intelligence/oxlint-plugin-schema-type-separation": "0.0.1",
69
+ "@longzai-intelligence/oxlint-plugin-stylistic": "0.0.1",
70
+ "@longzai-intelligence/oxlint-plugin-tsdoc": "0.0.1",
71
+ "@longzai-intelligence/oxlint-plugin-typescript-eslint": "0.0.1",
72
+ "@longzai-intelligence/oxlint-plugin-zod": "0.0.1",
73
+ "@longzai-intelligence/oxlint-testing": "0.0.1",
74
+ "@longzai-intelligence/oxlint-utils": "0.0.1",
75
+ "@longzai-intelligence/tsdown-config": "0.0.1",
76
+ "@longzai-intelligence/typescript-config": "0.0.3",
77
+ "@longzai-intelligence/vitest-config": "0.0.10",
78
+ "@types/node": "^25.7.0",
79
+ "oxlint": "^1.64.0",
80
+ "rimraf": "^6.1.3",
81
+ "tsdown": "^0.21.10",
82
+ "typescript": "^6.0.3",
83
+ "vitest": "^4.1.6"
84
+ },
85
+ "peerDependencies": {
86
+ "oxlint": ">=1.0.0"
87
+ }
88
+ }