@longzai-intelligence-oxlint/schema-type-separation-plugin 0.1.35 → 0.1.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.js +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=/* @__PURE__ */ new Set(/* @__PURE__ */ `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)
|
|
1
|
+
import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=/* @__PURE__ */ new Set(/* @__PURE__ */ `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`||!(`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-oxlint/schema-type-separation-plugin`},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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-oxlint/schema-type-separation-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"description": "Longzai Intelligence oxlint schema 与类型分离规则插件",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"longzai-intelligence",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"typecheck:test": "lzi-tsgo typecheck tsconfig/test.json"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@longzai-intelligence-oxlint/core": "0.1.
|
|
46
|
+
"@longzai-intelligence-oxlint/core": "0.1.37",
|
|
47
47
|
"@oxlint/plugins": "^1.74.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|