@longzai-intelligence-oxlint/presets 0.2.31 → 0.2.32
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/{base.entry-ihV3q_2I.js → base.entry-Dap4Z6h_.js} +1 -1
- package/dist/base.js +1 -1
- package/dist/{dist-CskvMq7J.js → dist-DVSw2KvF.js} +1 -1
- package/dist/{e2e-playwright.entry-Ct1Rlhhz.js → e2e-playwright.entry-_NlwoSgs.js} +1 -1
- package/dist/e2e-playwright.js +1 -1
- package/dist/{e2e.entry-BovadSvn.js → e2e.entry-BIUjOKup.js} +1 -1
- package/dist/e2e.js +1 -1
- package/dist/{electron.entry-DUsDae4u.js → electron.entry-BQ3oiPKs.js} +1 -1
- package/dist/electron.js +1 -1
- package/dist/elysia.js +1 -1
- package/dist/expo.js +1 -1
- package/dist/{fumadocs.entry-CbNS_gTP.js → fumadocs.entry-CVCOLNvS.js} +1 -1
- package/dist/fumadocs.js +1 -1
- package/dist/hono.js +1 -1
- package/dist/index.js +1 -1
- package/dist/library.js +1 -1
- package/dist/mcp.js +1 -1
- package/dist/{nest.entry-esm5OFt2.js → nest.entry-CLJU3uZd.js} +1 -1
- package/dist/nest.js +1 -1
- package/dist/{next.entry-9WqH5pU4.js → next.entry-DGuXCWMY.js} +1 -1
- package/dist/next.js +1 -1
- package/dist/node.js +1 -1
- package/dist/plugins/architecture-core.js +1 -1
- package/dist/plugins/architecture-electron.js +1 -1
- package/dist/plugins/architecture-library.js +1 -1
- package/dist/plugins/code-style.js +1 -1
- package/dist/plugins/file-naming.js +1 -1
- package/dist/plugins/lzi-builder-config.js +1 -1
- package/dist/plugins/lzi-config.js +1 -1
- package/dist/plugins/package-json.js +1 -1
- package/dist/plugins/schema-type-separation.js +1 -1
- package/dist/plugins/stylistic.js +7 -7
- package/dist/plugins/tsdoc.js +2 -2
- package/dist/{react-native.entry-D2Dj46b7.js → react-native.entry-CRBcPvfA.js} +1 -1
- package/dist/react-native.js +1 -1
- package/dist/react.js +1 -1
- package/dist/{root.entry-DgJMQCn5.js → root.entry-DUE5WDMN.js} +1 -1
- package/dist/root.js +1 -1
- package/dist/{sdk.entry-DpBT2LZv.js → sdk.entry-CZjdN7jn.js} +1 -1
- package/dist/sdk.js +1 -1
- package/dist/{taro.entry-BMIixeDL.js → taro.entry-BbKrVHru.js} +1 -1
- package/dist/taro.js +1 -1
- package/dist/ui-application.js +1 -1
- package/dist/ui-base.js +1 -1
- package/dist/ui-library.js +1 -1
- package/package.json +28 -28
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../rolldown-runtime-BqT_7tdF.js";import"../rolldown-runtime-BqT_7tdF-BqT_7tdF.js";import{n as e,r as t,t as n}from"../dist-CskvMq7J.js";import{defineRule as r,eslintCompatPlugin as i}from"@oxlint/plugins";import{existsSync as a,readFileSync as ee}from"node:fs";import{dirname as o,join as te}from"node:path";import*as s from"zod/mini";function c(e){return e.endsWith(`Class`)}const l=r({meta:{type:`problem`,docs:{description:`禁止在 import 别名中使用 "Class" 后缀`}},createOnce(e){return{ImportSpecifier(t){let n=t.local.name,r=t.imported.type===`Identifier`?t.imported.name:n;n!==r&&c(n)&&e.report({node:t,message:`导入别名 "${n}" 使用了 "Class" 后缀,这是不允许的命名方式。请使用更具描述性的名称,或直接使用原始名称 "${r}"`})}}}}),u=/* @__PURE__ */ new Set([`console.log`,`console.warn`,`console.error`,`console.info`,`console.debug`,`console.trace`,`console.dir`,`console.table`]);function d(e){let t=e.callee;return t.type===`Identifier`?t.name:t.type===`MemberExpression`&&t.property.type===`Identifier`&&t.object.type===`Identifier`?`${t.object.name}.${t.property.name}`:null}const f=r({meta:{type:`problem`,docs:{description:`禁止使用 console 方法,必须使用 @longzai-intelligence/logger-preset-* 或 react-devtools(ADR 0038)`}},createOnce(e){return{CallExpression(t){if(t.type!==`CallExpression`)return;let n=d(t);n&&u.has(n)&&e.report({node:t,message:`检测到 '${n}' — 必须使用 @longzai-intelligence/logger-preset-* 代替(ADR 0038)`})}}}}),p=/\/src\/(index|main|cli)\.(ts|mts|cts)$/,m=/(^|\/)dist\//;function ne(e){return e.replace(/\\/g,`/`)}function h(e){return typeof e==`object`&&!!e}function re(e){return e.startsWith(`#!`)}function g(e){return p.test(ne(e))}function ie(e){let t=e;for(let e=0;e<4;e+=1){let e=te(t,`package.json`);if(a(e))try{let t=JSON.parse(ee(e,`utf8`));return h(t)?t:null}catch{return null}let n=o(t);if(n===t)break;t=n}return null}function ae(e){let t=e.bin;return(typeof t==`string`?[t]:h(t)?Object.values(t).filter(e=>typeof e==`string`):[]).some(e=>m.test(e.replace(/^\.\//,``)))}const oe={noHandwrittenShebang:`入口源码手写 shebang 属被裁定的错误方式,bin 产物首行 shebang 应由 "lzi-builder.config.ts" 的 banner 在构建期注入。请删除源码首行的 "#!" 行并补 banner 配置。`},_=r({meta:{type:`problem`,docs:{description:`禁止所属包 bin 指向 dist 产物的入口源码手写 shebang`}},createOnce(e){return{before(){let t=e.filename;if(!g(t))return!1},Program(t){let n=e.sourceCode.text;if(!re(n))return;let r=ie(o(o(e.filename)));r!==null&&ae(r)&&e.report({node:t,message:oe.noHandwrittenShebang})}}}}),v=s.object({type:s.literal(`TSTypeLiteral`)}),y=s.object({type:s.literal(`TSFunctionType`)}),b=s.object({type:s.literal(`TSUnionType`),types:s.array(s.unknown())}),se=s.object({type:s.literal(`TSIntersectionType`),types:s.array(s.unknown())}),ce=s.object({type:s.literal(`Identifier`),name:s.string()}),le=s.object({type:s.literal(`RestElement`),argument:s.object({name:s.string()})}),ue=s.union([ce,le]),x=s.object({typeAnnotation:s.unknown()}),de=s.object({type:s.literal(`MethodDefinition`),key:s.object({type:s.string(),name:s.optional(s.string())}),value:s.object({params:s.optional(s.array(s.unknown())),returnType:s.optional(s.union([x,s.null()]))}),kind:s.enum([`method`,`constructor`,`get`,`set`])}),fe=s.object({returnType:x}),pe=s.object({id:s.optional(s.object({name:s.optional(s.string())})),params:s.optional(s.array(s.unknown())),returnType:s.optional(s.unknown())}),me=s.object({params:s.optional(s.array(s.unknown()))});function S(e){return v.safeParse(e).success}function C(e){return y.safeParse(e).success}function w(e){return b.safeParse(e).success}function T(e){return se.safeParse(e).success}function E(e){return ue.safeParse(e).success}function D(e){if(typeof e!=`object`||!e||!(`type`in e))return!1;let t=[`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`],n=e.type;return typeof n==`string`&&t.includes(n)}function O(e){return de.safeParse(e).success}function k(e){return fe.safeParse(e).success}function A(e){return pe.safeParse(e).success}function j(e){return me.safeParse(e).success}function M(e){return S(e)||C(e)?!0:w(e)||T(e)?e.types.some(M):!1}function N(e){return S(e)?`对象类型`:C(e)?`函数类型`:`内联类型`}function P(e){return E(e)?e.type===`Identifier`?e.name:e.type===`RestElement`?e.argument.name:null:null}function F(e,t,n,r,i,a){i?e.report({node:t,message:`参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`}):a?e.report({node:t,message:`方法 "${a}" 的参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`}):e.report({node:t,message:`参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`})}function I(e,t,n,r,i){i?e.report({node:t,message:`方法 "${i}" 的返回值使用了内联${n}定义。请将其提取为具名的 type。`}):r?e.report({node:t,message:`函数 "${r}" 的返回值使用了内联${n}定义。请将其提取为具名的 type。`}):e.report({node:t,message:`匿名函数的返回值使用了内联${n}定义。请将其提取为具名的 type。`})}function L(e,t,n,r,i){if(typeof e!=`object`||!e||!(`typeAnnotation`in e)||e.typeAnnotation===null||typeof e.typeAnnotation!=`object`||!(`typeAnnotation`in e.typeAnnotation))return;let a=e.typeAnnotation.typeAnnotation;M(a)&&F(t,n,P(e)??`未知参数`,N(a),r,i)}function R(e,t,n,r,i){for(let a of e)L(a,t,n,i??!1,r)}function z(e,t,n,r,i){if(typeof e!=`object`||!e||!(`typeAnnotation`in e))return;let a=e.typeAnnotation;M(a)&&I(t,n,N(a),r,i)}function B(e,t){if(!D(e)||!A(e))return;let n=null;`id`in e&&e.id!==null&&typeof e.id==`object`&&`name`in e.id&&typeof e.id.name==`string`&&(n=e.id.name),j(e)&&R(e.params??[],t,e),k(e)&&z(e.returnType,t,e,n??void 0)}function he(e,t){D(e)&&j(e)&&(j(e)&&R(e.params??[],t,e),k(e)&&z(e.returnType,t,e))}function ge(e,t){if(!O(e))return;let n=e.key,r=n&&`name`in n&&typeof n.name==`string`?n.name:`未知方法`,i=e.value;if(i&&`params`in i&&Array.isArray(i.params)&&R(i.params,t,e,r,e.kind===`constructor`),i&&`returnType`in i&&i.returnType&&typeof i.returnType==`object`&&`typeAnnotation`in i.returnType){let n=i.returnType;z(n,t,e,void 0,r)}}const V=r({meta:{type:`suggestion`,docs:{description:`禁止在函数参数和返回值中使用内联类型定义,强制使用具名类型`}},createOnce(e){return{FunctionDeclaration(t){B(t,e)},FunctionExpression(t){B(t,e)},ArrowFunctionExpression(t){he(t,e)},MethodDefinition(t){ge(t,e)}}}}),H=/^(?:eslint-disable(?:-next-line|-line)?|eslint-enable|oxlint-disable(?:-next-line|-line)?|oxlint-enable|biome-ignore|stylelint-disable(?:-next-line|-line)?|stylelint-enable|@ts-ignore|@ts-nocheck)(?=[\s,]|$)/;function _e(e){let t=e.trimStart();return H.exec(t)?.[0]??null}const U=r({meta:{type:`problem`,docs:{description:`禁止 eslint-disable、oxlint-disable、biome-ignore、stylelint-disable、@ts-ignore、@ts-nocheck 等抑制注释`}},createOnce(e){return{Program(){let t=e.sourceCode.getAllComments();for(let n of t){if(n.type===`Shebang`)continue;let t=_e(n.value);t!==null&&e.report({node:n,message:`检测到抑制指令 ${t},抑制注释不是合法豁免手段,请从源头消除违例或在包级 oxlint.config.ts 的 ignorePatterns 登记路径豁免`})}}}}});function ve(e){let t=[];if(e.type===`Identifier`&&t.push(e.name),e.type===`ObjectPattern`)for(let n of e.properties)n.type===`Property`&&`value`in n?n.value.type===`Identifier`&&t.push(n.value.name):n.type===`RestElement`&&n.argument.type===`Identifier`&&t.push(n.argument.name);if(e.type===`ArrayPattern`)for(let n of e.elements)n&&n.type===`Identifier`&&t.push(n.name);return t}const W=r({meta:{type:`suggestion`,docs:{description:`将 export const/let/var 拆分为独立的声明和导出语句`}},createOnce(e){return{ExportNamedDeclaration(t){if(!t.declaration||t.declaration.type!==`VariableDeclaration`)return;let n=t.declaration;if(n.kind!==`const`&&n.kind!==`let`&&n.kind!==`var`||n.declarations.length===0)return;let r=[];for(let e of n.declarations)r.push(...ve(e.id));r.length!==0&&e.report({node:t,message:`应将 \`export ${n.kind} ${r.join(`, `)}\` 拆分为独立的声明和导出语句`})}}}}),G=[{suffix:`.service.drizzle.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.memory.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.controller.ts`,classSuffix:`Controller`,isInterface:!1,isPrefix:!1},{suffix:`.module.ts`,classSuffix:`Module`,isInterface:!1,isPrefix:!1},{suffix:`.repository.drizzle.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.memory.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.interface.ts`,classSuffix:`Repository`,isInterface:!0,isPrefix:!0},{suffix:`.repository.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.entity.ts`,classSuffix:`Entity`,isInterface:!1,isPrefix:!1},{suffix:`.orm-entity.ts`,classSuffix:`OrmEntity`,isInterface:!1,isPrefix:!1},{suffix:`.dto.ts`,classSuffix:`DTO`,isInterface:!1,isPrefix:!1},{suffix:`.port.interface.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!0},{suffix:`.interface.ts`,classSuffix:``,isInterface:!0,isPrefix:!0},{suffix:`.port.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!1},{suffix:`.port.adapter.ts`,classSuffix:`PortAdapter`,isInterface:!1,isPrefix:!1},{suffix:`.adapter.ts`,classSuffix:`Adapter`,isInterface:!1,isPrefix:!1},{suffix:`.events.ts`,classSuffix:`Event`,isInterface:!1,isPrefix:!1},{suffix:`.mapper.ts`,classSuffix:`Mapper`,isInterface:!1,isPrefix:!1},{suffix:`.vo.ts`,classSuffix:`VO`,isInterface:!1,isPrefix:!1},{suffix:`.usecase.ts`,classSuffix:`UseCase`,isInterface:!1,isPrefix:!1},{suffix:`.errors.ts`,classSuffix:`Error`,isInterface:!1,isPrefix:!1}];function K(e){for(let t of G)if(e.endsWith(t.suffix))return t;return null}function q(e,t){if(t.isPrefix&&t.isInterface){if(t.classSuffix){let n=t.classSuffix;return e.startsWith(`I`)&&e.endsWith(n)&&e.length>1+n.length}return e.startsWith(`I`)&&e.length>1}return t.isPrefix?e.startsWith(`I`)&&e.length>1:e.endsWith(t.classSuffix)&&e.length>t.classSuffix.length}function J(e){return e.isPrefix&&e.isInterface?e.classSuffix?`I${e.classSuffix}(如 IUser${e.classSuffix})`:`I 前缀(如 IUser)`:e.isPrefix?`I 前缀(如 IUser)`:`${e.classSuffix} 后缀`}const Y=r({meta:{type:`problem`,docs:{description:`强制执行类名与文件类型后缀的一致性`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||!K(t))return!1},ClassDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=K(n);if(!r||r.isInterface||!t.id)return;let i=t.id.name;q(i,r)||e.report({node:t,message:`类名 "${i}" 不符合命名规范。文件 "${n}" 中的类应使用 ${J(r)}`})},TSInterfaceDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=K(n);if(!r||!r.isInterface)return;let i=t.id.name;q(i,r)||e.report({node:t,message:`接口名 "${i}" 不符合命名规范。文件 "${n}" 中的接口应使用 ${J(r)}`})}}}});function X(e){return e.endsWith(`.dto.ts`)}function ye(e){return e.endsWith(`DTO`)}const Z=r({meta:{type:`problem`,docs:{description:`强制执行 DTO 文件中的接口命名规范(Dto 后缀,驼峰式)`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||!X(t))return!1},TSInterfaceDeclaration(n){let r=n.id.name;ye(r)?e.report({node:n,message:`接口名 "${r}" 后缀应使用 Dto(驼峰式)而非 DTO(全大写)`}):t(r)||e.report({node:n,message:`DTO 文件中的接口名 "${r}" 应以 Dto 结尾(如 UserResponseDto)`})}}}}),be=[`types.ts`,`types.d.ts`],xe=[`.port.interface.ts`,`.repository.interface.ts`,`.types.ts`,`.types.d.ts`,`.events.ts`,`.d.ts`];function Se(t,r){return e(t)?!1:!r.endsWith(`.dto.ts`)||n(t)}function Ce(e){return e.endsWith(`.dto.ts`)?`DTO 后缀(如 UserDTO),禁止 I 前缀`:`PascalCase(如 User、UserRepository),禁止 I 前缀`}function we(e){if(be.includes(e))return!0;for(let t of xe)if(e.endsWith(t))return!0;return!1}function Te(e){return e.endsWith(`.port.ts`)?e.replace(`.port.ts`,`.port.interface.ts`):e.endsWith(`.repository.ts`)?e.replace(`.repository.ts`,`.repository.interface.ts`):e.replace(`.ts`,`.interface.ts`)}const Q=r({meta:{type:`problem`,docs:{description:`强制执行接口命名规范(禁止 I 前缀,使用 PascalCase)和文件命名规范`}},createOnce(t){return{before(){let e=t.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(e.endsWith(`.test.ts`)||e.endsWith(`.spec.ts`)||we(e))return!1},TSInterfaceDeclaration(n){let r=t.filename.replace(/\\/g,`/`).split(`/`).pop()??``,i=r.endsWith(`.interface.ts`)||r.endsWith(`.interface.tsx`),a=n.id.name;Se(a,r)||(e(a)?t.report({node:n,message:`接口名 "${a}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "${a.substring(1)}"`}):r.endsWith(`.dto.ts`)&&a.endsWith(`Dto`)?t.report({node:n,message:`接口名 "${a}" 后缀应使用 DTO(全大写)而非 Dto(驼峰式)`}):t.report({node:n,message:`接口名 "${a}" 不符合命名规范。接口名应使用 ${Ce(r)}`})),i||r.endsWith(`.dto.ts`)||r.endsWith(`.tsx`)||t.report({node:n,message:`包含接口 "${a}" 的文件 "${r}" 应命名为 "${Te(r)}"`})}}}}),$=i({meta:{name:`@longzai-intelligence-oxlint/code-style-plugin`},rules:{"no-console":f,"no-inline-type-definition":V,"prefer-split-export-const":W,"require-interface-naming":Q,"require-dto-naming":Z,"require-class-suffix":Y,"no-class-suffix-alias":l,"no-handwritten-shebang":_,"no-lint-suppression":U}});export{G as SUFFIX_MAPPINGS,$ as codeStylePlugin,$ as default,N as getInlineTypeDescription,P as getParamName,e as hasIPrefix,M as hasInlineType,X as isDtoFile,D as isFunctionNode,O as isMethodDefinition,C as isTSFunctionType,T as isTSIntersectionType,S as isTSTypeLiteral,w as isTSUnionType,l as noClassSuffixAliasRule,f as noConsoleRule,_ as noHandwrittenShebangRule,V as noInlineTypeDefinitionRule,U as noLintSuppressionRule,W as preferSplitExportConstRule,Y as requireClassSuffixRule,Z as requireDtoNamingRule,Q as requireInterfaceNamingRule};
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import"../rolldown-runtime-BqT_7tdF-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import{existsSync as n,readFileSync as r}from"node:fs";import{dirname as i,join as a}from"node:path";import*as o from"zod/mini";import{n as s,r as ee,t as te}from"../dist-DVSw2KvF.js";function c(e){return e.endsWith(`Class`)}const l=e({meta:{type:`problem`,docs:{description:`禁止在 import 别名中使用 "Class" 后缀`}},createOnce(e){return{ImportSpecifier(t){let n=t.local.name,r=t.imported.type===`Identifier`?t.imported.name:n;n!==r&&c(n)&&e.report({node:t,message:`导入别名 "${n}" 使用了 "Class" 后缀,这是不允许的命名方式。请使用更具描述性的名称,或直接使用原始名称 "${r}"`})}}}}),u=/* @__PURE__ */ new Set([`console.log`,`console.warn`,`console.error`,`console.info`,`console.debug`,`console.trace`,`console.dir`,`console.table`]);function d(e){let t=e.callee;return t.type===`Identifier`?t.name:t.type===`MemberExpression`&&t.property.type===`Identifier`&&t.object.type===`Identifier`?`${t.object.name}.${t.property.name}`:null}const f=e({meta:{type:`problem`,docs:{description:`禁止使用 console 方法,必须使用 @longzai-intelligence/logger-preset-* 或 react-devtools(ADR 0038)`}},createOnce(e){return{CallExpression(t){if(t.type!==`CallExpression`)return;let n=d(t);n&&u.has(n)&&e.report({node:t,message:`检测到 '${n}' — 必须使用 @longzai-intelligence/logger-preset-* 代替(ADR 0038)`})}}}}),p=/\/src\/(index|main|cli)\.(ts|mts|cts)$/,m=/(^|\/)dist\//;function ne(e){return e.replace(/\\/g,`/`)}function h(e){return typeof e==`object`&&!!e}function re(e){return e.startsWith(`#!`)}function g(e){return p.test(ne(e))}function ie(e){let t=e;for(let e=0;e<4;e+=1){let e=a(t,`package.json`);if(n(e))try{let t=JSON.parse(r(e,`utf8`));return h(t)?t:null}catch{return null}let o=i(t);if(o===t)break;t=o}return null}function ae(e){let t=e.bin;return(typeof t==`string`?[t]:h(t)?Object.values(t).filter(e=>typeof e==`string`):[]).some(e=>m.test(e.replace(/^\.\//,``)))}const oe={noHandwrittenShebang:`入口源码手写 shebang 属被裁定的错误方式,bin 产物首行 shebang 应由 "lzi-builder.config.ts" 的 banner 在构建期注入。请删除源码首行的 "#!" 行并补 banner 配置。`},_=e({meta:{type:`problem`,docs:{description:`禁止所属包 bin 指向 dist 产物的入口源码手写 shebang`}},createOnce(e){return{before(){if(!g(e.filename))return!1},Program(t){if(!re(e.sourceCode.text))return;let n=ie(i(i(e.filename)));n!==null&&ae(n)&&e.report({node:t,message:oe.noHandwrittenShebang})}}}}),v=o.object({type:o.literal(`TSTypeLiteral`)}),y=o.object({type:o.literal(`TSFunctionType`)}),b=o.object({type:o.literal(`TSUnionType`),types:o.array(o.unknown())}),se=o.object({type:o.literal(`TSIntersectionType`),types:o.array(o.unknown())}),ce=o.object({type:o.literal(`Identifier`),name:o.string()}),le=o.object({type:o.literal(`RestElement`),argument:o.object({name:o.string()})}),ue=o.union([ce,le]),x=o.object({typeAnnotation:o.unknown()}),de=o.object({type:o.literal(`MethodDefinition`),key:o.object({type:o.string(),name:o.optional(o.string())}),value:o.object({params:o.optional(o.array(o.unknown())),returnType:o.optional(o.union([x,o.null()]))}),kind:o.enum([`method`,`constructor`,`get`,`set`])}),fe=o.object({returnType:x}),pe=o.object({id:o.optional(o.object({name:o.optional(o.string())})),params:o.optional(o.array(o.unknown())),returnType:o.optional(o.unknown())}),me=o.object({params:o.optional(o.array(o.unknown()))});function S(e){return v.safeParse(e).success}function C(e){return y.safeParse(e).success}function w(e){return b.safeParse(e).success}function T(e){return se.safeParse(e).success}function E(e){return ue.safeParse(e).success}function D(e){if(typeof e!=`object`||!e||!(`type`in e))return!1;let t=[`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`MethodDefinition`],n=e.type;return typeof n==`string`&&t.includes(n)}function O(e){return de.safeParse(e).success}function k(e){return fe.safeParse(e).success}function A(e){return pe.safeParse(e).success}function j(e){return me.safeParse(e).success}function M(e){return S(e)||C(e)?!0:w(e)||T(e)?e.types.some(M):!1}function N(e){return S(e)?`对象类型`:C(e)?`函数类型`:`内联类型`}function P(e){return E(e)?e.type===`Identifier`?e.name:e.type===`RestElement`?e.argument.name:null:null}function F(e,t,n,r,i,a){i?e.report({node:t,message:`参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`}):a?e.report({node:t,message:`方法 "${a}" 的参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`}):e.report({node:t,message:`参数 "${n}" 使用了内联${r}定义。请将其提取为具名的 type。`})}function I(e,t,n,r,i){i?e.report({node:t,message:`方法 "${i}" 的返回值使用了内联${n}定义。请将其提取为具名的 type。`}):r?e.report({node:t,message:`函数 "${r}" 的返回值使用了内联${n}定义。请将其提取为具名的 type。`}):e.report({node:t,message:`匿名函数的返回值使用了内联${n}定义。请将其提取为具名的 type。`})}function L(e,t,n,r,i){if(typeof e!=`object`||!e||!(`typeAnnotation`in e)||e.typeAnnotation===null||typeof e.typeAnnotation!=`object`||!(`typeAnnotation`in e.typeAnnotation))return;let a=e.typeAnnotation.typeAnnotation;M(a)&&F(t,n,P(e)??`未知参数`,N(a),r,i)}function R(e,t,n,r,i){for(let a of e)L(a,t,n,i??!1,r)}function z(e,t,n,r,i){if(typeof e!=`object`||!e||!(`typeAnnotation`in e))return;let a=e.typeAnnotation;M(a)&&I(t,n,N(a),r,i)}function B(e,t){if(!D(e)||!A(e))return;let n=null;`id`in e&&e.id!==null&&typeof e.id==`object`&&`name`in e.id&&typeof e.id.name==`string`&&(n=e.id.name),j(e)&&R(e.params??[],t,e),k(e)&&z(e.returnType,t,e,n??void 0)}function he(e,t){D(e)&&j(e)&&(j(e)&&R(e.params??[],t,e),k(e)&&z(e.returnType,t,e))}function ge(e,t){if(!O(e))return;let n=e.key,r=n&&`name`in n&&typeof n.name==`string`?n.name:`未知方法`,i=e.value;i&&`params`in i&&Array.isArray(i.params)&&R(i.params,t,e,r,e.kind===`constructor`),i&&`returnType`in i&&i.returnType&&typeof i.returnType==`object`&&`typeAnnotation`in i.returnType&&z(i.returnType,t,e,void 0,r)}const V=e({meta:{type:`suggestion`,docs:{description:`禁止在函数参数和返回值中使用内联类型定义,强制使用具名类型`}},createOnce(e){return{FunctionDeclaration(t){B(t,e)},FunctionExpression(t){B(t,e)},ArrowFunctionExpression(t){he(t,e)},MethodDefinition(t){ge(t,e)}}}}),H=/^(?:eslint-disable(?:-next-line|-line)?|eslint-enable|oxlint-disable(?:-next-line|-line)?|oxlint-enable|biome-ignore|stylelint-disable(?:-next-line|-line)?|stylelint-enable|@ts-ignore|@ts-nocheck)(?=[\s,]|$)/;function _e(e){let t=e.trimStart();return H.exec(t)?.[0]??null}const U=e({meta:{type:`problem`,docs:{description:`禁止 eslint-disable、oxlint-disable、biome-ignore、stylelint-disable、@ts-ignore、@ts-nocheck 等抑制注释`}},createOnce(e){return{Program(){let t=e.sourceCode.getAllComments();for(let n of t){if(n.type===`Shebang`)continue;let t=_e(n.value);t!==null&&e.report({node:n,message:`检测到抑制指令 ${t},抑制注释不是合法豁免手段,请从源头消除违例或在包级 oxlint.config.ts 的 ignorePatterns 登记路径豁免`})}}}}});function ve(e){let t=[];if(e.type===`Identifier`&&t.push(e.name),e.type===`ObjectPattern`)for(let n of e.properties)n.type===`Property`&&`value`in n?n.value.type===`Identifier`&&t.push(n.value.name):n.type===`RestElement`&&n.argument.type===`Identifier`&&t.push(n.argument.name);if(e.type===`ArrayPattern`)for(let n of e.elements)n&&n.type===`Identifier`&&t.push(n.name);return t}const W=e({meta:{type:`suggestion`,docs:{description:`将 export const/let/var 拆分为独立的声明和导出语句`}},createOnce(e){return{ExportNamedDeclaration(t){if(!t.declaration||t.declaration.type!==`VariableDeclaration`)return;let n=t.declaration;if(n.kind!==`const`&&n.kind!==`let`&&n.kind!==`var`||n.declarations.length===0)return;let r=[];for(let e of n.declarations)r.push(...ve(e.id));r.length!==0&&e.report({node:t,message:`应将 \`export ${n.kind} ${r.join(`, `)}\` 拆分为独立的声明和导出语句`})}}}}),G=[{suffix:`.service.drizzle.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.memory.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.service.ts`,classSuffix:`Service`,isInterface:!1,isPrefix:!1},{suffix:`.controller.ts`,classSuffix:`Controller`,isInterface:!1,isPrefix:!1},{suffix:`.module.ts`,classSuffix:`Module`,isInterface:!1,isPrefix:!1},{suffix:`.repository.drizzle.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.memory.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.repository.interface.ts`,classSuffix:`Repository`,isInterface:!0,isPrefix:!0},{suffix:`.repository.ts`,classSuffix:`Repository`,isInterface:!1,isPrefix:!1},{suffix:`.entity.ts`,classSuffix:`Entity`,isInterface:!1,isPrefix:!1},{suffix:`.orm-entity.ts`,classSuffix:`OrmEntity`,isInterface:!1,isPrefix:!1},{suffix:`.dto.ts`,classSuffix:`DTO`,isInterface:!1,isPrefix:!1},{suffix:`.port.interface.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!0},{suffix:`.interface.ts`,classSuffix:``,isInterface:!0,isPrefix:!0},{suffix:`.port.ts`,classSuffix:`Port`,isInterface:!0,isPrefix:!1},{suffix:`.port.adapter.ts`,classSuffix:`PortAdapter`,isInterface:!1,isPrefix:!1},{suffix:`.adapter.ts`,classSuffix:`Adapter`,isInterface:!1,isPrefix:!1},{suffix:`.events.ts`,classSuffix:`Event`,isInterface:!1,isPrefix:!1},{suffix:`.mapper.ts`,classSuffix:`Mapper`,isInterface:!1,isPrefix:!1},{suffix:`.vo.ts`,classSuffix:`VO`,isInterface:!1,isPrefix:!1},{suffix:`.usecase.ts`,classSuffix:`UseCase`,isInterface:!1,isPrefix:!1},{suffix:`.errors.ts`,classSuffix:`Error`,isInterface:!1,isPrefix:!1}];function K(e){for(let t of G)if(e.endsWith(t.suffix))return t;return null}function q(e,t){if(t.isPrefix&&t.isInterface){if(t.classSuffix){let n=t.classSuffix;return e.startsWith(`I`)&&e.endsWith(n)&&e.length>1+n.length}return e.startsWith(`I`)&&e.length>1}return t.isPrefix?e.startsWith(`I`)&&e.length>1:e.endsWith(t.classSuffix)&&e.length>t.classSuffix.length}function J(e){return e.isPrefix&&e.isInterface?e.classSuffix?`I${e.classSuffix}(如 IUser${e.classSuffix})`:`I 前缀(如 IUser)`:e.isPrefix?`I 前缀(如 IUser)`:`${e.classSuffix} 后缀`}const Y=e({meta:{type:`problem`,docs:{description:`强制执行类名与文件类型后缀的一致性`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||!K(t))return!1},ClassDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=K(n);if(!r||r.isInterface||!t.id)return;let i=t.id.name;q(i,r)||e.report({node:t,message:`类名 "${i}" 不符合命名规范。文件 "${n}" 中的类应使用 ${J(r)}`})},TSInterfaceDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=K(n);if(!r||!r.isInterface)return;let i=t.id.name;q(i,r)||e.report({node:t,message:`接口名 "${i}" 不符合命名规范。文件 "${n}" 中的接口应使用 ${J(r)}`})}}}});function X(e){return e.endsWith(`.dto.ts`)}function ye(e){return e.endsWith(`DTO`)}const Z=e({meta:{type:`problem`,docs:{description:`强制执行 DTO 文件中的接口命名规范(Dto 后缀,驼峰式)`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||!X(t))return!1},TSInterfaceDeclaration(t){let n=t.id.name;ye(n)?e.report({node:t,message:`接口名 "${n}" 后缀应使用 Dto(驼峰式)而非 DTO(全大写)`}):ee(n)||e.report({node:t,message:`DTO 文件中的接口名 "${n}" 应以 Dto 结尾(如 UserResponseDto)`})}}}}),be=[`types.ts`,`types.d.ts`],xe=[`.port.interface.ts`,`.repository.interface.ts`,`.types.ts`,`.types.d.ts`,`.events.ts`,`.d.ts`];function Se(e,t){return s(e)?!1:!t.endsWith(`.dto.ts`)||te(e)}function Ce(e){return e.endsWith(`.dto.ts`)?`DTO 后缀(如 UserDTO),禁止 I 前缀`:`PascalCase(如 User、UserRepository),禁止 I 前缀`}function we(e){if(be.includes(e))return!0;for(let t of xe)if(e.endsWith(t))return!0;return!1}function Te(e){return e.endsWith(`.port.ts`)?e.replace(`.port.ts`,`.port.interface.ts`):e.endsWith(`.repository.ts`)?e.replace(`.repository.ts`,`.repository.interface.ts`):e.replace(`.ts`,`.interface.ts`)}const Q=e({meta:{type:`problem`,docs:{description:`强制执行接口命名规范(禁止 I 前缀,使用 PascalCase)和文件命名规范`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||we(t))return!1},TSInterfaceDeclaration(t){let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=n.endsWith(`.interface.ts`)||n.endsWith(`.interface.tsx`),i=t.id.name;Se(i,n)||(s(i)?e.report({node:t,message:`接口名 "${i}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "${i.substring(1)}"`}):n.endsWith(`.dto.ts`)&&i.endsWith(`Dto`)?e.report({node:t,message:`接口名 "${i}" 后缀应使用 DTO(全大写)而非 Dto(驼峰式)`}):e.report({node:t,message:`接口名 "${i}" 不符合命名规范。接口名应使用 ${Ce(n)}`})),r||n.endsWith(`.dto.ts`)||n.endsWith(`.tsx`)||e.report({node:t,message:`包含接口 "${i}" 的文件 "${n}" 应命名为 "${Te(n)}"`})}}}}),$=t({meta:{name:`@longzai-intelligence-oxlint/code-style-plugin`},rules:{"no-console":f,"no-inline-type-definition":V,"prefer-split-export-const":W,"require-interface-naming":Q,"require-dto-naming":Z,"require-class-suffix":Y,"no-class-suffix-alias":l,"no-handwritten-shebang":_,"no-lint-suppression":U}});export{G as SUFFIX_MAPPINGS,$ as codeStylePlugin,$ as default,N as getInlineTypeDescription,P as getParamName,s as hasIPrefix,M as hasInlineType,X as isDtoFile,D as isFunctionNode,O as isMethodDefinition,C as isTSFunctionType,T as isTSIntersectionType,S as isTSTypeLiteral,w as isTSUnionType,l as noClassSuffixAliasRule,f as noConsoleRule,_ as noHandwrittenShebangRule,V as noInlineTypeDefinitionRule,U as noLintSuppressionRule,W as preferSplitExportConstRule,Y as requireClassSuffixRule,Z as requireDtoNamingRule,Q as requireInterfaceNamingRule};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../rolldown-runtime-BqT_7tdF.js";import{n as e}from"../dist-CskvMq7J.js";import{defineRule as t,eslintCompatPlugin as n}from"@oxlint/plugins";import{existsSync as r,readdirSync as i}from"node:fs";import a from"node:path";const o=[`index.ts`,`index.tsx`,`main.ts`,`main.tsx`,`App.tsx`],s=[`types.ts`,`errors.ts`,`constants.ts`],c=[`persistence.ts`,`typeorm.ts`,`hono.ts`,`react.ts`,`vue.ts`,`next.ts`,`electron.ts`,`browser.ts`,`node.ts`],l=[...o,...s,...c],u=[`impl`,`functions`,`methods`,`handlers`,`classes`,`class`,`manager`,`object`,`processor`,`process`,`common`,`logic`,`hooks`,`component`,`scripts`,`script`],d=[{pattern:/^use[A-Z][a-zA-Z]*\.spec\.tsx?$/,caseStyle:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.spec.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.test\.tsx?$/,caseStyle:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.test.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.types\.ts$/,caseStyle:`camelCase`,description:`Hook 类型文件应使用 camelCase 并以 use 前缀开头(如 useChat.types.ts)`},{pattern:/\.spec\.ts$/,caseStyle:`kebab-case-test`,description:`测试文件应使用 xxx.spec.ts 格式(kebab-case)`},{pattern:/\.test\.ts$/,caseStyle:`kebab-case-test`,description:`测试文件应使用 xxx.test.ts 格式(kebab-case)`},{pattern:/\.spec\.tsx$/,caseStyle:`kebab-case-test`,description:`测试文件应使用 xxx.spec.tsx 格式(kebab-case)`},{pattern:/\.test\.tsx$/,caseStyle:`kebab-case-test`,description:`测试文件应使用 xxx.test.tsx 格式(kebab-case)`},{pattern:/^use[A-Z][a-zA-Z]*\.tsx?$/,caseStyle:`camelCase`,description:`Hook 文件应使用 camelCase 并以 use 前缀开头(如 useChat.ts)`}],f=[{pattern:/\.service\.drizzle\.ts$/,caseStyle:`kebab-case`,description:`Drizzle Service 文件应使用 xxx.service.drizzle.ts 格式(kebab-case)`},{pattern:/\.service\.memory\.ts$/,caseStyle:`kebab-case`,description:`Memory Service 文件应使用 xxx.service.memory.ts 格式(kebab-case)`},{pattern:/\.service\.ts$/,caseStyle:`kebab-case`,description:`服务文件应使用 xxx.service.ts 格式(kebab-case)`},{pattern:/\.controller\.ts$/,caseStyle:`kebab-case`,description:`控制器文件应使用 xxx.controller.ts 格式(kebab-case)`},{pattern:/\.module\.ts$/,caseStyle:`kebab-case`,description:`模块文件应使用 xxx.module.ts 格式(kebab-case)`},{pattern:/\.repository\.drizzle\.ts$/,caseStyle:`kebab-case`,description:`Drizzle Repository 文件应使用 xxx.repository.drizzle.ts 格式(kebab-case)`},{pattern:/\.repository\.memory\.ts$/,caseStyle:`kebab-case`,description:`Memory Repository 文件应使用 xxx.repository.memory.ts 格式(kebab-case)`},{pattern:/\.repository\.interface\.ts$/,caseStyle:`kebab-case`,description:`Repository 接口文件应使用 xxx.repository.interface.ts 格式(kebab-case)`},{pattern:/\.repository\.types\.ts$/,caseStyle:`kebab-case`,description:`Repository 类型文件应使用 xxx.repository.types.ts 格式(kebab-case)`},{pattern:/\.repository\.ts$/,caseStyle:`kebab-case`,description:`Repository 文件应使用 xxx.repository.ts 格式(kebab-case)`},{pattern:/\.entity\.types\.ts$/,caseStyle:`kebab-case`,description:`Entity 类型文件应使用 xxx.entity.types.ts 格式(kebab-case)`},{pattern:/\.entity\.interface\.ts$/,caseStyle:`kebab-case`,description:`Entity 接口文件应使用 xxx.entity.interface.ts 格式(kebab-case)`},{pattern:/\.entity\.ts$/,caseStyle:`kebab-case`,description:`Entity 文件应使用 xxx.entity.ts 格式(kebab-case)`},{pattern:/\.dto\.ts$/,caseStyle:`kebab-case`,description:`DTO 文件应使用 xxx.dto.ts 格式(kebab-case)`},{pattern:/\.port\.interface\.ts$/,caseStyle:`kebab-case`,description:`Port 接口文件应使用 xxx.port.interface.ts 格式(kebab-case)`},{pattern:/\.interface\.ts$/,caseStyle:`kebab-case`,description:`接口文件应使用 xxx.interface.ts 格式(kebab-case)`},{pattern:/\.interface\.tsx$/,caseStyle:`kebab-case`,description:`接口文件应使用 xxx.interface.tsx 格式(kebab-case)`},{pattern:/\.types\.ts$/,caseStyle:`kebab-case`,description:`类型文件应使用 xxx.types.ts 格式(kebab-case)`},{pattern:/\.schema\.ts$/,caseStyle:`kebab-case`,description:`Schema 文件应使用 xxx.schema.ts 格式(kebab-case)`},{pattern:/\.port\.ts$/,caseStyle:`kebab-case`,description:`Port 文件应使用 xxx.port.ts 格式(kebab-case)`},{pattern:/\.port-adapter\.factory\.ts$/,caseStyle:`kebab-case`,description:`Port Adapter Factory 文件应使用 xxx.port-adapter.factory.ts 格式(kebab-case)`},{pattern:/\.port-adapter\.ts$/,caseStyle:`kebab-case`,description:`Port Adapter 文件应使用 xxx.port-adapter.ts 格式(kebab-case)`},{pattern:/\.adapter\.ts$/,caseStyle:`kebab-case`,description:`Adapter 文件应使用 xxx.adapter.ts 格式(kebab-case)`},{pattern:/\.client\.ts$/,caseStyle:`kebab-case`,description:`客户端文件应使用 xxx.client.ts 格式(kebab-case)`},{pattern:/\.events\.ts$/,caseStyle:`kebab-case`,description:`Events 文件应使用 xxx.events.ts 格式(kebab-case)`},{pattern:/\.mapper\.ts$/,caseStyle:`kebab-case`,description:`Mapper 文件应使用 xxx.mapper.ts 格式(kebab-case)`},{pattern:/\.ipc\.ts$/,caseStyle:`kebab-case`,description:`IPC 文件应使用 xxx.ipc.ts 格式(kebab-case)`},{pattern:/\.config\.ts$/,caseStyle:`kebab-case`,description:`配置文件应使用 xxx.config.ts 格式(kebab-case)`},{pattern:/\.errors\.ts$/,caseStyle:`kebab-case`,description:`错误文件应使用 xxx.errors.ts 格式(kebab-case)`},{pattern:/\.utils\.ts$/,caseStyle:`kebab-case`,description:`工具函数文件应使用 xxx.utils.ts 格式(kebab-case)`},{pattern:/\.constants\.ts$/,caseStyle:`kebab-case`,description:`常量文件应使用 xxx.constants.ts 格式(kebab-case)`},{pattern:/\.atom\.ts$/,caseStyle:`kebab-case`,description:`Atom 文件应使用 xxx.atom.ts 格式(kebab-case)`},{pattern:/\.vo\.ts$/,caseStyle:`kebab-case`,description:`值对象文件应使用 xxx.vo.ts 格式(kebab-case)`},{pattern:/\.usecase\.ts$/,caseStyle:`kebab-case`,description:`UseCase 文件应使用 xxx.usecase.ts 格式(kebab-case)`},{pattern:/\.styles\.css$/,caseStyle:`kebab-case`,description:`样式文件应使用 xxx.styles.css 格式(kebab-case)`},{pattern:/\.extension\.tsx?$/,caseStyle:`kebab-case`,description:`扩展文件应使用 xxx.extension.ts(x) 格式(kebab-case)`}],p=[{pattern:/^[A-Z][a-zA-Z0-9]*\.types\.ts$/,caseStyle:`PascalCase`,description:`类型文件可使用 PascalCase(如 DataExtractor.types.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.utils\.ts$/,caseStyle:`PascalCase`,description:`工具函数文件可使用 PascalCase(如 DataExtractor.utils.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.constants\.ts$/,caseStyle:`PascalCase`,description:`常量文件可使用 PascalCase(如 ByteVisualizer.constants.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.guards\.ts$/,caseStyle:`PascalCase`,description:`守卫文件可使用 PascalCase(如 DataExtractor.guards.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.helpers\.ts$/,caseStyle:`PascalCase`,description:`辅助函数文件可使用 PascalCase(如 TableVisualizer.helpers.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.groups\.ts$/,caseStyle:`PascalCase`,description:`分组文件可使用 PascalCase(如 TableVisualizer.groups.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.type-guards\.ts$/,caseStyle:`PascalCase`,description:`类型守卫文件可使用 PascalCase(如 TableVisualizer.type-guards.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.test\.ts$/,caseStyle:`PascalCase`,description:`测试文件可使用 PascalCase(如 DataExtractor.test.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.[a-z][-a-z]*\.test\.ts$/,caseStyle:`PascalCase`,description:`伴生测试文件可使用 PascalCase(如 DataExtractor.guards.test.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.[a-z][-a-z]*\.test\.tsx$/,caseStyle:`PascalCase`,description:`伴生测试文件可使用 PascalCase(如 PacketCompare.test.tsx)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.test\.tsx$/,caseStyle:`PascalCase`,description:`测试文件可使用 PascalCase(如 ByteVisualizer.test.tsx)`}],m={pattern:/^[a-z][a-zA-Z0-9_-]*\.tsx$/,caseStyle:`PascalCase`,description:`组件文件应使用 PascalCase(如 ChatPage.tsx),小写开头不允许`},h={pattern:/^[A-Z][a-zA-Z0-9]*\.tsx$/,caseStyle:`PascalCase`,description:`React 组件文件可使用 PascalCase(如 ChatPage.tsx)`},g=[...d,...p,...f,m,h];function _(e){return/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(e)}function v(e){return e.split(`.`).every(e=>_(e)&&e.length>0)}function y(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function b(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function x(e){let t=e.split(`.`)[0];return t!==void 0&&t.length>0&&y(t)}function S(e){return e.split(`.`).every(e=>_(e)&&e.length>0)}function ee(e,t){switch(t){case`kebab-case`:return v(e);case`PascalCase`:return y(e);case`camelCase`:return b(e);case`kebab-case-test`:return S(e);default:return!0}}function te(e){return/^v\d+(-[a-z0-9-]+)?\.ts$/.test(e)}function C(e){let t=e.replace(/\.tsx?$/,``);for(let e of u){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function w(e){return!!(l.includes(e)||e.endsWith(`.d.ts`)||te(e)||e.startsWith(`[`)||e.startsWith(`_`))}function T(e,t){let n=e.replace(/\\/g,`/`);for(let e of t){let t=e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*\//g,`<<DOUBLE_STAR_SLASH>>`).replace(/\*\*/g,`<<DOUBLE_STAR>>`).replace(/\*/g,`[^/]*`).replace(/<<DOUBLE_STAR_SLASH>>/g,`(.*\\/)?`).replace(/<<DOUBLE_STAR>>/g,`.*`);if(RegExp(`.*${t}`).test(n))return!0}return!1}function E(e,t){if(t===h)return e.replace(/\.tsx$/,``);let n=t.pattern.source;if(n.startsWith(`^`)&&n.endsWith(`$`)){if(n.includes(`\\.test\\.`)||n.includes(`\\.spec\\.`))return e.replace(/\.(test|spec)\.(tsx?|jsx?)$/,``);let t=e.match(/^([A-Z][a-zA-Z0-9]*)\.[a-z][-a-z]*\.tsx?$/);return t&&t[1]?t[1]:n.includes(`\\.types\\.`)?e.replace(/\.types\.ts$/,``):e.replace(/\.[^.]+$/,``)}return e.replace(t.pattern,``)}[...l];const D=/* @__PURE__ */ new Map;function O(e){let t=D.get(e);if(t!==void 0)return t;let n;try{n=r(e)}catch{n=!1}return D.set(e,n),n}const k=/^([A-Z][a-zA-Z0-9]*)\.[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)*\.ts$/;function A(e){return e.match(k)?.[1]??null}function j(e,t){let n=A(t);if(!n)return!1;let r=`${n}.tsx`,i=e.substring(0,e.lastIndexOf(`/`));return O(a.join(i,r))}function M(e){let t=e.replace(/\.(test|spec)\.(tsx|ts)$/,``);return y(t)||x(t)}function N(e,t){if(!(t.endsWith(`.test.tsx`)||t.endsWith(`.spec.tsx`)||t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`))||!M(t))return{status:`not-component-test`};let n=t.replace(/\.(test|spec)\.(tsx|ts)$/,`.tsx`),r=t.replace(/\.(test|spec)\.(tsx|ts)$/,`.ts`);if(e.includes(`/__tests__/`))return F(e,n)||F(e,r)?{status:`component-test-found`}:{status:`not-component-test`};if(e.includes(`/components/`)){let t=e.substring(0,e.lastIndexOf(`/`)),i=e.indexOf(`/components/`),o=e.substring(0,i+11),s=t;for(;;){if(P(s,n)||P(s,r))return{status:`component-test-found`};if(s===o)break;let e=a.dirname(s);if(e===s)break;s=e}}return{status:`not-component-test`}}function P(e,t){if(O(a.join(e,t)))return!0;try{let n=i(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()&&O(a.join(e,r.name,t)))return!0}catch{}return!1}function F(e,t){let n=e.indexOf(`/__tests__/`),r=e.substring(0,n),i=e.substring(n+11),o=a.dirname(i),s=o===`.`?r:a.join(r,o);for(;;){if(P(s,t))return!0;if(s===r)break;let e=a.dirname(s);if(e===s)break;s=e}return!1}function I(e){return typeof e==`object`&&!!e}function L(e,t){let n=I(t)?t:void 0;return!!(n?.skipPatterns?.length&&T(e,n.skipPatterns))}const R=t({meta:{type:`problem`,docs:{description:`强制执行文件命名规范`},schema:[{type:`object`,properties:{skipPatterns:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{before(){if(L(e.filename,e.options?.[0])||w(e.filename.replace(/\\/g,`/`).split(`/`).pop()??``))return!1},Program(t){if(L(e.filename,e.options?.[0]))return;let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=e.filename.replace(/\\/g,`/`),i=C(n);if(i!==`hooks`&&j(r,n))return;if(N(r,n).status===`component-test-found`){let e=n.replace(/\.(test|spec)\.(tsx|ts)$/,``);if(y(e)||x(e))return}if(i!==null){let r=i===`hooks`?`hook 文件应使用 use 前缀小驼峰且不带后缀,如 useRepos.ts`:i===`component`?`组件文件应使用大驼峰且不带后缀,如 RepoList.tsx`:i===`scripts`||i===`script`?`脚本文件应以动词直接命名且不带后缀,置于包级 scripts 目录,如 scripts/migrate.ts、scripts/seed.ts`:`.${i} 后缀语义过于泛化,请改用具体语义后缀`;e.report({node:t,message:`文件命名违规: ${n}。禁用 .${i} 后缀,${r}`});return}let a=g.find(e=>e.pattern.test(n));a&&(ee(E(n,a),a.caseStyle)||e.report({node:t,message:`文件命名违规: ${n}。${a.description}`}))}}}}),ne=[`.types.ts`,`.types.d.ts`];function z(e){return ne.some(t=>e.endsWith(t))}const B=t({meta:{type:`problem`,docs:{description:`强制执行 types 文件中的接口命名规范(禁止 I 前缀)`}},createOnce(t){return{before(){let e=t.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(e.endsWith(`.test.ts`)||e.endsWith(`.spec.ts`)||!z(e))return!1},TSInterfaceDeclaration(n){let r=n.id.name;e(r)&&t.report({node:n,message:`类型文件中的接口名 "${r}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "${r.substring(1)}"`})}}}}),V=[`impl`,`functions`,`methods`,`handlers`,`classes`,`class`,`manager`,`object`,`processor`,`process`,`common`,`logic`,`scripts`,`script`],H=/* @__PURE__ */ new Set([`index.ts`,`index.tsx`,`main.ts`,`main.tsx`,`App.tsx`,`bootstrap.ts`,`types.ts`,`errors.ts`,`constants.ts`,`types.d.ts`,`persistence.ts`,`typeorm.ts`,`migrate.ts`,`seed.ts`,`hono.ts`,`react.ts`,`vue.ts`,`next.ts`,`electron.ts`,`browser.ts`,`node.ts`]);function U(e){if(!e.endsWith(`.ts`)&&!e.endsWith(`.tsx`))return!1;let t=e.replace(/\.tsx?$/,``);return/^use[A-Z][a-zA-Z0-9]*$/.test(t)}function W(e){if(!e.endsWith(`.tsx`))return!1;let t=e.replace(`.tsx`,``);return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function G(e){return/^v\d+(-[a-z0-9-]+)?\.ts$/.test(e)}function K(e){let t=e.replace(/\.tsx?$/,``);return[/s$/,/es$/,/ies$/].some(e=>e.test(t))}function q(e){return e.endsWith(`.types.ts`)?!0:/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)||/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)}function J(e){let t=e.replace(/\.tsx?$/,``);for(let e of V){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function Y(e){let t=[],n=e.replace(/\.tsx?$/,``);return(n.includes(`service`)||n.includes(`Service`))&&t.push(`.service.ts`),(n.includes(`controller`)||n.includes(`Controller`))&&t.push(`.controller.ts`),(n.includes(`utils`)||n.includes(`helper`))&&t.push(`.utils.ts`),(n.includes(`constant`)||n.includes(`Constant`))&&t.push(`.constants.ts`),(n.includes(`config`)||n.includes(`Config`))&&t.push(`.config.ts`),t.length===0&&t.push(`.utils.ts`,`.config.ts`,`.constants.ts`),t}function X(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}function Z(e){return typeof e==`object`&&!!e}function re(e,t,n,r){return!!(n?.skipPatterns&&T(r,n.skipPatterns)||H.has(t)||t.endsWith(`.d.ts`)||e.startsWith(`[`)||e.startsWith(`_`)||t.endsWith(`.tsx`)||e.endsWith(`.test.ts`)||e.endsWith(`.test.tsx`)||e.endsWith(`.spec.ts`)||e.endsWith(`.spec.tsx`)||G(t)||W(t)||U(t)||!J(t)&&K(t))}const Q=t({meta:{type:`problem`,docs:{description:`强制执行文件类型后缀规范,确保文件名明确表达其用途`},schema:[{type:`object`,properties:{skipPatterns:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{Program(t){let n=e.options?.[0],r=Z(n)?n:void 0,i=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,a=X(i);if(re(i,a,r,e.filename))return;let o=J(a);if(o){e.report({node:t,message:`文件 "${i}" 使用了禁止的后缀 ".${o}"。该后缀语义过于泛化,无法表达文件用途。请使用更具体的后缀,如 ".utils"、".service" 等。`});return}if(q(a))return;let s=Y(a);e.report({node:t,message:`文件 "${i}" 缺少类型后缀。除特殊文件外,所有文件应使用 xxx.yyy.ts 格式明确表达用途。建议: ${s.join(`, `)}`})}}}}),$=n({meta:{name:`@longzai-intelligence-oxlint/file-naming-plugin`},rules:{"file-naming":R,"require-type-naming":B,"require-type-suffix":Q}});export{$ as default,$ as fileNamingPlugin,R as fileNamingRule,B as requireTypeNamingRule,Q as requireTypeSuffixRule};
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import{existsSync as n,readdirSync as r}from"node:fs";import i from"node:path";import{n as a}from"../dist-DVSw2KvF.js";const o=[`index.ts`,`index.tsx`,`main.ts`,`main.tsx`,`App.tsx`],s=[`types.ts`,`errors.ts`,`constants.ts`],c=[`persistence.ts`,`typeorm.ts`,`hono.ts`,`react.ts`,`vue.ts`,`next.ts`,`electron.ts`,`browser.ts`,`node.ts`],l=[...o,...s,...c],u=[`impl`,`functions`,`methods`,`handlers`,`classes`,`class`,`manager`,`object`,`processor`,`process`,`common`,`logic`,`hooks`,`component`,`scripts`,`script`],d=[{pattern:/^use[A-Z][a-zA-Z]*\.spec\.tsx?$/,caseStyle:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.spec.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.test\.tsx?$/,caseStyle:`camelCase`,description:`Hook 测试文件应使用 camelCase 并以 use 前缀开头(如 useChat.test.ts)`},{pattern:/^use[A-Z][a-zA-Z]*\.types\.ts$/,caseStyle:`camelCase`,description:`Hook 类型文件应使用 camelCase 并以 use 前缀开头(如 useChat.types.ts)`},{pattern:/\.spec\.ts$/,caseStyle:`kebab-case-test`,description:`测试文件应使用 xxx.spec.ts 格式(kebab-case)`},{pattern:/\.test\.ts$/,caseStyle:`kebab-case-test`,description:`测试文件应使用 xxx.test.ts 格式(kebab-case)`},{pattern:/\.spec\.tsx$/,caseStyle:`kebab-case-test`,description:`测试文件应使用 xxx.spec.tsx 格式(kebab-case)`},{pattern:/\.test\.tsx$/,caseStyle:`kebab-case-test`,description:`测试文件应使用 xxx.test.tsx 格式(kebab-case)`},{pattern:/^use[A-Z][a-zA-Z]*\.tsx?$/,caseStyle:`camelCase`,description:`Hook 文件应使用 camelCase 并以 use 前缀开头(如 useChat.ts)`}],f=[{pattern:/\.service\.drizzle\.ts$/,caseStyle:`kebab-case`,description:`Drizzle Service 文件应使用 xxx.service.drizzle.ts 格式(kebab-case)`},{pattern:/\.service\.memory\.ts$/,caseStyle:`kebab-case`,description:`Memory Service 文件应使用 xxx.service.memory.ts 格式(kebab-case)`},{pattern:/\.service\.ts$/,caseStyle:`kebab-case`,description:`服务文件应使用 xxx.service.ts 格式(kebab-case)`},{pattern:/\.controller\.ts$/,caseStyle:`kebab-case`,description:`控制器文件应使用 xxx.controller.ts 格式(kebab-case)`},{pattern:/\.module\.ts$/,caseStyle:`kebab-case`,description:`模块文件应使用 xxx.module.ts 格式(kebab-case)`},{pattern:/\.repository\.drizzle\.ts$/,caseStyle:`kebab-case`,description:`Drizzle Repository 文件应使用 xxx.repository.drizzle.ts 格式(kebab-case)`},{pattern:/\.repository\.memory\.ts$/,caseStyle:`kebab-case`,description:`Memory Repository 文件应使用 xxx.repository.memory.ts 格式(kebab-case)`},{pattern:/\.repository\.interface\.ts$/,caseStyle:`kebab-case`,description:`Repository 接口文件应使用 xxx.repository.interface.ts 格式(kebab-case)`},{pattern:/\.repository\.types\.ts$/,caseStyle:`kebab-case`,description:`Repository 类型文件应使用 xxx.repository.types.ts 格式(kebab-case)`},{pattern:/\.repository\.ts$/,caseStyle:`kebab-case`,description:`Repository 文件应使用 xxx.repository.ts 格式(kebab-case)`},{pattern:/\.entity\.types\.ts$/,caseStyle:`kebab-case`,description:`Entity 类型文件应使用 xxx.entity.types.ts 格式(kebab-case)`},{pattern:/\.entity\.interface\.ts$/,caseStyle:`kebab-case`,description:`Entity 接口文件应使用 xxx.entity.interface.ts 格式(kebab-case)`},{pattern:/\.entity\.ts$/,caseStyle:`kebab-case`,description:`Entity 文件应使用 xxx.entity.ts 格式(kebab-case)`},{pattern:/\.dto\.ts$/,caseStyle:`kebab-case`,description:`DTO 文件应使用 xxx.dto.ts 格式(kebab-case)`},{pattern:/\.port\.interface\.ts$/,caseStyle:`kebab-case`,description:`Port 接口文件应使用 xxx.port.interface.ts 格式(kebab-case)`},{pattern:/\.interface\.ts$/,caseStyle:`kebab-case`,description:`接口文件应使用 xxx.interface.ts 格式(kebab-case)`},{pattern:/\.interface\.tsx$/,caseStyle:`kebab-case`,description:`接口文件应使用 xxx.interface.tsx 格式(kebab-case)`},{pattern:/\.types\.ts$/,caseStyle:`kebab-case`,description:`类型文件应使用 xxx.types.ts 格式(kebab-case)`},{pattern:/\.schema\.ts$/,caseStyle:`kebab-case`,description:`Schema 文件应使用 xxx.schema.ts 格式(kebab-case)`},{pattern:/\.port\.ts$/,caseStyle:`kebab-case`,description:`Port 文件应使用 xxx.port.ts 格式(kebab-case)`},{pattern:/\.port-adapter\.factory\.ts$/,caseStyle:`kebab-case`,description:`Port Adapter Factory 文件应使用 xxx.port-adapter.factory.ts 格式(kebab-case)`},{pattern:/\.port-adapter\.ts$/,caseStyle:`kebab-case`,description:`Port Adapter 文件应使用 xxx.port-adapter.ts 格式(kebab-case)`},{pattern:/\.adapter\.ts$/,caseStyle:`kebab-case`,description:`Adapter 文件应使用 xxx.adapter.ts 格式(kebab-case)`},{pattern:/\.client\.ts$/,caseStyle:`kebab-case`,description:`客户端文件应使用 xxx.client.ts 格式(kebab-case)`},{pattern:/\.events\.ts$/,caseStyle:`kebab-case`,description:`Events 文件应使用 xxx.events.ts 格式(kebab-case)`},{pattern:/\.mapper\.ts$/,caseStyle:`kebab-case`,description:`Mapper 文件应使用 xxx.mapper.ts 格式(kebab-case)`},{pattern:/\.ipc\.ts$/,caseStyle:`kebab-case`,description:`IPC 文件应使用 xxx.ipc.ts 格式(kebab-case)`},{pattern:/\.config\.ts$/,caseStyle:`kebab-case`,description:`配置文件应使用 xxx.config.ts 格式(kebab-case)`},{pattern:/\.errors\.ts$/,caseStyle:`kebab-case`,description:`错误文件应使用 xxx.errors.ts 格式(kebab-case)`},{pattern:/\.utils\.ts$/,caseStyle:`kebab-case`,description:`工具函数文件应使用 xxx.utils.ts 格式(kebab-case)`},{pattern:/\.constants\.ts$/,caseStyle:`kebab-case`,description:`常量文件应使用 xxx.constants.ts 格式(kebab-case)`},{pattern:/\.atom\.ts$/,caseStyle:`kebab-case`,description:`Atom 文件应使用 xxx.atom.ts 格式(kebab-case)`},{pattern:/\.vo\.ts$/,caseStyle:`kebab-case`,description:`值对象文件应使用 xxx.vo.ts 格式(kebab-case)`},{pattern:/\.usecase\.ts$/,caseStyle:`kebab-case`,description:`UseCase 文件应使用 xxx.usecase.ts 格式(kebab-case)`},{pattern:/\.styles\.css$/,caseStyle:`kebab-case`,description:`样式文件应使用 xxx.styles.css 格式(kebab-case)`},{pattern:/\.extension\.tsx?$/,caseStyle:`kebab-case`,description:`扩展文件应使用 xxx.extension.ts(x) 格式(kebab-case)`}],p=[{pattern:/^[A-Z][a-zA-Z0-9]*\.types\.ts$/,caseStyle:`PascalCase`,description:`类型文件可使用 PascalCase(如 DataExtractor.types.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.utils\.ts$/,caseStyle:`PascalCase`,description:`工具函数文件可使用 PascalCase(如 DataExtractor.utils.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.constants\.ts$/,caseStyle:`PascalCase`,description:`常量文件可使用 PascalCase(如 ByteVisualizer.constants.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.guards\.ts$/,caseStyle:`PascalCase`,description:`守卫文件可使用 PascalCase(如 DataExtractor.guards.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.helpers\.ts$/,caseStyle:`PascalCase`,description:`辅助函数文件可使用 PascalCase(如 TableVisualizer.helpers.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.groups\.ts$/,caseStyle:`PascalCase`,description:`分组文件可使用 PascalCase(如 TableVisualizer.groups.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.type-guards\.ts$/,caseStyle:`PascalCase`,description:`类型守卫文件可使用 PascalCase(如 TableVisualizer.type-guards.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.test\.ts$/,caseStyle:`PascalCase`,description:`测试文件可使用 PascalCase(如 DataExtractor.test.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.[a-z][-a-z]*\.test\.ts$/,caseStyle:`PascalCase`,description:`伴生测试文件可使用 PascalCase(如 DataExtractor.guards.test.ts)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.[a-z][-a-z]*\.test\.tsx$/,caseStyle:`PascalCase`,description:`伴生测试文件可使用 PascalCase(如 PacketCompare.test.tsx)`},{pattern:/^[A-Z][a-zA-Z0-9]*\.test\.tsx$/,caseStyle:`PascalCase`,description:`测试文件可使用 PascalCase(如 ByteVisualizer.test.tsx)`}],m={pattern:/^[a-z][a-zA-Z0-9_-]*\.tsx$/,caseStyle:`PascalCase`,description:`组件文件应使用 PascalCase(如 ChatPage.tsx),小写开头不允许`},h={pattern:/^[A-Z][a-zA-Z0-9]*\.tsx$/,caseStyle:`PascalCase`,description:`React 组件文件可使用 PascalCase(如 ChatPage.tsx)`},g=[...d,...p,...f,m,h];function _(e){return/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/.test(e)}function v(e){return e.split(`.`).every(e=>_(e)&&e.length>0)}function y(e){return/^[A-Z][a-zA-Z0-9]*$/.test(e)}function b(e){return/^[a-z][a-zA-Z0-9]*$/.test(e)}function x(e){let t=e.split(`.`)[0];return t!==void 0&&t.length>0&&y(t)}function S(e){return e.split(`.`).every(e=>_(e)&&e.length>0)}function ee(e,t){switch(t){case`kebab-case`:return v(e);case`PascalCase`:return y(e);case`camelCase`:return b(e);case`kebab-case-test`:return S(e);default:return!0}}function te(e){return/^v\d+(-[a-z0-9-]+)?\.ts$/.test(e)}function C(e){let t=e.replace(/\.tsx?$/,``);for(let e of u){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function w(e){return!!(l.includes(e)||e.endsWith(`.d.ts`)||te(e)||e.startsWith(`[`)||e.startsWith(`_`))}function T(e,t){let n=e.replace(/\\/g,`/`);for(let e of t){let t=e.replace(/[.+^${}()|[\]\\]/g,`\\$&`).replace(/\*\*\//g,`<<DOUBLE_STAR_SLASH>>`).replace(/\*\*/g,`<<DOUBLE_STAR>>`).replace(/\*/g,`[^/]*`).replace(/<<DOUBLE_STAR_SLASH>>/g,`(.*\\/)?`).replace(/<<DOUBLE_STAR>>/g,`.*`);if(RegExp(`.*${t}`).test(n))return!0}return!1}function E(e,t){if(t===h)return e.replace(/\.tsx$/,``);let n=t.pattern.source;if(n.startsWith(`^`)&&n.endsWith(`$`)){if(n.includes(`\\.test\\.`)||n.includes(`\\.spec\\.`))return e.replace(/\.(test|spec)\.(tsx?|jsx?)$/,``);let t=e.match(/^([A-Z][a-zA-Z0-9]*)\.[a-z][-a-z]*\.tsx?$/);return t&&t[1]?t[1]:n.includes(`\\.types\\.`)?e.replace(/\.types\.ts$/,``):e.replace(/\.[^.]+$/,``)}return e.replace(t.pattern,``)}[...l];const D=/* @__PURE__ */ new Map;function O(e){let t=D.get(e);if(t!==void 0)return t;let r;try{r=n(e)}catch{r=!1}return D.set(e,r),r}const k=/^([A-Z][a-zA-Z0-9]*)\.[a-z][a-z0-9-]*(\.[a-z][a-z0-9-]*)*\.ts$/;function A(e){return e.match(k)?.[1]??null}function j(e,t){let n=A(t);if(!n)return!1;let r=`${n}.tsx`,a=e.substring(0,e.lastIndexOf(`/`));return O(i.join(a,r))}function M(e){let t=e.replace(/\.(test|spec)\.(tsx|ts)$/,``);return y(t)||x(t)}function N(e,t){if(!(t.endsWith(`.test.tsx`)||t.endsWith(`.spec.tsx`)||t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`))||!M(t))return{status:`not-component-test`};let n=t.replace(/\.(test|spec)\.(tsx|ts)$/,`.tsx`),r=t.replace(/\.(test|spec)\.(tsx|ts)$/,`.ts`);if(e.includes(`/__tests__/`))return F(e,n)||F(e,r)?{status:`component-test-found`}:{status:`not-component-test`};if(e.includes(`/components/`)){let t=e.substring(0,e.lastIndexOf(`/`)),a=e.indexOf(`/components/`),o=e.substring(0,a+11),s=t;for(;;){if(P(s,n)||P(s,r))return{status:`component-test-found`};if(s===o)break;let e=i.dirname(s);if(e===s)break;s=e}}return{status:`not-component-test`}}function P(e,t){if(O(i.join(e,t)))return!0;try{let n=r(e,{withFileTypes:!0});for(let r of n)if(r.isDirectory()&&O(i.join(e,r.name,t)))return!0}catch{}return!1}function F(e,t){let n=e.indexOf(`/__tests__/`),r=e.substring(0,n),a=e.substring(n+11),o=i.dirname(a),s=o===`.`?r:i.join(r,o);for(;;){if(P(s,t))return!0;if(s===r)break;let e=i.dirname(s);if(e===s)break;s=e}return!1}function I(e){return typeof e==`object`&&!!e}function L(e,t){let n=I(t)?t:void 0;return!!(n?.skipPatterns?.length&&T(e,n.skipPatterns))}const R=e({meta:{type:`problem`,docs:{description:`强制执行文件命名规范`},schema:[{type:`object`,properties:{skipPatterns:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{before(){if(L(e.filename,e.options?.[0])||w(e.filename.replace(/\\/g,`/`).split(`/`).pop()??``))return!1},Program(t){if(L(e.filename,e.options?.[0]))return;let n=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,r=e.filename.replace(/\\/g,`/`),i=C(n);if(i!==`hooks`&&j(r,n))return;if(N(r,n).status===`component-test-found`){let e=n.replace(/\.(test|spec)\.(tsx|ts)$/,``);if(y(e)||x(e))return}if(i!==null){let r=i===`hooks`?`hook 文件应使用 use 前缀小驼峰且不带后缀,如 useRepos.ts`:i===`component`?`组件文件应使用大驼峰且不带后缀,如 RepoList.tsx`:i===`scripts`||i===`script`?`脚本文件应以动词直接命名且不带后缀,置于包级 scripts 目录,如 scripts/migrate.ts、scripts/seed.ts`:`.${i} 后缀语义过于泛化,请改用具体语义后缀`;e.report({node:t,message:`文件命名违规: ${n}。禁用 .${i} 后缀,${r}`});return}let a=g.find(e=>e.pattern.test(n));a&&(ee(E(n,a),a.caseStyle)||e.report({node:t,message:`文件命名违规: ${n}。${a.description}`}))}}}}),ne=[`.types.ts`,`.types.d.ts`];function z(e){return ne.some(t=>e.endsWith(t))}const B=e({meta:{type:`problem`,docs:{description:`强制执行 types 文件中的接口命名规范(禁止 I 前缀)`}},createOnce(e){return{before(){let t=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``;if(t.endsWith(`.test.ts`)||t.endsWith(`.spec.ts`)||!z(t))return!1},TSInterfaceDeclaration(t){let n=t.id.name;a(n)&&e.report({node:t,message:`类型文件中的接口名 "${n}" 使用了 I 前缀。现代 TypeScript 不推荐使用匈牙利命名法,建议使用 "${n.substring(1)}"`})}}}}),V=[`impl`,`functions`,`methods`,`handlers`,`classes`,`class`,`manager`,`object`,`processor`,`process`,`common`,`logic`,`scripts`,`script`],H=/* @__PURE__ */ new Set([`index.ts`,`index.tsx`,`main.ts`,`main.tsx`,`App.tsx`,`bootstrap.ts`,`types.ts`,`errors.ts`,`constants.ts`,`types.d.ts`,`persistence.ts`,`typeorm.ts`,`migrate.ts`,`seed.ts`,`hono.ts`,`react.ts`,`vue.ts`,`next.ts`,`electron.ts`,`browser.ts`,`node.ts`]);function U(e){if(!e.endsWith(`.ts`)&&!e.endsWith(`.tsx`))return!1;let t=e.replace(/\.tsx?$/,``);return/^use[A-Z][a-zA-Z0-9]*$/.test(t)}function W(e){if(!e.endsWith(`.tsx`))return!1;let t=e.replace(`.tsx`,``);return/^[A-Z][a-zA-Z0-9]*$/.test(t)}function G(e){return/^v\d+(-[a-z0-9-]+)?\.ts$/.test(e)}function K(e){let t=e.replace(/\.tsx?$/,``);return[/s$/,/es$/,/ies$/].some(e=>e.test(t))}function q(e){return e.endsWith(`.types.ts`)?!0:/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)||/^[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.[a-z][a-z0-9-]*\.tsx?$/.test(e)}function J(e){let t=e.replace(/\.tsx?$/,``);for(let e of V){if(t.endsWith(`.${e}`))return e;let n=t.split(`.`);if(n.length>=2&&n[n.length-1]===e)return e}return null}function Y(e){let t=[],n=e.replace(/\.tsx?$/,``);return(n.includes(`service`)||n.includes(`Service`))&&t.push(`.service.ts`),(n.includes(`controller`)||n.includes(`Controller`))&&t.push(`.controller.ts`),(n.includes(`utils`)||n.includes(`helper`))&&t.push(`.utils.ts`),(n.includes(`constant`)||n.includes(`Constant`))&&t.push(`.constants.ts`),(n.includes(`config`)||n.includes(`Config`))&&t.push(`.config.ts`),t.length===0&&t.push(`.utils.ts`,`.config.ts`,`.constants.ts`),t}function X(e){for(let t of[`.test.ts`,`.test.tsx`,`.spec.ts`,`.spec.tsx`])if(e.endsWith(t)){let n=t.endsWith(`.tsx`)?`.tsx`:`.ts`;return e.replace(t,n)}return e}function Z(e){return typeof e==`object`&&!!e}function re(e,t,n,r){return!!(n?.skipPatterns&&T(r,n.skipPatterns)||H.has(t)||t.endsWith(`.d.ts`)||e.startsWith(`[`)||e.startsWith(`_`)||t.endsWith(`.tsx`)||e.endsWith(`.test.ts`)||e.endsWith(`.test.tsx`)||e.endsWith(`.spec.ts`)||e.endsWith(`.spec.tsx`)||G(t)||W(t)||U(t)||!J(t)&&K(t))}const Q=e({meta:{type:`problem`,docs:{description:`强制执行文件类型后缀规范,确保文件名明确表达其用途`},schema:[{type:`object`,properties:{skipPatterns:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{Program(t){let n=e.options?.[0],r=Z(n)?n:void 0,i=e.filename.replace(/\\/g,`/`).split(`/`).pop()??``,a=X(i);if(re(i,a,r,e.filename))return;let o=J(a);if(o){e.report({node:t,message:`文件 "${i}" 使用了禁止的后缀 ".${o}"。该后缀语义过于泛化,无法表达文件用途。请使用更具体的后缀,如 ".utils"、".service" 等。`});return}if(q(a))return;let s=Y(a);e.report({node:t,message:`文件 "${i}" 缺少类型后缀。除特殊文件外,所有文件应使用 xxx.yyy.ts 格式明确表达用途。建议: ${s.join(`, `)}`})}}}}),$=t({meta:{name:`@longzai-intelligence-oxlint/file-naming-plugin`},rules:{"file-naming":R,"require-type-naming":B,"require-type-suffix":Q}});export{$ as default,$ as fileNamingPlugin,R as fileNamingRule,B as requireTypeNamingRule,Q as requireTypeSuffixRule};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../rolldown-runtime-BqT_7tdF.js";import"../rolldown-runtime-BqT_7tdF-DsHBzDG-.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import{existsSync as n,readFileSync as r}from"node:fs";import{dirname as i,join as a}from"node:path";const o=/(^|\/)lzi-builder\.config\.(ts|mts)$/,s=[`lzi-builder.config.ts`,`lzi-builder.config.mts`],c=/banner\s*:\s*['"]#!/,l=/banner\s*:\s*\{[^}]*#!/,u=/(^|\/)dist\//,d=/(^|\/)src\//;function f(e){return typeof e==`object`&&!!e}function p(e){let t=e.replace(/\\/g,`/`);return o.test(t)||t.endsWith(`/lzi.config.ts`)}function m(e){let t=e.bin;return typeof t==`string`?[t]:f(t)?Object.values(t).filter(e=>typeof e==`string`):[]}function h(e){return c.test(e)||l.test(e)}function g(e){let t=a(e,`package.json`);if(!n(t))return null;try{let e=JSON.parse(r(t,`utf8`));return f(e)?e:null}catch{return null}}function _(e,t){let n=m(e);return n.length===0?null:n.some(e=>u.test(e.replace(/^\.\//,``)))?h(t)?null:`missingBanner`:e.private===!0?null:n.some(e=>d.test(e.replace(/^\.\//,``)))?`binPointsToSource`:null}const v={missingBanner:`bin 入口指向 dist 产物但构建配置缺少 banner,发布后经 npm 软链直执行会交系统 shell 解析而报语法错误。请配置 "banner: '#!/usr/bin/env bun'",规范见 architecture 仓 "docs/best-practices/build-and-toolchain/guides/cli-bin-shebang.md"。`,binPointsToSource:`可发布包的 bin 入口指向 src 源码,安装链软链直指 TS 源码无法执行。请将 bin 指向 "dist" 产物并配置 banner。`},y=e({meta:{type:`problem`,docs:{description:`要求 bin 指向 dist 产物的包在构建配置注入 shebang banner`}},createOnce(e){return{before(){
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import"../rolldown-runtime-BqT_7tdF-DsHBzDG-.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import{existsSync as n,readFileSync as r}from"node:fs";import{dirname as i,join as a}from"node:path";const o=/(^|\/)lzi-builder\.config\.(ts|mts)$/,s=[`lzi-builder.config.ts`,`lzi-builder.config.mts`],c=/banner\s*:\s*['"]#!/,l=/banner\s*:\s*\{[^}]*#!/,u=/(^|\/)dist\//,d=/(^|\/)src\//;function f(e){return typeof e==`object`&&!!e}function p(e){let t=e.replace(/\\/g,`/`);return o.test(t)||t.endsWith(`/lzi.config.ts`)}function m(e){let t=e.bin;return typeof t==`string`?[t]:f(t)?Object.values(t).filter(e=>typeof e==`string`):[]}function h(e){return c.test(e)||l.test(e)}function g(e){let t=a(e,`package.json`);if(!n(t))return null;try{let e=JSON.parse(r(t,`utf8`));return f(e)?e:null}catch{return null}}function _(e,t){let n=m(e);return n.length===0?null:n.some(e=>u.test(e.replace(/^\.\//,``)))?h(t)?null:`missingBanner`:e.private===!0?null:n.some(e=>d.test(e.replace(/^\.\//,``)))?`binPointsToSource`:null}const v={missingBanner:`bin 入口指向 dist 产物但构建配置缺少 banner,发布后经 npm 软链直执行会交系统 shell 解析而报语法错误。请配置 "banner: '#!/usr/bin/env bun'",规范见 architecture 仓 "docs/best-practices/build-and-toolchain/guides/cli-bin-shebang.md"。`,binPointsToSource:`可发布包的 bin 入口指向 src 源码,安装链软链直指 TS 源码无法执行。请将 bin 指向 "dist" 产物并配置 banner。`},y=e({meta:{type:`problem`,docs:{description:`要求 bin 指向 dist 产物的包在构建配置注入 shebang banner`}},createOnce(e){return{before(){if(!p(e.filename))return!1},Program(t){let r=i(e.filename);if(e.filename.replace(/\\/g,`/`).endsWith(`/lzi.config.ts`)&&s.some(e=>n(a(r,e))))return;let o=g(r);if(o===null)return;let c=_(o,e.sourceCode.text);c!==null&&e.report({node:t,message:v[c]})}}}}),b=/readPackageVersionString/;function x(e){return b.test(e)}function S(e,t){let n=m(e);return n.length===0||!n.some(e=>u.test(e.replace(/^\.\//,``)))||x(t)?null:`missingVersionInjection`}const C={missingVersionInjection:`版本注入未启用,bin 入口指向 dist 产物的包 --version 将回退框架兜底版本而非本包版本。请在 define 声明中以 readPackageVersionString 注入本包版本号,键为 process.env.CLI_VERSION,规范见 architecture 仓 ADR 0049 §3。`},w=e({meta:{type:`problem`,docs:{description:`要求 bin 指向 dist 产物的包在构建配置声明版本注入`}},createOnce(e){return{before(){if(!p(e.filename))return!1},Program(t){let r=i(e.filename);if(e.filename.replace(/\\/g,`/`).endsWith(`/lzi.config.ts`)&&s.some(e=>n(a(r,e))))return;let o=g(r);if(o===null)return;let c=S(o,e.sourceCode.text);c!==null&&e.report({node:t,message:C[c]})}}}}),T=t({meta:{name:`@longzai-intelligence-oxlint/lzi-builder-config-plugin`},rules:{"require-bin-banner":y,"require-version-injection":w}});export{T as default,T as lziBuilderConfigPlugin,y as requireBinBannerRule};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../rolldown-runtime-BqT_7tdF.js";import"../rolldown-runtime-BqT_7tdF-BT7sSRF3.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=/(^|\/)lzi-[^/]+\.config\.(ts|mts)$/;function r(e){let t=e.replace(/\\/g,`/`);return n.test(t)}function i(e){return typeof e==`object`&&!!e&&`type`in e}function a(e){return i(e)&&e.type===`ObjectExpression`}const o={bareDefaultExport:`lzi 工具配置的默认导出为裸对象字面量,缺少类型防线,字段写错时静态检查无法暴露。请改用 defineConfig 工厂包裹,工具未提供工厂时以 satisfies 标注配置类型。`},s=e({meta:{type:`problem`,docs:{description:`要求 lzi 工具配置默认导出经 defineConfig 或类型约束提供类型防线`}},createOnce(e){return{before(){
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import"../rolldown-runtime-BqT_7tdF-BT7sSRF3.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=/(^|\/)lzi-[^/]+\.config\.(ts|mts)$/;function r(e){let t=e.replace(/\\/g,`/`);return n.test(t)}function i(e){return typeof e==`object`&&!!e&&`type`in e}function a(e){return i(e)&&e.type===`ObjectExpression`}const o={bareDefaultExport:`lzi 工具配置的默认导出为裸对象字面量,缺少类型防线,字段写错时静态检查无法暴露。请改用 defineConfig 工厂包裹,工具未提供工厂时以 satisfies 标注配置类型。`},s=e({meta:{type:`problem`,docs:{description:`要求 lzi 工具配置默认导出经 defineConfig 或类型约束提供类型防线`}},createOnce(e){return{before(){if(!r(e.filename))return!1},ExportDefaultDeclaration(t){t.type===`ExportDefaultDeclaration`&&a(t.declaration)&&e.report({node:t,message:o.bareDefaultExport})}}}});function c(e){return typeof e==`object`&&!!e&&`type`in e}function l(e){if(!c(e)||e.type!==`CallExpression`)return!1;let t=e.callee;if(!c(t)||t.type!==`Identifier`||t.name!==`defineConfig`)return!1;let n=e.arguments??[];if(n.length!==1)return!1;let[r]=n;return!c(r)||r.type!==`ObjectExpression`?!1:(r.properties??[]).length===0}const u={emptyDefineConfigCall:"`defineConfig` 不接受空对象字面量,空配置请使用无参调用 `defineConfig()`。配置文件形态以仓内同类配置先例为准。"},d=e({meta:{type:`problem`,docs:{description:"禁止 `defineConfig` 以空对象字面量为唯一入参,空配置应无参调用"}},createOnce(e){return{before(){if(!r(e.filename))return!1},CallExpression(t){t.type===`CallExpression`&&l(t)&&e.report({node:t,message:u.emptyDefineConfigCall})}}}}),f=t({meta:{name:`@longzai-intelligence-oxlint/lzi-config-plugin`},rules:{"no-empty-define-config":d,"require-define-config":s}});export{f as default,f as lziConfigPlugin,d as noEmptyDefineConfigRule,s as requireDefineConfigRule};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";function n(e){return/\/(apps|packages)\//.test(e)&&e.endsWith(`/package.json`)}function r(e){return e.endsWith(`-infrastructure`)}function i(e){return typeof e==`object`&&!!e}const a=e({meta:{type:`problem`,docs:{description:`禁止 apps/packages 层声明领域基础设施包依赖(ADR 0102:域细节只经域公开面流出)`}},createOnce(e){return{before(){if(!n(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let a=JSON.parse(n);if(!i(a)||!i(a.dependencies))return;let o=Object.keys(a.dependencies).filter(r);o.length>0&&e.report({node:t,message:`禁止 apps/packages 层声明领域基础设施包依赖(ADR 0102):域的持久化实现细节只经域公开面流出。发现依赖 [${o.join(`, `)}]。`})}catch{}}}}});function o(e){return/\/apps\//.test(e)&&e.endsWith(`/package.json`)}function s(e){return typeof e==`object`&&!!e}function c(e){return s(e)?Object.keys(e).filter(e=>e!==`.`):[]}const l=e({meta:{type:`problem`,docs:{description:`禁止 apps 层应用包声明多出口 exports,依据 ADR 0198:应用包 exports 只允许无或单一根出口,跨应用复用一律经根出口取件`}},createOnce(e){return{before(){if(!o(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!s(r))return;let i=c(r.exports);i.length>0&&e.report({node:t,message:`禁止 apps 层应用包声明多出口 exports,依据 ADR 0198:应用包 exports 只允许无或单一根出口,跨应用复用一律经根出口取件。发现子出口 [${i.join(`, `)}]。`})}catch{}}}}}),ee=/* @__PURE__ */ new Set([`tsgo`,`tsc`]),te={bareCompiler:`裸调 tsgo 或 tsc 执行类型检查`,legacyDevCliTypecheck:`使用 lzi-dev-cli typecheck 旧封装,应迁移至 lzi-tsgo typecheck`,wrapperWithoutConfig:`lzi-tsgo typecheck 未传 tsconfig 路径`,wrapperWithoutSubcommand:`调用 lzi-tsgo 未带 typecheck 子命令`};function u(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function d(e){return typeof e==`object`&&!!e}function f(e){return e===`typecheck`||e.startsWith(`typecheck:`)}function p(e){return e.split(/&&|\|\||;|\|/).map(e=>e.trim()).filter(e=>e.length>0)}function m(e){let t=e.split(/\s+/).filter(e=>e.length>0),n=``,r=[];for(let e of t)if(n)r.push(e);else{if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))continue;n=e}return n?{command:n,args:r}:null}function h(e,t,n){let r=m(t);if(!r)return null;let i=r.command,a=r.args;return ee.has(i)?n||a.includes(`--noEmit`)?{key:e,kind:`bareCompiler`,segment:t}:null:n?i===`lzi-tsgo`?a[0]===`typecheck`?a.slice(1).some(e=>!e.startsWith(`-`))?null:{key:e,kind:`wrapperWithoutConfig`,segment:t}:{key:e,kind:`wrapperWithoutSubcommand`,segment:t}:i===`lzi-dev-cli`&&a[0]===`typecheck`?{key:e,kind:`legacyDevCliTypecheck`,segment:t}:null:null}function g(e){let t=[];for(let[n,r]of Object.entries(e)){if(typeof r!=`string`)continue;let e=f(n);for(let i of p(r)){let r=h(n,i,e);r&&t.push(r)}}return t}function ne(e){if(!d(e))return null;let t=e.scripts;return d(t)?t:null}function re(e){return`scripts 键 ${e.key} ${te[e.kind]}。类型检查统一使用 lzi-tsgo typecheck 加 tsconfig 路径,依据 ADR 0057 与 ADR 0117。`}const ie=e({meta:{type:`problem`,docs:{description:`禁止在 package.json scripts 中绕过 lzi-tsgo 封装执行类型检查`}},createOnce(e){return{before(){let t=e.filename;if(!u(t))return!1},Program(t){let n=e.sourceCode.text;try{let r=ne(JSON.parse(n));if(r){let n=g(r);for(let r of n)e.report({node:t,message:re(r)})}}catch{}}}}});function ae(e){return/\/domains\/[^/]+\/implementation\/package\.json$/.test(e)}function _(e){return typeof e==`object`&&!!e}function oe(e,t){if(e===`./domain`)return!0;let n=typeof t==`string`?t:_(t)?[t.types,t.import,t.require,t.default].filter(e=>typeof e==`string`).join(` `):``;return/(^|\/)dist\/domain(\.|\/|$)/.test(n)||/(^|\/)src\/domain(\/|$)/.test(n)}const se={noDomainLayerSubpathExport:"禁止领域实现包声明领域分层子路径导出(ADR 0101):领域分层(domain/)为 implementation 包内私有,仓储端口应落位 contract 包;`./domain` 类子导出属违规逃逸通道。"},ce=e({meta:{type:`problem`,docs:{description:`禁止领域实现包声明领域分层子路径导出(ADR 0101 违规逃逸通道)`}},createOnce(e){return{before(){if(!ae(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!_(r)||!_(r.exports))return;for(let[n,i]of Object.entries(r.exports))n!==`.`&&oe(n,i)&&e.report({node:t,message:`${se.noDomainLayerSubpathExport}(发现子路径 "${n}")`})}catch{}}}}}),le=/* @__PURE__ */ new Set([`@types/bun`,`@types/node`,`@typescript/native-preview`,`oxfmt`,`oxlint`,`tsdown`,`turbo`]),ue=[`@longzai-intelligence-agent-tools/`,`@longzai-intelligence-bun/`,`@longzai-intelligence-builder/`,`@longzai-intelligence-changelog/`,`@longzai-intelligence-decision/`,`@longzai-intelligence-dev-tools/`,`@longzai-intelligence-env/`,`@longzai-intelligence-git/`,`@longzai-intelligence-issues/`,`@longzai-intelligence-oxfmt/`,`@longzai-intelligence-oxlint/`,`@longzai-intelligence-release/`,`@longzai-intelligence-tsgo/`,`@longzai-intelligence-tsdown/`,`@longzai-intelligence-typescript/`,`@longzai-intelligence-vitest/`,`@longzai-intelligence-vscode/`],de=/* @__PURE__ */ new Set([`@longzai-intelligence/typescript-config`]),fe=/* @__PURE__ */ new Set([`@longzai-intelligence-dev-tools/vite-plugin`,`@longzai-intelligence-typescript/rolldown-plugin-type-boundary`]);function pe(e){return/\/(apps|packages|domains|plugins)\//.test(e)&&e.endsWith(`/package.json`)}function me(e){return fe.has(e)?!1:le.has(e)||de.has(e)?!0:ue.some(t=>e.startsWith(t))}function v(e){return typeof e==`object`&&!!e}const y=e({meta:{type:`problem`,docs:{description:`禁止子包声明应放 workspace 根的开发依赖,依据 ADR 0036 根已声明与应放根类别由根统一承载`}},createOnce(e){return{before(){if(!pe(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!v(r)||!v(r.devDependencies)||`workspaces`in r)return;let i=Object.keys(r.devDependencies).filter(me);i.length>0&&e.report({node:t,message:`禁止子包声明应放 workspace 根的开发依赖,ADR 0036 判定根已声明与应放根类别均由根统一承载,子包经 Bun hoisting 取用。发现依赖 [${i.join(`, `)}]。`})}catch{}}}}});function b(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function x(e){return typeof e==`object`&&!!e}const S={noMitLicense:`禁止使用 MIT 协议。项目中的所有包都应使用 "license": "UNLICENSED"。`},C=e({meta:{type:`problem`,docs:{description:`禁止在 package.json 中使用 MIT 协议`}},createOnce(e){return{before(){let t=e.filename;if(!b(t))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);x(r)&&r.license===`MIT`&&e.report({node:t,message:S.noMitLicense})}catch{}}}}});function w(e){return/\/domains\/[^/]+\/infrastructure\/package\.json$/.test(e)}function T(e){return e.endsWith(`-infrastructure`)?`${e.slice(0,-15)}-implementation`:null}function E(e){return typeof e==`object`&&!!e}const D=e({meta:{type:`problem`,docs:{description:`禁止领域基础设施包依赖同域实现包(ADR 0101 依赖图只允许 infrastructure ──> contract)`}},createOnce(e){return{before(){if(!w(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!E(r)||typeof r.name!=`string`)return;let i=T(r.name);if(!i||!E(r.dependencies))return;i in r.dependencies&&e.report({node:t,message:`禁止领域基础设施包依赖同域实现包(ADR 0101):依赖图只允许 infrastructure ──> contract,发现依赖 "${i}"。`})}catch{}}}}});function O(e){return e.endsWith(`/package.json`)}const k=/^(?:\.{1,2}\/)?src\//;function A(e){return typeof e==`object`&&!!e}function j(e,t,n){if(typeof t==`string`)k.test(t)&&n.push({subpath:e,target:t});else if(A(t))for(let r of Object.values(t))j(e,r,n)}function M(e){let t=[];if(typeof e==`string`)return j(`.`,e,t),t;if(A(e))for(let[n,r]of Object.entries(e))j(n,r,t);return t}const N={noSrcExports:`禁止 exports 指向 src 源码(统一 dist 产物范式):包导出一律指向 dist 产物,指向源码会使消费方程序拉入本包源码编译。`},P=e({meta:{type:`problem`,docs:{description:`禁止 exports 指向 src 源码(统一 dist 产物范式门禁)`}},createOnce(e){return{before(){if(!O(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!A(r))return;let i=M(r.exports);for(let n of i)e.report({node:t,message:`${N.noSrcExports}(发现 "${n.subpath}" 指向 "${n.target}")`})}catch{}}}}}),F=[`-domain`,`-contract`,`-implementation`,`-infrastructure`];function I(e){return/\/domains\/[^/]+\/ui\/package\.json$/.test(e)}function L(e){return F.some(t=>e.endsWith(t))}function R(e){return typeof e==`object`&&!!e}const z=e({meta:{type:`problem`,docs:{description:`禁止 domains ui 层声明域内四层包依赖,ADR 0127:UI 面域外依赖唯一指向生成式 sdk 客户端`}},createOnce(e){return{before(){if(!I(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!R(r)||!R(r.dependencies))return;let i=Object.keys(r.dependencies).filter(L);i.length>0&&e.report({node:t,message:`禁止 ui 层声明域内包依赖,ADR 0127:UI 面域外依赖唯一指向生成式 sdk 客户端,DDD 主体对 ui 全封闭。发现依赖 [${i.join(`, `)}]。`})}catch{}}}}});function he(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function ge(e){return e.split(/&&|\|\||;|\|/).map(e=>e.trim()).filter(e=>e.length>0)}function _e(e){let t=e.split(/\s+/).filter(e=>e.length>0),n=``,r=[];for(let e of t)if(n)r.push(e);else{if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))continue;n=e}return n?{command:n,args:r}:null}const ve={buildToolchainMismatch:`build 脚本命令与所属预设的工具链不符`,buildProdToolchainMismatch:`build:prod 脚本命令与所属预设的工具链不符`,devToolchainMismatch:`dev 脚本命令与所属预设的工具链不符`};function B(e){return typeof e==`object`&&!!e}function ye(e){if(!B(e))return!1;for(let t of[`dev`,`build`,`buildProd`]){let n=e[t];if(n!==void 0&&(!Array.isArray(n)||n.some(e=>typeof e!=`string`)))return!1}return!0}function be(e){if(!B(e))return null;let t=e.scripts;return B(t)?t:null}function V(e,t,n,r){if(r===void 0||r.length===0)return[];let i=e[t];if(typeof i!=`string`)return[];let a=[];for(let e of ge(i)){let i=_e(e);i!==null&&(r.includes(i.command)||a.push({key:t,kind:n,command:i.command,allowedList:r.join(`、`)}))}return a}function H(e,t){return[...V(e,`dev`,`devToolchainMismatch`,t.dev),...V(e,`build`,`buildToolchainMismatch`,t.build),...V(e,`build:prod`,`buildProdToolchainMismatch`,t.buildProd)]}function xe(e){return`scripts 键 ${e.key} 使用命令 "${e.command}",${ve[e.kind]},允许清单为 ${e.allowedList}。build 脚本形态按预设校验,依据 ADR 0220,请改用当前预设允许的命令。`}const Se=e({meta:{type:`problem`,docs:{description:`按预设注入的允许清单校验 package.json 的 dev 与 build 与 build:prod 脚本命令形态`},schema:[{type:`object`,properties:{dev:{type:`array`,items:{type:`string`}},build:{type:`array`,items:{type:`string`}},buildProd:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{before(){let t=e.filename;if(!he(t))return!1},Program(t){let n=e.options?.[0];if(!ye(n)||n.dev===void 0&&n.build===void 0&&n.buildProd===void 0)return;let r=e.sourceCode.text;try{let i=be(JSON.parse(r));if(i){let r=H(i,n);for(let n of r)e.report({node:t,message:xe(n)})}}catch{}}}}}),U=[`mcp`,`cli`,`tui`,`dev`];function Ce(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}const we=/^@longzai-intelligence-([a-z0-9][a-z0-9-]*)\//,Te=/^longzai-intelligence-[a-z0-9][a-z0-9-]*$/;function W(e){return typeof e==`object`&&!!e}function Ee(e){let t=e.replace(/\\/g,`/`).split(`/`);for(let e=t.length-2;e>=0;--e){let n=t[e];if(n!==void 0&&Te.test(n))return n.slice(21)}return null}function De(e){let t=we.exec(e);return t===null?null:t[1]??null}function Oe(e,t){return Ee(e)??De(t)}function G(e){return`lzi-${e}`}function K(e){return e.includes(`/`)?e.slice(e.indexOf(`/`)+1):e}function ke(e,t,n){let r=G(t),i=U.find(t=>e===t||e.endsWith(`-${t}`));if(i!==void 0)return`${r}-${i}`;if(n===void 0)return r;let a=K(n);return e.endsWith(`-${a}`)?`${r}-${a}`:r}function q(e,t,n){let r=G(t);return e===r||U.some(t=>e===`${r}-${t}`)?!0:n!==void 0&&e===`${r}-${K(n)}`}function J(e,t){let n=e.bin;return typeof n==`string`?[K(t)]:W(n)?Object.keys(n):[]}const Ae={invalidBinName:`bin 命令名不符合 ADR 0049 完整名称规范,命令名须为 lzi- 前缀加项目全名的 kebab-case 形态,禁止缩写`};function je(e,t){return`${Ae.invalidBinName},实际命令名为 "${e}",应为 "${t}"。`}const Me=e({meta:{type:`problem`,docs:{description:`校验 package.json 的 bin 命令名使用项目全名,禁止缩写,依据 ADR 0049`}},createOnce(e){return{before(){let t=e.filename;if(!Ce(t))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!W(r)||typeof r.name!=`string`||r.bin===void 0||r.name.includes(`{{`))return;let i=Oe(e.filename,r.name);if(i===null)return;let a=J(r,r.name);for(let n of a)n.includes(`{{`)||q(n,i,r.name)||e.report({node:t,message:je(n,ke(n,i,r.name))})}catch{}}}}});function Ne(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function Pe(e){return e.split(/&&|\|\||;|\|/).map(e=>e.trim()).filter(e=>e.length>0)}function Y(e){let t=e.split(/\s+/).filter(e=>e.length>0),n=``,r=[];for(let e of t)if(n)r.push(e);else{if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))continue;n=e}return n?{command:n,args:r}:null}const Fe={testToolchainMismatch:`test 脚本命令与所属预设的工具链不符`,testWatchToolchainMismatch:`test:watch 脚本命令与所属预设的工具链不符`,testCoverageToolchainMismatch:`test:coverage 脚本命令与所属预设的工具链不符`};function X(e){return typeof e==`object`&&!!e}function Ie(e){if(!X(e))return!1;for(let t of[`test`,`testWatch`,`testCoverage`]){let n=e[t];if(n!==void 0&&(!Array.isArray(n)||n.some(e=>typeof e!=`string`)))return!1}return!0}function Le(e){if(!X(e))return null;let t=e.scripts;return X(t)?t:null}function Z(e,t,n,r){if(r===void 0||r.length===0)return[];let i=e[t];if(typeof i!=`string`)return[];let a=[];for(let e of Pe(i)){let i=Y(e);i!==null&&(r.includes(i.command)||a.push({key:t,kind:n,command:i.command,allowedList:r.join(`、`)}))}return a}function Q(e,t){return[...Z(e,`test`,`testToolchainMismatch`,t.test),...Z(e,`test:watch`,`testWatchToolchainMismatch`,t.testWatch),...Z(e,`test:coverage`,`testCoverageToolchainMismatch`,t.testCoverage)]}function Re(e){return`scripts 键 ${e.key} 使用命令 "${e.command}",${Fe[e.kind]},允许清单为 ${e.allowedList}。test 脚本形态按预设校验,依据 ADR 0227,请改用当前预设允许的命令。`}const ze=e({meta:{type:`problem`,docs:{description:`按预设注入的允许清单校验 package.json 的 test 与 test:watch 与 test:coverage 脚本命令形态`},schema:[{type:`object`,properties:{test:{type:`array`,items:{type:`string`}},testWatch:{type:`array`,items:{type:`string`}},testCoverage:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{before(){let t=e.filename;if(!Ne(t))return!1},Program(t){let n=e.options?.[0];if(!Ie(n)||n.test===void 0&&n.testWatch===void 0&&n.testCoverage===void 0)return;let r=e.sourceCode.text;try{let i=Le(JSON.parse(r));if(i){let r=Q(i,n);for(let n of r)e.report({node:t,message:Re(n)})}}catch{}}}}}),$=t({meta:{name:`@longzai-intelligence-oxlint/package-json-plugin`},rules:{"no-app-infrastructure-dependency":a,"no-app-subpath-exports":l,"no-bare-tsgo-invocation":ie,"no-domain-layer-subpath-export":ce,"no-hoistable-dev-dependency":y,"no-mit-license":C,"no-sibling-implementation-dependency":D,"no-src-exports":P,"no-ui-domain-package-dependency":z,"require-build-script-toolchain":Se,"require-full-project-bin-name":Me,"require-test-script-toolchain":ze}});export{$ as default,$ as packageJsonPlugin,H as detectBuildScriptToolchainViolations,Q as detectTestScriptToolchainViolations,J as extractBinNames,c as extractSubpathExits,M as findSrcExportTargets,o as isAppLayerPackageJson,b as isPackageJson,q as isValidBinName,C as noMitLicenseRule};
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";function n(e){return/\/(apps|packages)\//.test(e)&&e.endsWith(`/package.json`)}function r(e){return e.endsWith(`-infrastructure`)}function i(e){return typeof e==`object`&&!!e}const a=e({meta:{type:`problem`,docs:{description:`禁止 apps/packages 层声明领域基础设施包依赖(ADR 0102:域细节只经域公开面流出)`}},createOnce(e){return{before(){if(!n(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let a=JSON.parse(n);if(!i(a)||!i(a.dependencies))return;let o=Object.keys(a.dependencies).filter(r);o.length>0&&e.report({node:t,message:`禁止 apps/packages 层声明领域基础设施包依赖(ADR 0102):域的持久化实现细节只经域公开面流出。发现依赖 [${o.join(`, `)}]。`})}catch{}}}}});function o(e){return/\/apps\//.test(e)&&e.endsWith(`/package.json`)}function s(e){return typeof e==`object`&&!!e}function c(e){return s(e)?Object.keys(e).filter(e=>e!==`.`):[]}const l=e({meta:{type:`problem`,docs:{description:`禁止 apps 层应用包声明多出口 exports,依据 ADR 0198:应用包 exports 只允许无或单一根出口,跨应用复用一律经根出口取件`}},createOnce(e){return{before(){if(!o(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!s(r))return;let i=c(r.exports);i.length>0&&e.report({node:t,message:`禁止 apps 层应用包声明多出口 exports,依据 ADR 0198:应用包 exports 只允许无或单一根出口,跨应用复用一律经根出口取件。发现子出口 [${i.join(`, `)}]。`})}catch{}}}}}),ee=/* @__PURE__ */ new Set([`tsgo`,`tsc`]),te={bareCompiler:`裸调 tsgo 或 tsc 执行类型检查`,legacyDevCliTypecheck:`使用 lzi-dev-cli typecheck 旧封装,应迁移至 lzi-tsgo typecheck`,wrapperWithoutConfig:`lzi-tsgo typecheck 未传 tsconfig 路径`,wrapperWithoutSubcommand:`调用 lzi-tsgo 未带 typecheck 子命令`};function u(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function d(e){return typeof e==`object`&&!!e}function f(e){return e===`typecheck`||e.startsWith(`typecheck:`)}function p(e){return e.split(/&&|\|\||;|\|/).map(e=>e.trim()).filter(e=>e.length>0)}function m(e){let t=e.split(/\s+/).filter(e=>e.length>0),n=``,r=[];for(let e of t)if(n)r.push(e);else{if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))continue;n=e}return n?{command:n,args:r}:null}function h(e,t,n){let r=m(t);if(!r)return null;let i=r.command,a=r.args;return ee.has(i)?n||a.includes(`--noEmit`)?{key:e,kind:`bareCompiler`,segment:t}:null:n?i===`lzi-tsgo`?a[0]===`typecheck`?a.slice(1).some(e=>!e.startsWith(`-`))?null:{key:e,kind:`wrapperWithoutConfig`,segment:t}:{key:e,kind:`wrapperWithoutSubcommand`,segment:t}:i===`lzi-dev-cli`&&a[0]===`typecheck`?{key:e,kind:`legacyDevCliTypecheck`,segment:t}:null:null}function g(e){let t=[];for(let[n,r]of Object.entries(e)){if(typeof r!=`string`)continue;let e=f(n);for(let i of p(r)){let r=h(n,i,e);r&&t.push(r)}}return t}function ne(e){if(!d(e))return null;let t=e.scripts;return d(t)?t:null}function re(e){return`scripts 键 ${e.key} ${te[e.kind]}。类型检查统一使用 lzi-tsgo typecheck 加 tsconfig 路径,依据 ADR 0057 与 ADR 0117。`}const ie=e({meta:{type:`problem`,docs:{description:`禁止在 package.json scripts 中绕过 lzi-tsgo 封装执行类型检查`}},createOnce(e){return{before(){if(!u(e.filename))return!1},Program(t){let n=e.sourceCode.text;try{let r=ne(JSON.parse(n));if(r){let n=g(r);for(let r of n)e.report({node:t,message:re(r)})}}catch{}}}}});function ae(e){return/\/domains\/[^/]+\/implementation\/package\.json$/.test(e)}function _(e){return typeof e==`object`&&!!e}function oe(e,t){if(e===`./domain`)return!0;let n=typeof t==`string`?t:_(t)?[t.types,t.import,t.require,t.default].filter(e=>typeof e==`string`).join(` `):``;return/(^|\/)dist\/domain(\.|\/|$)/.test(n)||/(^|\/)src\/domain(\/|$)/.test(n)}const se={noDomainLayerSubpathExport:"禁止领域实现包声明领域分层子路径导出(ADR 0101):领域分层(domain/)为 implementation 包内私有,仓储端口应落位 contract 包;`./domain` 类子导出属违规逃逸通道。"},ce=e({meta:{type:`problem`,docs:{description:`禁止领域实现包声明领域分层子路径导出(ADR 0101 违规逃逸通道)`}},createOnce(e){return{before(){if(!ae(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!_(r)||!_(r.exports))return;for(let[n,i]of Object.entries(r.exports))n!==`.`&&oe(n,i)&&e.report({node:t,message:`${se.noDomainLayerSubpathExport}(发现子路径 "${n}")`})}catch{}}}}}),le=/* @__PURE__ */ new Set([`@types/bun`,`@types/node`,`@typescript/native-preview`,`oxfmt`,`oxlint`,`tsdown`,`turbo`]),ue=[`@longzai-intelligence-agent-tools/`,`@longzai-intelligence-bun/`,`@longzai-intelligence-builder/`,`@longzai-intelligence-changelog/`,`@longzai-intelligence-decision/`,`@longzai-intelligence-dev-tools/`,`@longzai-intelligence-env/`,`@longzai-intelligence-git/`,`@longzai-intelligence-issues/`,`@longzai-intelligence-oxfmt/`,`@longzai-intelligence-oxlint/`,`@longzai-intelligence-release/`,`@longzai-intelligence-tsgo/`,`@longzai-intelligence-tsdown/`,`@longzai-intelligence-typescript/`,`@longzai-intelligence-vitest/`,`@longzai-intelligence-vscode/`],de=/* @__PURE__ */ new Set([`@longzai-intelligence/typescript-config`]),fe=/* @__PURE__ */ new Set([`@longzai-intelligence-dev-tools/vite-plugin`,`@longzai-intelligence-typescript/rolldown-plugin-type-boundary`]);function pe(e){return/\/(apps|packages|domains|plugins)\//.test(e)&&e.endsWith(`/package.json`)}function me(e){return fe.has(e)?!1:le.has(e)||de.has(e)?!0:ue.some(t=>e.startsWith(t))}function v(e){return typeof e==`object`&&!!e}const y=e({meta:{type:`problem`,docs:{description:`禁止子包声明应放 workspace 根的开发依赖,依据 ADR 0036 根已声明与应放根类别由根统一承载`}},createOnce(e){return{before(){if(!pe(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!v(r)||!v(r.devDependencies)||`workspaces`in r)return;let i=Object.keys(r.devDependencies).filter(me);i.length>0&&e.report({node:t,message:`禁止子包声明应放 workspace 根的开发依赖,ADR 0036 判定根已声明与应放根类别均由根统一承载,子包经 Bun hoisting 取用。发现依赖 [${i.join(`, `)}]。`})}catch{}}}}});function b(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function x(e){return typeof e==`object`&&!!e}const S={noMitLicense:`禁止使用 MIT 协议。项目中的所有包都应使用 "license": "UNLICENSED"。`},C=e({meta:{type:`problem`,docs:{description:`禁止在 package.json 中使用 MIT 协议`}},createOnce(e){return{before(){if(!b(e.filename))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);x(r)&&r.license===`MIT`&&e.report({node:t,message:S.noMitLicense})}catch{}}}}});function w(e){return/\/domains\/[^/]+\/infrastructure\/package\.json$/.test(e)}function T(e){return e.endsWith(`-infrastructure`)?`${e.slice(0,-15)}-implementation`:null}function E(e){return typeof e==`object`&&!!e}const D=e({meta:{type:`problem`,docs:{description:`禁止领域基础设施包依赖同域实现包(ADR 0101 依赖图只允许 infrastructure ──> contract)`}},createOnce(e){return{before(){if(!w(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!E(r)||typeof r.name!=`string`)return;let i=T(r.name);if(!i||!E(r.dependencies))return;i in r.dependencies&&e.report({node:t,message:`禁止领域基础设施包依赖同域实现包(ADR 0101):依赖图只允许 infrastructure ──> contract,发现依赖 "${i}"。`})}catch{}}}}});function O(e){return e.endsWith(`/package.json`)}const k=/^(?:\.{1,2}\/)?src\//;function A(e){return typeof e==`object`&&!!e}function j(e,t,n){if(typeof t==`string`)k.test(t)&&n.push({subpath:e,target:t});else if(A(t))for(let r of Object.values(t))j(e,r,n)}function M(e){let t=[];if(typeof e==`string`)return j(`.`,e,t),t;if(A(e))for(let[n,r]of Object.entries(e))j(n,r,t);return t}const N={noSrcExports:`禁止 exports 指向 src 源码(统一 dist 产物范式):包导出一律指向 dist 产物,指向源码会使消费方程序拉入本包源码编译。`},P=e({meta:{type:`problem`,docs:{description:`禁止 exports 指向 src 源码(统一 dist 产物范式门禁)`}},createOnce(e){return{before(){if(!O(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!A(r))return;let i=M(r.exports);for(let n of i)e.report({node:t,message:`${N.noSrcExports}(发现 "${n.subpath}" 指向 "${n.target}")`})}catch{}}}}}),F=[`-domain`,`-contract`,`-implementation`,`-infrastructure`];function I(e){return/\/domains\/[^/]+\/ui\/package\.json$/.test(e)}function L(e){return F.some(t=>e.endsWith(t))}function R(e){return typeof e==`object`&&!!e}const z=e({meta:{type:`problem`,docs:{description:`禁止 domains ui 层声明域内四层包依赖,ADR 0127:UI 面域外依赖唯一指向生成式 sdk 客户端`}},createOnce(e){return{before(){if(!I(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!R(r)||!R(r.dependencies))return;let i=Object.keys(r.dependencies).filter(L);i.length>0&&e.report({node:t,message:`禁止 ui 层声明域内包依赖,ADR 0127:UI 面域外依赖唯一指向生成式 sdk 客户端,DDD 主体对 ui 全封闭。发现依赖 [${i.join(`, `)}]。`})}catch{}}}}});function he(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function ge(e){return e.split(/&&|\|\||;|\|/).map(e=>e.trim()).filter(e=>e.length>0)}function _e(e){let t=e.split(/\s+/).filter(e=>e.length>0),n=``,r=[];for(let e of t)if(n)r.push(e);else{if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))continue;n=e}return n?{command:n,args:r}:null}const ve={buildToolchainMismatch:`build 脚本命令与所属预设的工具链不符`,buildProdToolchainMismatch:`build:prod 脚本命令与所属预设的工具链不符`,devToolchainMismatch:`dev 脚本命令与所属预设的工具链不符`};function B(e){return typeof e==`object`&&!!e}function ye(e){if(!B(e))return!1;for(let t of[`dev`,`build`,`buildProd`]){let n=e[t];if(n!==void 0&&(!Array.isArray(n)||n.some(e=>typeof e!=`string`)))return!1}return!0}function be(e){if(!B(e))return null;let t=e.scripts;return B(t)?t:null}function V(e,t,n,r){if(r===void 0||r.length===0)return[];let i=e[t];if(typeof i!=`string`)return[];let a=[];for(let e of ge(i)){let i=_e(e);i!==null&&(r.includes(i.command)||a.push({key:t,kind:n,command:i.command,allowedList:r.join(`、`)}))}return a}function H(e,t){return[...V(e,`dev`,`devToolchainMismatch`,t.dev),...V(e,`build`,`buildToolchainMismatch`,t.build),...V(e,`build:prod`,`buildProdToolchainMismatch`,t.buildProd)]}function xe(e){return`scripts 键 ${e.key} 使用命令 "${e.command}",${ve[e.kind]},允许清单为 ${e.allowedList}。build 脚本形态按预设校验,依据 ADR 0220,请改用当前预设允许的命令。`}const Se=e({meta:{type:`problem`,docs:{description:`按预设注入的允许清单校验 package.json 的 dev 与 build 与 build:prod 脚本命令形态`},schema:[{type:`object`,properties:{dev:{type:`array`,items:{type:`string`}},build:{type:`array`,items:{type:`string`}},buildProd:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{before(){if(!he(e.filename))return!1},Program(t){let n=e.options?.[0];if(!ye(n)||n.dev===void 0&&n.build===void 0&&n.buildProd===void 0)return;let r=e.sourceCode.text;try{let i=be(JSON.parse(r));if(i){let r=H(i,n);for(let n of r)e.report({node:t,message:xe(n)})}}catch{}}}}}),U=[`mcp`,`cli`,`tui`,`dev`];function Ce(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}const we=/^@longzai-intelligence-([a-z0-9][a-z0-9-]*)\//,Te=/^longzai-intelligence-[a-z0-9][a-z0-9-]*$/;function W(e){return typeof e==`object`&&!!e}function Ee(e){let t=e.replace(/\\/g,`/`).split(`/`);for(let e=t.length-2;e>=0;--e){let n=t[e];if(n!==void 0&&Te.test(n))return n.slice(21)}return null}function De(e){let t=we.exec(e);return t===null?null:t[1]??null}function Oe(e,t){return Ee(e)??De(t)}function G(e){return`lzi-${e}`}function K(e){return e.includes(`/`)?e.slice(e.indexOf(`/`)+1):e}function ke(e,t,n){let r=G(t),i=U.find(t=>e===t||e.endsWith(`-${t}`));if(i!==void 0)return`${r}-${i}`;if(n===void 0)return r;let a=K(n);return e.endsWith(`-${a}`)?`${r}-${a}`:r}function q(e,t,n){let r=G(t);return e===r||U.some(t=>e===`${r}-${t}`)?!0:n!==void 0&&e===`${r}-${K(n)}`}function J(e,t){let n=e.bin;return typeof n==`string`?[K(t)]:W(n)?Object.keys(n):[]}const Ae={invalidBinName:`bin 命令名不符合 ADR 0049 完整名称规范,命令名须为 lzi- 前缀加项目全名的 kebab-case 形态,禁止缩写`};function je(e,t){return`${Ae.invalidBinName},实际命令名为 "${e}",应为 "${t}"。`}const Me=e({meta:{type:`problem`,docs:{description:`校验 package.json 的 bin 命令名使用项目全名,禁止缩写,依据 ADR 0049`}},createOnce(e){return{before(){if(!Ce(e.filename))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!W(r)||typeof r.name!=`string`||r.bin===void 0||r.name.includes(`{{`))return;let i=Oe(e.filename,r.name);if(i===null)return;let a=J(r,r.name);for(let n of a)n.includes(`{{`)||q(n,i,r.name)||e.report({node:t,message:je(n,ke(n,i,r.name))})}catch{}}}}});function Ne(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function Pe(e){return e.split(/&&|\|\||;|\|/).map(e=>e.trim()).filter(e=>e.length>0)}function Y(e){let t=e.split(/\s+/).filter(e=>e.length>0),n=``,r=[];for(let e of t)if(n)r.push(e);else{if(/^[A-Za-z_][A-Za-z0-9_]*=/.test(e))continue;n=e}return n?{command:n,args:r}:null}const Fe={testToolchainMismatch:`test 脚本命令与所属预设的工具链不符`,testWatchToolchainMismatch:`test:watch 脚本命令与所属预设的工具链不符`,testCoverageToolchainMismatch:`test:coverage 脚本命令与所属预设的工具链不符`};function X(e){return typeof e==`object`&&!!e}function Ie(e){if(!X(e))return!1;for(let t of[`test`,`testWatch`,`testCoverage`]){let n=e[t];if(n!==void 0&&(!Array.isArray(n)||n.some(e=>typeof e!=`string`)))return!1}return!0}function Le(e){if(!X(e))return null;let t=e.scripts;return X(t)?t:null}function Z(e,t,n,r){if(r===void 0||r.length===0)return[];let i=e[t];if(typeof i!=`string`)return[];let a=[];for(let e of Pe(i)){let i=Y(e);i!==null&&(r.includes(i.command)||a.push({key:t,kind:n,command:i.command,allowedList:r.join(`、`)}))}return a}function Q(e,t){return[...Z(e,`test`,`testToolchainMismatch`,t.test),...Z(e,`test:watch`,`testWatchToolchainMismatch`,t.testWatch),...Z(e,`test:coverage`,`testCoverageToolchainMismatch`,t.testCoverage)]}function Re(e){return`scripts 键 ${e.key} 使用命令 "${e.command}",${Fe[e.kind]},允许清单为 ${e.allowedList}。test 脚本形态按预设校验,依据 ADR 0227,请改用当前预设允许的命令。`}const ze=e({meta:{type:`problem`,docs:{description:`按预设注入的允许清单校验 package.json 的 test 与 test:watch 与 test:coverage 脚本命令形态`},schema:[{type:`object`,properties:{test:{type:`array`,items:{type:`string`}},testWatch:{type:`array`,items:{type:`string`}},testCoverage:{type:`array`,items:{type:`string`}}},additionalProperties:!1}]},createOnce(e){return{before(){if(!Ne(e.filename))return!1},Program(t){let n=e.options?.[0];if(!Ie(n)||n.test===void 0&&n.testWatch===void 0&&n.testCoverage===void 0)return;let r=e.sourceCode.text;try{let i=Le(JSON.parse(r));if(i){let r=Q(i,n);for(let n of r)e.report({node:t,message:Re(n)})}}catch{}}}}}),$=t({meta:{name:`@longzai-intelligence-oxlint/package-json-plugin`},rules:{"no-app-infrastructure-dependency":a,"no-app-subpath-exports":l,"no-bare-tsgo-invocation":ie,"no-domain-layer-subpath-export":ce,"no-hoistable-dev-dependency":y,"no-mit-license":C,"no-sibling-implementation-dependency":D,"no-src-exports":P,"no-ui-domain-package-dependency":z,"require-build-script-toolchain":Se,"require-full-project-bin-name":Me,"require-test-script-toolchain":ze}});export{$ as default,$ as packageJsonPlugin,H as detectBuildScriptToolchainViolations,Q as detectTestScriptToolchainViolations,J as extractBinNames,c as extractSubpathExits,M as findSrcExportTargets,o as isAppLayerPackageJson,b as isPackageJson,q as isValidBinName,C as noMitLicenseRule};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../rolldown-runtime-BqT_7tdF.js";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(){
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";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(){if(!r(e.filename))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(){if(!a(e.filename))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};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import"../rolldown-runtime-BqT_7tdF.js";import{
|
|
2
|
-
`)}})}}function P(e,t,n,r,i){let a=e.type===`Block`;if(a&&n.afterBlockComment||!a&&n.afterLineComment){if(M(i,n))return;
|
|
3
|
-
`)})}}function F(e,t,n,r,i=[],a=!1,o=!1){if(b(e,t)||C(e,n))return;let s=x(e,i),c=m(e,t),l=ee(e,t)||te(e,t),u=re(e,t);a||s||l||u||N(e,t,n,r,c),o||P(e,t,n,r,c)}const ie=
|
|
4
|
-
`),n=[];let i=e.sourceCode.getAllComments();for(let a=0;a<i.length;a++){let o=i[a];if(!o)continue;let s=i[a+1],c=s!==void 0&&s.loc.start.line<=o.loc.end.line+1;F(o,t,r,e,n,!1,c),n.push(o)}}}}}),I=[`eslint`,`oxlint`,`jshint`,`jslint`,`tslint`,`istanbul`,`global`,`exported`,`jscs`],L=[`<reference`,`<amd-module`,`<amd-dependency`,`@ts-`],R=/^\*?\s*$/u,z=/^\s*$/u,B=`禁止双斜杠注释,只允许多行块注释`;function V(e){let t=e.value.trim(),n=t.replace(/^\/+/u,``).trim();return I.some(e=>t.startsWith(e))||L.some(e=>n.startsWith(e))}function H(
|
|
1
|
+
import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";import{parseSeparatorComment as n}from"./tsdoc.js";function r(){return{isBlockStart:!1,isBlockEnd:!1,isObjectStart:!1,isObjectEnd:!1,isArrayStart:!1,isArrayEnd:!1,isClassStart:!1,isClassEnd:!1,isInterfaceStart:!1,isInterfaceEnd:!1,isTypeStart:!1,isTypeEnd:!1,isEnumStart:!1,isEnumEnd:!1,isModuleStart:!1,isModuleEnd:!1,isFunctionStart:!1,isFunctionEnd:!1}}function i(e){return!!(e.includes(`type `)||e.includes(`extends {`)||e.includes(`type{`)||e.includes(`Array<{`)||e.includes(`Promise<{`)||e.includes(`<{`)||e.includes(`| {`)||e.includes(`as {`)||e.includes(`Record<{`)||e.includes(`Partial<{`)||e.includes(`Required<{`)||e.includes(`Pick<{`)||e.includes(`Omit<{`)||e.includes(`& {`))}function a(e,t){for(let n=2;n<=5&&t>n;n++){let r=e[t-n-1];if(r){let e=r.trimEnd();if(e.includes(`Record<{`)||e.includes(`Partial<{`)||e.includes(`Required<{`)||e.includes(`Pick<{`)||e.includes(`Omit<{`)||e.includes(`Array<{`)||e.includes(`Promise<{`)||e.includes(`type `)||e.includes(`interface `))return!0}}return!1}function o(e){return e.endsWith(`) {`)||e.endsWith(`){`)||/\)\s*(?::\s*[^{]+)?\{/.test(e)||e.includes(`=> {`)}function s(e){return!!(e.endsWith(`) {`)||e.endsWith(`){`)||e===`{`||/: [^{]+ \{$/.test(e)||/\)\s*(?::\s*[^{]+)?\{/.test(e)||e.endsWith(`}> {`)||e===`> {`||e.includes(`try {`)||e.includes(`catch {`)||e.includes(`finally {`)||e.includes(`=> {`)||e.includes(`else {`)||/^\w+\s*\{$/.test(e)||/^\| .+ \{$/.test(e))}function c(e){let t=e.includes(`namespace `)||e.includes(`namespace{`),n=e.startsWith(`declare global`)||e.startsWith(`declare module`);return e.includes(`module `)||e.includes(`module{`)||t||n}function l(e,t){for(let n=2;n<=10&&t>n;n++){let r=e[t-n-1];if(r){let e=r.trim();if(e.includes(`class `)||e.includes(`class{`))return!0}}return!1}function u(e){let t=/\w\(\{$/.test(e),n=e.endsWith(`, {`),r=/=>\s*\(\{$/.test(e),i=e.includes(`export default {`);return e.includes(`: {`)||e.endsWith(`= {`)||t||n||r||i}function d(e,t,n,r){i(t)?e.isTypeStart=!0:t.trim()===`{`?e[a(n,r)?`isTypeStart`:`isBlockStart`]=!0:t.includes(`interface `)||t.includes(`interface{`)?e.isInterfaceStart=!0:t.includes(`enum `)||t.includes(`enum{`)?e.isEnumStart=!0:c(t)?e.isModuleStart=!0:t.includes(`class `)||t.includes(`class{`)||t===`> {`?e.isClassStart=!0:s(t)?(e.isBlockStart=!0,o(t)&&(e.isFunctionStart=!0)):u(t)?e.isObjectStart=!0:t.includes(`: [`)||t.endsWith(`= [`)||t.endsWith(`[`)?e.isArrayStart=!0:l(n,r)&&(e.isClassStart=!0)}function f(e,t,n){if(t<=1)return;let r=t-2;for(;r>=0;){let e=n[r];if(e&&e.trim().length>0)break;r--}if(r<0)return;let i=n[r];if(!i)return;let a=i.trim();a.endsWith(`{`)||/>+\s*\{\s*$/.test(a)?d(e,a,n,t):a.endsWith(`(`)||a.endsWith(`>`)?e.isBlockStart=!0:a.endsWith(`[`)&&(e.isArrayStart=!0)}function p(e,t,n){if(t>=n.length)return;let r=n[t];if(!r)return;let i=r.trimStart();i===`}`||i===`};`?(e.isBlockEnd=!0,e.isObjectEnd=!0,e.isClassEnd=!0,e.isInterfaceEnd=!0,e.isTypeEnd=!0,e.isEnumEnd=!0,e.isModuleEnd=!0,e.isFunctionEnd=!0):i.startsWith(`];`)&&(e.isArrayEnd=!0)}function m(e,t){let n=r(),i=e.loc.start.line,a=e.loc.end.line;return f(n,i,t),p(n,a,t),n}const h={beforeBlockComment:!0,afterBlockComment:!1,beforeLineComment:!1,afterLineComment:!1,allowBlockStart:!1,allowBlockEnd:!1,allowObjectStart:!1,allowObjectEnd:!1,allowArrayStart:!1,allowArrayEnd:!1,allowClassStart:!1,allowClassEnd:!1,allowInterfaceStart:!1,allowInterfaceEnd:!1,allowTypeStart:!1,allowTypeEnd:!1,allowEnumStart:!1,allowEnumEnd:!1,allowModuleStart:!1,allowModuleEnd:!1,allowFunctionStart:!1,allowFunctionEnd:!1,ignorePattern:void 0,applyDefaultIgnorePatterns:!0};function ee(e,t){if(e.loc.start.line<=1)return!1;let n=g(e.loc.start.line,t);return n?/\w+=\{$/.test(n):!1}function te(e,t){if(e.loc.start.line<=1)return!1;let n=g(e.loc.start.line,t);if(!n||!(n===`}`||/^\w+=("[^"]*"|'[^']*')$/.test(n)||/^\w+=\{.+\}$/.test(n)||/^<[A-Z]\w*$/.test(n)||/^\w+:$/.test(n)))return!1;let r=_(e.loc.end.line,t);return r?/^\w+=/.test(r)||/^\/?>$/.test(r)||r.startsWith(`/>`)||r.startsWith(`(`)||r.startsWith(`<`):!1}const ne=/(?:,|:|\?|=>|&&|\|\||=|[+*/%&|^<-])$/u;function re(e,t){if(e.loc.start.line<=1)return!1;let n=y(e.loc.start.line,t);return n?ne.test(n):!1}function g(e,t){let n=e-2;for(;n>=0;){let e=t[n];if(e&&e.trim().length>0)return e.trim();n--}return null}function _(e,t){let n=e;for(;n<t.length;){let e=t[n];if(e&&e.trim().length>0)return e.trim();n++}return null}function v(e){return e.startsWith(`//`)||e.startsWith(`/*`)||e.startsWith(`*`)}function y(e,t){let n=e-2;for(;n>=0;){let e=t[n];if(e&&e.trim().length>0&&!v(e.trim()))return e.trim();n--}return null}function b(e,t){let n=t[e.loc.start.line-1];return n?n.slice(0,e.loc.start.column).trim().length>0:!1}function x(e,t){if(t.length===0)return!1;let n=t[t.length-1];return n?n.loc.end.line+1>=e.loc.start.line:!1}const S=[/^eslint/i,/^jshint/i,/^jslint/i,/^istanbul/i,/^global/i,/^exported/i,/^jscs/i];function C(e,t){let n=e.value.trim();if(t.applyDefaultIgnorePatterns!==!1){for(let e of S)if(e.test(n))return!0}return!!(t.ignorePattern&&new RegExp(t.ignorePattern,`u`).test(n))}function w(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function T(e,t,n){let r=t[n];typeof r==`boolean`&&(e[n]=r)}function E(e,t){T(e,t,`beforeBlockComment`),T(e,t,`afterBlockComment`),T(e,t,`beforeLineComment`),T(e,t,`afterLineComment`),T(e,t,`allowBlockStart`),T(e,t,`allowBlockEnd`),T(e,t,`allowObjectStart`),T(e,t,`allowObjectEnd`),T(e,t,`allowArrayStart`),T(e,t,`allowArrayEnd`),T(e,t,`allowClassStart`),T(e,t,`allowClassEnd`),T(e,t,`allowInterfaceStart`),T(e,t,`allowInterfaceEnd`),T(e,t,`allowTypeStart`),T(e,t,`allowTypeEnd`),T(e,t,`allowEnumStart`),T(e,t,`allowEnumEnd`),T(e,t,`allowModuleStart`),T(e,t,`allowModuleEnd`),T(e,t,`allowFunctionStart`),T(e,t,`allowFunctionEnd`),T(e,t,`applyDefaultIgnorePatterns`)}function D(e,t,n){let r=t[n];typeof r==`string`&&(e[n]=r)}function O(e){let t={...h};return w(e)&&(E(t,e),D(t,e,`ignorePattern`)),t}function k(e,t){return e<=1||t[e-2]?.trim()===``}function A(e,t){return e>=t.length||t[e]?.trim()===``}function j(e,t){return e.isBlockStart&&(t.allowBlockStart??!1)||e.isObjectStart&&(t.allowObjectStart??!1)||e.isArrayStart&&(t.allowArrayStart??!1)||e.isClassStart&&(t.allowClassStart??!1)||e.isInterfaceStart&&(t.allowInterfaceStart??!1)||e.isTypeStart&&(t.allowTypeStart??!1)||e.isEnumStart&&(t.allowEnumStart??!1)||e.isModuleStart&&(t.allowModuleStart??!1)||e.isFunctionStart&&(t.allowFunctionStart??!1)}function M(e,t){return e.isBlockEnd&&(t.allowBlockEnd??!1)||e.isObjectEnd&&(t.allowObjectEnd??!1)||e.isArrayEnd&&(t.allowArrayEnd??!1)||e.isClassEnd&&(t.allowClassEnd??!1)||e.isInterfaceEnd&&(t.allowInterfaceEnd??!1)||e.isTypeEnd&&(t.allowTypeEnd??!1)||e.isEnumEnd&&(t.allowEnumEnd??!1)||e.isModuleEnd&&(t.allowModuleEnd??!1)||e.isFunctionEnd&&(t.allowFunctionEnd??!1)}function N(e,t,n,r,i){let a=e.type===`Block`;if(a&&n.beforeBlockComment||!a&&n.beforeLineComment){if(j(i,n))return;k(e.loc.start.line,t)||r.report({loc:{start:e.loc.start,end:e.loc.start},message:a?`块注释前需要空行`:`行注释前需要空行`,fix:n=>{let r=0;for(let n=0;n<e.loc.start.line-1;n++)r+=(t[n]?.length??0)+1;return n.insertTextBeforeRange([r,r],`
|
|
2
|
+
`)}})}}function P(e,t,n,r,i){let a=e.type===`Block`;if(a&&n.afterBlockComment||!a&&n.afterLineComment){if(M(i,n))return;A(e.loc.end.line,t)||r.report({loc:{start:e.loc.end,end:e.loc.end},message:a?`块注释后需要空行`:`行注释后需要空行`,fix:t=>t.insertTextAfterRange([e.range[1],e.range[1]],`
|
|
3
|
+
`)})}}function F(e,t,n,r,i=[],a=!1,o=!1){if(b(e,t)||C(e,n))return;let s=x(e,i),c=m(e,t),l=ee(e,t)||te(e,t),u=re(e,t);a||s||l||u||N(e,t,n,r,c),o||P(e,t,n,r,c)}const ie=e({meta:{type:`layout`,fixable:`whitespace`,docs:{description:`要求在注释前后有空行`},schema:[{type:`object`,properties:{beforeBlockComment:{type:`boolean`},afterBlockComment:{type:`boolean`},beforeLineComment:{type:`boolean`},afterLineComment:{type:`boolean`},allowBlockStart:{type:`boolean`},allowBlockEnd:{type:`boolean`},allowObjectStart:{type:`boolean`},allowObjectEnd:{type:`boolean`},allowArrayStart:{type:`boolean`},allowArrayEnd:{type:`boolean`},allowClassStart:{type:`boolean`},allowClassEnd:{type:`boolean`},allowInterfaceStart:{type:`boolean`},allowInterfaceEnd:{type:`boolean`},allowTypeStart:{type:`boolean`},allowTypeEnd:{type:`boolean`},allowEnumStart:{type:`boolean`},allowEnumEnd:{type:`boolean`},allowModuleStart:{type:`boolean`},allowModuleEnd:{type:`boolean`},allowFunctionStart:{type:`boolean`},allowFunctionEnd:{type:`boolean`},ignorePattern:{type:`string`},applyDefaultIgnorePatterns:{type:`boolean`}},additionalProperties:!1}]},createOnce(e){let t=[],n=[];return{Program(){let r=O(e.options?.[0]);t=e.sourceCode.text.split(`
|
|
4
|
+
`),n=[];let i=e.sourceCode.getAllComments();for(let a=0;a<i.length;a++){let o=i[a];if(!o)continue;let s=i[a+1],c=s!==void 0&&s.loc.start.line<=o.loc.end.line+1;F(o,t,r,e,n,!1,c),n.push(o)}}}}}),I=[`eslint`,`oxlint`,`jshint`,`jslint`,`tslint`,`istanbul`,`global`,`exported`,`jscs`],L=[`<reference`,`<amd-module`,`<amd-dependency`,`@ts-`],R=/^\*?\s*$/u,z=/^\s*$/u,B=`禁止双斜杠注释,只允许多行块注释`;function V(e){let t=e.value.trim(),n=t.replace(/^\/+/u,``).trim();return I.some(e=>t.startsWith(e))||L.some(e=>n.startsWith(e))}function H(e){return e.type===`Line`&&n(e.value)!==null}function U(e,t){let n=t[e.loc.start.line-1];if(!n)return` `.repeat(e.loc.start.column);let r=n.slice(0,e.loc.start.column);return r.trim().length>0?` `.repeat(e.loc.start.column):r}function W(e){let t=[];for(let n of e){let e=t[t.length-1];if(e){let t=e[e.length-1];if(t&&t.loc.end.line===n.loc.start.line-1){e.push(n);continue}}t.push([n])}return t}function G(e){return e.map(e=>e.value)}function K(e,t){return`/*\n${e.map(e=>{let n=e.trim();return n?`${t} * ${n}`:`${t} *`}).join(`
|
|
5
5
|
`)}\n${t} */`}function q(e,t){let n=e.trim(),r=n.startsWith(`*`),i=r?n.slice(1).trim():n,a=r?`/**`:`/*`;return i?`${a}\n${t} * ${i}\n${t} */`:`${a}\n${t} */`}function J(e,t){let n=e.value.split(`
|
|
6
6
|
`),r=0;for(let e=0;e<t;e++)r+=(n[e]?.length??0)+1;return e.range[0]+2+r}function Y(e,t){let n=[],r=[];for(let i of e)b(i,t)?n.push({message:B,loc:{start:{...i.loc.start},end:{...i.loc.end}}}):r.push(i);for(let e of W(r)){let r=e[0],i=e[e.length-1];if(!r||!i)continue;let a=U(r,t),o=G(e),s=o.some(e=>e.trim().startsWith(`/`));n.push({message:B,loc:{start:{...r.loc.start},end:{...i.loc.end}},fix:s?void 0:{range:[r.range[0],i.range[1]],text:K(o,a)}})}return n}function ae(e,t){let n=[],r=e.value.split(`
|
|
7
|
-
`),i=U(e,t);if(e.loc.start.line===e.loc.end.line)return n.push({message:`禁止单行块注释,注释须为多行星号块形态`,loc:{start:{...e.loc.start},end:{...e.loc.end}},fix:{range:[e.range[0],e.range[1]],text:q(e.value,i)}}),n;let a=r[0]??``;if(!R.test(a)){let t=+!!a.startsWith(`*`),r=e.range[0]+2+t;n.push({message:`多行块注释的首行应在 "/*" 后换行`,loc:{start:{...e.loc.start},end:{...e.loc.end}},fix:{range:[r,r],text:`\n${i} *`}})}for(let t=1;t<r.length-1;t++){let a=r[t]??``,o=a.trim();if(!o||o.startsWith(`*`))continue;let s=J(e,t),c=a.length-a.trimStart().length;n.push({message:`多行注释的中间行应以 "*" 开头`,loc:{start:{line:e.loc.start.line+t,column:0},end:{line:e.loc.start.line+t,column:a.length}},fix:{range:[s,s+c],text:`${i} * `}})}let o=r[r.length-1]??``;return z.test(o)||n.push({message:`多行块注释的末行应在 "*/" 前换行`,loc:{start:{...e.loc.start},end:{...e.loc.end}},fix:{range:[e.range[1]-2,e.range[1]-2],text:`\n${i} `}}),n}function oe(e,t){let n=[],r=[];for(let i of e)i.type!==`Shebang`&&(V(i)||H(i)||(i.type===`Line`?r.push(i):n.push(...ae(i,t))));return n.push(...Y(r,t)),n}const se=
|
|
8
|
-
`));for(let t of i){let{fix:n}=t;e.report({loc:t.loc,message:t.message,fix:n?e=>e.replaceTextRange(n.range,n.text):void 0})}}}}});function X(e){return e.type===`ExportNamedDeclaration`||e.type===`ExportDefaultDeclaration`||e.type===`ExportAllDeclaration`}function ce(e,t,n){if(n-t<=1)return!1;for(let r=t+1;r<n;r++)if(e[r-1]?.trim()===``)return!0;return!1}function Z(e){return e.type===`Program`}function le(e,t,n){for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];
|
|
9
|
-
`),r=Z(t)?t:null;r&&le(r.body,n,e)}}}})},$=
|
|
7
|
+
`),i=U(e,t);if(e.loc.start.line===e.loc.end.line)return n.push({message:`禁止单行块注释,注释须为多行星号块形态`,loc:{start:{...e.loc.start},end:{...e.loc.end}},fix:{range:[e.range[0],e.range[1]],text:q(e.value,i)}}),n;let a=r[0]??``;if(!R.test(a)){let t=+!!a.startsWith(`*`),r=e.range[0]+2+t;n.push({message:`多行块注释的首行应在 "/*" 后换行`,loc:{start:{...e.loc.start},end:{...e.loc.end}},fix:{range:[r,r],text:`\n${i} *`}})}for(let t=1;t<r.length-1;t++){let a=r[t]??``,o=a.trim();if(!o||o.startsWith(`*`))continue;let s=J(e,t),c=a.length-a.trimStart().length;n.push({message:`多行注释的中间行应以 "*" 开头`,loc:{start:{line:e.loc.start.line+t,column:0},end:{line:e.loc.start.line+t,column:a.length}},fix:{range:[s,s+c],text:`${i} * `}})}let o=r[r.length-1]??``;return z.test(o)||n.push({message:`多行块注释的末行应在 "*/" 前换行`,loc:{start:{...e.loc.start},end:{...e.loc.end}},fix:{range:[e.range[1]-2,e.range[1]-2],text:`\n${i} `}}),n}function oe(e,t){let n=[],r=[];for(let i of e)i.type!==`Shebang`&&(V(i)||H(i)||(i.type===`Line`?r.push(i):n.push(...ae(i,t))));return n.push(...Y(r,t)),n}const se=e({meta:{type:`layout`,fixable:`code`,docs:{description:`强制多行注释使用星号块样式`}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments(),r=e.sourceCode.text,i=oe(n,r==null?[]:r.split(`
|
|
8
|
+
`));for(let t of i){let{fix:n}=t;e.report({loc:t.loc,message:t.message,fix:n?e=>e.replaceTextRange(n.range,n.text):void 0})}}}}});function X(e){return e.type===`ExportNamedDeclaration`||e.type===`ExportDefaultDeclaration`||e.type===`ExportAllDeclaration`}function ce(e,t,n){if(n-t<=1)return!1;for(let r=t+1;r<n;r++)if(e[r-1]?.trim()===``)return!0;return!1}function Z(e){return e.type===`Program`}function le(e,t,n){for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];i!==void 0&&a!==void 0&&X(i)&&X(a)&&(ce(t,i.loc.end.line,a.loc.start.line)||n.report({loc:a.loc.start,message:`export 语句之间需要空行`}))}}const Q={"multiline-comment-style":se,"lines-around-comment":ie,"padding-line-between-statements":e({meta:{type:`layout`,docs:{description:`要求在 export 语句之间有空行`}},createOnce(e){return{Program(t){let n=e.sourceCode.text.split(`
|
|
9
|
+
`),r=Z(t)?t:null;r&&le(r.body,n,e)}}}})},$=t({meta:{name:`@longzai-intelligence-oxlint/stylistic-plugin`},rules:Q});export{$ as default,$ as stylisticPlugin,Q as stylisticRules};
|
package/dist/plugins/tsdoc.js
CHANGED
|
@@ -12,8 +12,8 @@ import"../rolldown-runtime-BqT_7tdF.js";import{defineRule as e,eslintCompatPlugi
|
|
|
12
12
|
`),a=-1;for(let e=0;e<i.length;e++){let n=i[e];if(n&&n.trim().startsWith(`* @${t}`)){a=e;break}}if(a===-1)return n.replaceTextRange(r,`/*${e}*/`);let o=i.filter((e,t)=>t!==a).join(`
|
|
13
13
|
`);return n.replaceTextRange(r,`/*${o}*/`)}const ze=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`禁止使用旧版 JSDoc 标签`}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments();for(let r of n){if(r.type!==`Block`)continue;let n=r.value;if(!n.startsWith(`*`))continue;let i=d(n);if(i)for(let a of i.tags)Le(a.tag)&&e.report({node:t,message:`禁止使用旧版 JSDoc 标签 @${a.tag},该标签在 TSDoc 中已不推荐使用`,fix:e=>Re(n,a.tag,e,r.range)})}}}}}),Be=[...Object.values(S),`参数描述`,`返回值描述`,`函数描述`,`方法描述`,`类描述`,`变量描述`,`类型参数描述`,`描述`];function k(e){let t=e.trim();t.startsWith(`-`)&&(t=t.slice(1).trim());for(let e of Be)if(t===e)return e;return null}function Ve(e){let t=k(e);return t?`禁止使用占位描述 "${t}",请提供有意义的描述`:null}function He(e){let t=[],n=p(e);for(let e of n){let n=k(e.description);n&&t.push(`@param 标签禁止使用占位描述 "${n}",请提供有意义的描述`)}let r=m(e);if(r){let e=k(r.description);e&&t.push(`@returns 标签禁止使用占位描述 "${e}",请提供有意义的描述`)}let i=e.tags.filter(e=>e.tag===`typeParam`||e.tag===`template`);for(let e of i){let n=k(e.description);n&&t.push(`@typeParam 标签禁止使用占位描述 "${n}",请提供有意义的描述`)}return t}const Ue=e({meta:{type:`suggestion`,docs:{description:`禁止使用占位描述文本`}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments();for(let r of n){if(r.type!==`Block`)continue;let n=r.value;if(!n.startsWith(`*`))continue;let i=d(n);if(!i)continue;let a=Ve(i.description);a&&e.report({node:t,message:a});let o=He(i);for(let n of o)e.report({node:t,message:n})}}}}});function We(e){return e?e.trim().startsWith(`-`):!1}const Ge=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:"要求参数描述使用 `-` 分隔"}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments();for(let r of n){if(r.type!==`Block`)continue;let n=r.value;if(!n.startsWith(`*`))continue;let i=d(n);if(!i)continue;let a=p(i);for(let i of a)We(i.description)||e.report({node:t,message:`参数 "${i.name}" 的描述应该使用 \`-\` 分隔,格式:@param ${i.name} - 描述`,fix:e=>{let t=RegExp(`(@param\\s+${E(i.name)}\\s+)([^\\-\\s].*?)(\\n|$)`,`g`),a=n.replace(t,`$1- $2$3`);return e.replaceTextRange(r.range,`/*${a}*/`)}})}}}}});function Ke(e){let t=e.split(`
|
|
14
14
|
`),n=-1,r=!1;for(let e=0;e<t.length;e++){let i=t[e];if(!i)continue;let a=i.trim();if(f(a.startsWith(`*`)?a.slice(1).trim():a))r=!r;else if(!r&&a.startsWith(`*`)&&a.slice(1).trim().startsWith(`@`)){n=e;break}}if(n===-1||n===0)return!0;let i=t[n-1];if(!i)return!0;let a=i.trim();return a===`*`||a===``}const qe=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`要求标签前有空行`}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments();for(let r of n){if(r.type!==`Block`)continue;let n=r.value;if(!n.startsWith(`*`))continue;let i=d(n);i&&i.tags.length>0&&h(i)&&(Ke(n)||e.report({node:t,message:`标签前应有一个空行`,fix:e=>{let t=n.replace(/([ \t]*)(\* [^\n@]+)\n([ \t]*)(\* @)/g,(e,t,n,r,i)=>`${t}${n}\n${t||r}*\n${r}${i}`);return e.replaceTextRange(r.range,`/*${t}*/`)}}))}}}}}),Je=[/使用\s+\S+\s+代替/,/请使用\s+\S+/,/use\s+\S+\s+instead/i,/replaced\s+by\s+\S+/i];function Ye(e){if(!e)return!1;let t=e.trim();if(t.length===0)return!1;for(let e of Je)if(e.test(t))return!0;return t.length>10}const Xe=e({meta:{type:`suggestion`,docs:{description:`要求 @deprecated 标签有替代方案说明`}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments();for(let r of n){if(r.type!==`Block`)continue;let n=r.value;if(!n.startsWith(`*`))continue;let i=d(n);if(!i)continue;let a=i.tags.find(e=>e.tag===`deprecated`);a&&(Ye(a.description)||e.report({node:t,message:`@deprecated 标签应该包含替代方案说明,例如:@deprecated 使用 newMethod 代替`}))}}}}}),Ze=[`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`,`ClassDeclaration`,`VariableDeclaration`,`MethodDefinition`,`TSInterfaceDeclaration`,`TSTypeAliasDeclaration`,`TSEnumDeclaration`,`PropertyDefinition`,`TSPropertySignature`,`TSEnumMember`],Qe=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`要求 TSDoc 注释有描述文本`}},createOnce(e){let t=[];function n(n){let r=x(t,n,e.sourceCode.text);if(!r)return;let i=d(r.value);i&&(h(i)||e.report({node:n,message:`TSDoc 注释缺少描述`,fix:t=>{let n=C(e.sourceCode.text,r.range);return Oe(t,r,n)}}))}let r={Program(){t=e.sourceCode.getAllComments()}};for(let e of Ze)r[e]=e=>n(e);return r}});function A(e){return he.safeParse(e).success}function j(e){return ge.safeParse(e).success}function M(e){return _e.safeParse(e).success}function $e(e){if(!Array.isArray(e)||e.length===0)return null;let t=e[0];if(!t||typeof t!=`object`)return null;let n=t;if(`type`in n&&n.type===`Property`&&`key`in n){let e=n.key;if(e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`)return e.name}if(`type`in n&&n.type===`RestElement`&&`argument`in n){let e=n.argument;if(e&&typeof e==`object`&&`name`in e&&typeof e.name==`string`)return e.name}return null}function et(e){if(!Array.isArray(e)||e.length===0)return null;let t=e[0];return t&&typeof t==`object`&&`name`in t&&typeof t.name==`string`?t.name:null}function tt(e){if(!e||typeof e!=`object`)return null;let t=e;return`type`in t&&t.type===`ObjectPattern`&&`properties`in t?$e(t.properties):`type`in t&&t.type===`ArrayPattern`&&`elements`in t?et(t.elements):null}function nt(e){if(!M(e)||e.declarations.length===0)return null;let t=e.declarations[0];if(!t||typeof t!=`object`||!t||!(`id`in t)||!t.id)return null;let n=t.id;if(typeof n==`object`&&`type`in n){let e=n;if(e.type===`Identifier`&&`name`in e)return typeof e.name==`string`?e.name:null;if(e.type===`ObjectPattern`||e.type===`ArrayPattern`)return tt(n)}return A(t)?t.id?.name??null:null}function N(e){if(!e||typeof e!=`object`||!(`type`in e))return null;let t=e.type;if(typeof t!=`string`)return null;switch(t){case`FunctionDeclaration`:case`ClassDeclaration`:case`TSInterfaceDeclaration`:case`TSTypeAliasDeclaration`:case`TSEnumDeclaration`:case`TSEnumMember`:return A(e)?e.id?.name??null:null;case`MethodDefinition`:case`PropertyDefinition`:case`TSPropertySignature`:return j(e)?e.key?.name??null:null;case`VariableDeclaration`:return nt(e);default:return null}}const rt={FunctionDeclaration:`函数`,MethodDefinition:`方法`,ClassDeclaration:`类`,VariableDeclaration:`变量`,TSInterfaceDeclaration:`接口`,TSTypeAliasDeclaration:`类型别名`,TSEnumDeclaration:`枚举`,PropertyDefinition:`类属性`,TSPropertySignature:`接口属性`,TSEnumMember:`枚举成员`};function P(e){return rt[e]||e}function it(e){return ve.safeParse(e).success}function at(e){return it(e)?e.typeParameters.params.map(e=>e.name&&typeof e.name==`object`&&`name`in e.name?String(e.name.name):``).filter(Boolean):[]}function ot(e){return!e.trim().includes(`
|
|
15
|
-
`)}function st(e){return j(e)?e.key.name:A(e)?e.id.name:`(匿名)`}const ct=e({meta:{type:`suggestion`,docs:{description:`要求接口属性、类属性、枚举成员使用多行 TSDoc 注释格式`}},createOnce(e){return{TSPropertySignature(t){F(t,e)},PropertyDefinition(t){F(t,e)},TSEnumMember(t){F(t,e)}}}});function F(e,t){let n=x(t.sourceCode.getAllComments(),e,t.sourceCode.text);if(
|
|
15
|
+
`)}function st(e){return j(e)?e.key.name:A(e)?e.id.name:`(匿名)`}const ct=e({meta:{type:`suggestion`,docs:{description:`要求接口属性、类属性、枚举成员使用多行 TSDoc 注释格式`}},createOnce(e){return{TSPropertySignature(t){F(t,e)},PropertyDefinition(t){F(t,e)},TSEnumMember(t){F(t,e)}}}});function F(e,t){let n=x(t.sourceCode.getAllComments(),e,t.sourceCode.text);if(n&&ot(n.value)){let n=st(e);t.report({node:e,message:`"${n}"的注释应使用多行 TSDoc 格式,当前为单行格式`})}}const lt=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`要求 @param 标签有描述`}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments();for(let r of n){if(r.type!==`Block`)continue;let n=r.value;if(!n.startsWith(`*`))continue;let i=d(n);if(!i)continue;let a=p(i);for(let n of a)ae(n)||e.report({node:t,message:`参数 "${n.name}" 缺少描述`,fix:t=>Ae(t,r,n.name,C(e.sourceCode.text,r.range))})}}}}}),ut=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`要求函数参数有 @param 标签`}},createOnce(e){let t=[];function n(n){let r=x(t,n,e.sourceCode.text);if(!r)return;let i=O(n);if(i.length===0)return;let a=d(r.value);if(!a)return;let o=oe(a),s=i.filter(e=>!o.includes(e));for(let t of s)e.report({node:n,message:`参数 "${t}" 缺少 @param 标签`,fix:n=>{let i=C(e.sourceCode.text,r.range);return Te(n,r,t,i)}})}return{Program(){t=e.sourceCode.getAllComments()},FunctionDeclaration(e){n(e)},FunctionExpression(e){n(e)},ArrowFunctionExpression(e){if(`parent`in e&&e.parent){let t=e.parent.type;if(t===`CallExpression`||t===`Property`)return}n(e)}}}}),dt=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`要求 @returns 标签有描述`}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments();for(let r of n){if(r.type!==`Block`)continue;let n=r.value;if(!n.startsWith(`*`))continue;let i=d(n);if(!i)continue;let a=m(i);a&&!ae(a)&&e.report({node:t,message:`@returns 标签缺少描述`,fix:t=>je(t,r,C(e.sourceCode.text,r.range))})}}}}});function I(e){return typeof e!=`object`||!e||!(`type`in e)?!1:typeof e.type==`string`}function ft(e){return I(e)&&e.type===`ReturnStatement`&&`argument`in e}function pt(e){return typeof e==`object`&&!!e&&`body`in e}function mt(e){return typeof e==`object`&&!!e&&`returnType`in e}function ht(e){return I(e)?[`FunctionDeclaration`,`FunctionExpression`,`ArrowFunctionExpression`].includes(e.type):!1}function L(e,t){if(!e||typeof e!=`object`)return!1;let n=e;if(t.has(n))return!1;if(t.add(n),ft(n))return!0;if(ht(n))return!1;for(let e of Object.keys(n)){let r=Object.getOwnPropertyDescriptor(n,e);if(!r||!(`value`in r))continue;let i=r.value;if(i&&typeof i==`object`){if(Array.isArray(i)){for(let e of i)if(L(e,t))return!0}else if(`type`in i&&L(i,t))return!0}}return!1}function R(e){if(typeof e!=`object`||!e||!pt(e)||!e.body)return!1;let t=e.body;return typeof t!=`object`||!t?!1:!(`type`in t)||t.type!==`BlockStatement`||L(t,/* @__PURE__ */ new WeakSet)}function z(e){if(typeof e!=`object`||!e||!mt(e)||!e.returnType)return!1;let t=e.returnType;if(!t||typeof t!=`object`||!(`typeAnnotation`in t)||!t.typeAnnotation)return!1;let n=t.typeAnnotation;if(typeof n!=`object`||!(`type`in n))return!1;if(n.type===`TSVoidKeyword`)return!0;if(n.type===`TSTypeReference`){let e=`typeName`in n?n.typeName:null;if(e&&typeof e==`object`&&`name`in e&&e.name===`Promise`){let e=`typeArguments`in n?n.typeArguments:null;if(e&&typeof e==`object`&&`params`in e&&Array.isArray(e.params)&&e.params.length>0){let t=e.params[0];if(I(t))return t.type===`TSVoidKeyword`}}}return!1}function gt(e){return R(e)?!z(e):!1}const _t=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`要求有返回值的函数有 @returns 标签`}},createOnce(e){return{FunctionDeclaration(t){B(t,e)},FunctionExpression(t){B(t,e)},ArrowFunctionExpression(t){if(`parent`in t&&t.parent){let e=t.parent.type;if(e===`CallExpression`||e===`Property`)return}B(t,e)}}}});function B(e,t){if(!gt(e))return;let n=x(t.sourceCode.getAllComments(),e,t.sourceCode.text);if(!n)return;let r=d(n.value);r&&(m(r)||t.report({node:e,message:`缺少 @returns 文档`,fix:e=>{let r=C(t.sourceCode.text,n.range);return Ee(e,n,r)}}))}function vt(e){if(typeof e!=`object`||!e)return!1;let t=e;return`type`in t&&`range`in t&&Array.isArray(t.range)}const yt=e({meta:{type:`suggestion`,docs:{description:`要求 @throws 标签有异常类型`}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments();for(let t of n){if(t.type!==`Block`)continue;let n=t.value;if(!n.startsWith(`*`))continue;let r=d(n);if(!r)continue;let i=r.tags.filter(e=>e.tag===`throws`||e.tag===`throw`);for(let n of i)!n.type&&vt(t)&&e.report({node:t,message:`@throws 标签应使用 {@link Type} 格式声明异常类型,例如:@throws {@link Error} 描述`})}}}}});function V(e){if(typeof e!=`object`||!e)return!1;let t=e;return`body`in t&&Array.isArray(t.body)}function bt(e){if(typeof e!=`object`||!e)return!1;let t=e;return`type`in t&&t.type===`ThrowStatement`&&`argument`in t}function xt(e){if(typeof e!=`object`||!e)return!1;let t=e;return`type`in t&&t.type===`NewExpression`&&`callee`in t}function H(e){if(typeof e!=`object`||!e)return!1;let t=e;return`type`in t&&t.type===`Identifier`&&`name`in t}function St(e){if(typeof e!=`object`||!e)return!1;let t=e;return`consequent`in t&&`alternate`in t}function Ct(e){if(typeof e!=`object`||!e)return!1;let t=e;return`block`in t&&`handler`in t}function wt(e){return typeof e!=`object`||!e?!1:`cases`in e}function Tt(e){if(typeof e!=`object`||!e||!(`consequent`in e))return!1;let t=e;return Array.isArray(t.consequent)}function Et(e){let t=e.argument;if(xt(t)){let e=t.callee;if(H(e))return e.name}return H(t)?t.name:`Error`}function U(e,t){if(!V(e))return;let n=e;if(Array.isArray(n.body))for(let e of n.body)W(e,t)}function W(e,t){if(!e||typeof e!=`object`)return;let n=e;if(`type`in n&&n.type===`ThrowStatement`&&bt(n)){let e=Et(n);t.push({typeName:e})}else`type`in n&&n.type===`IfStatement`&&St(n)?(W(n.consequent,t),n.alternate&&W(n.alternate,t)):`type`in n&&n.type===`TryStatement`&&Ct(n)?Dt(n,t):`type`in n&&n.type===`SwitchStatement`&&wt(n)?Ot(n,t):`type`in n&&n.type===`BlockStatement`&&V(n)&&U(n,t)}function Dt(e,t){V(e.block)&&U(e.block,t),e.handler&&typeof e.handler==`object`&&`body`in e.handler&&e.handler.body&&V(e.handler.body)&&U(e.handler.body,t)}function Ot(e,t){for(let n of e.cases)if(Tt(n))for(let e of n.consequent)W(e,t)}function kt(e){if(!e||typeof e!=`object`||!(`body`in e)||!e.body)return[];let t=e.body;if(typeof t!=`object`||!t||!(`type`in t)||t.type!==`BlockStatement`)return[];let n=[];return U(t,n),n}const At=e({meta:{type:`suggestion`,docs:{description:`要求抛出异常的函数有 @throws 标签`}},createOnce(e){return{FunctionDeclaration(t){G(t,e)},FunctionExpression(t){G(t,e)},ArrowFunctionExpression(t){if(`parent`in t&&t.parent){let e=t.parent.type;if(e===`CallExpression`||e===`Property`)return}G(t,e)}}}});function G(e,t){let n=kt(e);if(n.length===0)return;let r=x(t.sourceCode.getAllComments(),e,t.sourceCode.text);if(!r){K(e,t,n);return}let i=d(r.value);i?i.tags.filter(e=>e.tag===`throws`||e.tag===`throw`).length===0&&K(e,t,n):K(e,t,n)}function K(e,t,n){let r=[...new Set(n.map(e=>e.typeName))],i=r[0]||`Error`;t.report({node:e,message:`函数抛出异常但没有 @throws 标签。抛出的异常类型: ${r.join(`, `)}。正确用法: @throws {@link ${i}} 异常描述`})}function jt(e){return de.safeParse(e).success}function Mt(e){return ue.safeParse(e).success}function Nt(e){return ce.safeParse(e).success}function Pt(e){return le.safeParse(e).success}function Ft(e){return be.safeParse(e).success}function It(e){return xe.safeParse(e).success}function q(e){return e.type===`FunctionDeclaration`||e.type===`FunctionExpression`||e.type===`ArrowFunctionExpression`?zt(e):e.type===`MethodDefinition`&&Ft(e)&&e.value?Bt(e.value):e.type===`ClassDeclaration`?Vt():e.type===`VariableDeclaration`&&It(e)?Ht(e.declarations):J()}function Lt(e,t){return`\n${t}`+e.join(`\n${t}`)+`\n${t}`}function Rt(e,t){return Lt(q(e),t)}function zt(e){let t=O(e),n=R(e),r=z(e),i=[];i.push(`/**`),i.push(` * ${S.functionDescription}`);for(let e of t)i.push(` * @param ${e} - ${S.paramDescription}`);return n&&!r&&i.push(` * @returns ${S.returnsDescription}`),i.push(` */`),i}function Bt(e){if(!e||typeof e!=`object`||!jt(e))return J();let t=e,n=O(t),r=R(t),i=z(t),a=[];a.push(`/**`),a.push(` * ${S.methodDescription}`);for(let e of n)a.push(` * @param ${e} - ${S.paramDescription}`);return r&&!i&&a.push(` * @returns ${S.returnsDescription}`),a.push(` */`),a}function Vt(){let e=[];return e.push(`/**`),e.push(` * ${S.classDescription}`),e.push(` */`),e}function Ht(e){let t=e[0];if(!t||!Mt(t))return J();let n=Nt(t)?t.init:void 0;if(n&&typeof n==`object`&&Pt(n)){let e=n.type;if(e===`ArrowFunctionExpression`||e===`FunctionExpression`)return J()}let r=[];return r.push(`/**`),r.push(` * ${S.variableDescription}`),r.push(` */`),r}function J(){let e=[];return e.push(`/**`),e.push(` * ${S.description}`),e.push(` */`),e}function Ut(e,t){let n=e.map(e=>{let t=e.trim();return t.startsWith(`*`)?t.slice(1).trim():t});for(;n.length>0&&!n[0];)n.shift();for(;n.length>0&&!n[n.length-1];)n.pop();return n.length===0?`/**\n${t} */`:`/**\n${n.map(e=>e?`${t} * ${e}`:`${t} *`).join(`
|
|
16
16
|
`)}\n${t} */`}function Y(e){return typeof e==`object`&&!!e&&`type`in e&&typeof e.type==`string`}function X(e){return typeof e==`object`&&!!e&&`parent`in e}function Wt(e){return typeof e==`object`&&!!e&&`init`in e}function Z(e){return typeof e==`object`&&!!e}const Gt=[`FunctionDeclaration`,`MethodDefinition`,`ClassDeclaration`,`VariableDeclaration`,`TSInterfaceDeclaration`,`TSTypeAliasDeclaration`,`TSEnumDeclaration`,`PropertyDefinition`,`TSEnumMember`];function Kt(e){if(!Z(e)||e.type!==`TSPropertySignature`)return!1;let t=e.key;return Z(t)&&t.type===`Identifier`&&`name`in t&&typeof t.name==`string`?t.name===`null`||t.name===`undefined`:!1}function qt(e,t){if(X(e)&&e.parent&&typeof e.parent==`object`&&Y(e.parent)&&[`ForStatement`,`ForInStatement`,`ForOfStatement`].includes(e.parent.type))return!0;if(e.type===`VariableDeclaration`){if(t)return!1;if(M(e)&&e.declarations.length>0){let t=e.declarations[0];if(!t)return!0;if(Wt(t)&&t.init&&typeof t.init==`object`&&Y(t.init)&&(t.init.type===`ArrowFunctionExpression`||t.init.type===`FunctionExpression`))return!1}return!0}return!!Kt(e)}function Jt(e){return e.includes(`/**`)}function Yt(e){if(`decorators`in e&&Array.isArray(e.decorators)&&e.decorators.length>0){let t=e.decorators[0];if(Z(t)){let e=t.range;if(Array.isArray(e)&&e.length>=1&&typeof e[0]==`number`)return[e[0],e[0]]}}if(X(e)&&e.parent&&typeof e.parent==`object`){let t=e.parent;if(Y(t)&&Z(t)&&[`ExportNamedDeclaration`,`ExportDefaultDeclaration`].includes(t.type)){let e=t.range;if(Array.isArray(e)&&e.length>=1&&typeof e[0]==`number`)return[e[0],e[0]]}}return[e.range[0],e.range[0]]}function Q(e,t){if(!e)return``;let n=t;for(;n>0&&e[n-1]!==`
|
|
17
17
|
`;)n--;return e.slice(n,t)}function Xt(e,t,n){let r=Yt(t),i=Rt(t,Q(n.sourceCode.text,r[0]));return e.insertTextBeforeRange(r,i)}function Zt(e,t,n){if(t.skipFile||qt(e,t.checkAllVariables))return;let r=x(t.commentsCache,e,n.sourceCode.text);if(!r){let r=P(e.type),i=N(e),a=Se(t.commentsCache,e,n.sourceCode.text);n.report({node:e,message:`${r}"${i}"缺少 TSDoc 注释`,fix:t=>{let r=a?.comments[0],i=a?.comments[a.comments.length-1];if(!r||!i)return Xt(t,e,n);let o=[r.range[0],i.range[1]],s=Q(n.sourceCode.text,o[0]),c=a.comments.flatMap(e=>e.type===`Block`?e.value.split(`
|
|
18
18
|
`):[e.value]),l=c.map(e=>{let t=e.trim();return t.startsWith(`*`)?t.slice(1).trim():t}).every(e=>!e)?q(e).join(`
|
|
19
|
-
`):Ut(c,s);return t.replaceTextRange(o,l)}})
|
|
19
|
+
`):Ut(c,s);return t.replaceTextRange(o,l)}})}else if(we(r.value)){let t=P(e.type),r=N(e);n.report({node:e,message:`${t}"${r}"的 TSDoc 注释包含占位描述,请填写实际描述`})}}function Qt(e,t){let n=e.getAllComments(),r=e.text;if(r!=null){if(!Jt(r))return t.skipFile=!0,n}else if(!n.some(e=>e.type===`Block`&&e.value.startsWith(`*`)))return t.skipFile=!0,n;return n}function $t(e){if(typeof e==`object`&&e&&!Array.isArray(e)){let t=e;if(`checkAllVariables`in t&&typeof t.checkAllVariables==`boolean`)return t.checkAllVariables}return!1}const en=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`要求 TSDoc 注释存在`},schema:[{type:`object`,properties:{contexts:{type:`array`,items:{type:`string`}},checkAllVariables:{type:`boolean`}},additionalProperties:!1}]},createOnce(e){let t={commentsCache:[],checkAllVariables:!1,skipFile:!1},n={Program(n){t.skipFile=!1,t.checkAllVariables=!1,t.commentsCache=Qt(e.sourceCode,t);let r=e.options?.[0];t.checkAllVariables=$t(r)}};for(let r of Gt)n[r]=n=>Zt(n,t,e);return n}});function tn(e){return e.tags.filter(e=>e.tag===`typeParam`||e.tag===`template`).map(e=>e.name)}const nn=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`要求泛型有 @typeParam 标签`}},createOnce(e){return{FunctionDeclaration(t){$(t,e)},FunctionExpression(t){$(t,e)},ArrowFunctionExpression(t){if(`parent`in t&&t.parent){let e=t.parent.type;if(e===`CallExpression`||e===`Property`)return}$(t,e)},ClassDeclaration(t){$(t,e)},TSInterfaceDeclaration(t){$(t,e)},TSTypeAliasDeclaration(t){$(t,e)}}}});function $(e,t){if(!it(e))return;let n=at(e);if(n.length===0)return;let r=x(t.sourceCode.getAllComments(),e,t.sourceCode.text);if(!r)return;let i=d(r.value);if(!i)return;let a=tn(i),o=n.filter(e=>!a.includes(e));for(let n of o)t.report({node:e,message:`缺少类型参数 "${n}" 的 @typeParam 文档`,fix:e=>{let i=C(t.sourceCode.text,r.range);return De(e,r,n,i)}})}const rn=/^(=+)\s+(.+?)\s+(=+)$/;function an(e){let t=e.trim().match(rn);return t?{leadingEquals:t[1]??``,text:t[2]??``,trailingEquals:t[3]??``}:null}const on=e({meta:{type:`suggestion`,fixable:`code`,docs:{description:`要求代码块分隔符使用规范格式`}},createOnce(e){return{Program(t){let n=e.sourceCode.getAllComments();for(let r of n){if(r.type!==`Line`)continue;let n=an(r.value.trim());if(n&&(n.leadingEquals.length!==20||n.trailingEquals.length!==20)){let i=`=`.repeat(20);e.report({node:t,message:`代码块分隔符格式不正确,应为:// ${i} ${n.text} ${i}`,fix:e=>{let t=`// ${i} ${n.text} ${i}`;return e.replaceTextRange(r.range,t)}})}}}}}}),sn=/\bTODO(?:\(([^)]+)\))?:?\s*(.*)/i;function cn(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}const ln={requireAuthor:!1,requireDescription:!0};function un(e){return/\bTODO\b/i.test(e)}function dn(e){let t={...ln};if(cn(e)){let n=e;typeof n.requireAuthor==`boolean`&&(t.requireAuthor=n.requireAuthor),typeof n.requireDescription==`boolean`&&(t.requireDescription=n.requireDescription)}return t}function fn(e){let t=e.match(sn);return t?{author:t[1]??``,description:(t[2]??``).trim()}:null}const pn={"no-commented-code":s,"no-description-tag":se,"no-extra-param":Fe,"no-legacy-jsdoc-tags":ze,"no-placeholder-description":Ue,"param-hyphen-format":Ge,"require-blank-line-before-tags":qe,"require-deprecated-alternative":Xe,"require-description":Qe,"require-multiline-property-comment":ct,"require-param":ut,"require-param-description":lt,"require-returns":_t,"require-returns-description":dt,"require-throws":At,"require-throws-type":yt,"require-tsdoc":en,"require-type-param":nn,"separator-format":on,"todo-format":e({meta:{type:`suggestion`,docs:{description:`要求 TODO 注释有描述和作者`}},createOnce(e){let t=dn(e.options?.[0]);return{Program(n){let r=e.sourceCode.getAllComments();for(let i of r){let r=i.value;if(!un(r))continue;let a=fn(r);a&&(t.requireAuthor&&!a.author&&e.report({node:n,message:`TODO 注释缺少作者信息,格式:TODO(author): 描述`}),t.requireDescription&&!a.description&&e.report({node:n,message:`TODO 注释缺少描述说明`}))}}}}})},mn=t({meta:{name:`@longzai-intelligence-oxlint/tsdoc-plugin`},rules:pn});export{rn as SEPARATOR_PATTERN,mn as default,mn as tsdocPlugin,an as parseSeparatorComment,pn as tsdocRules};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-Dap4Z6h_.js";import{defineConfig as t}from"./react.js";const n=[`babel.config.js`,`metro.config.js`,`jest.config.js`],r={"@longzai-intelligence-oxlint/package-json-plugin/require-build-script-toolchain":[`warn`,{dev:[`lzi-react-native`],build:[`lzi-react-native`],buildProd:[`bun`]}]};function i(i){let a=t();return{extends:[a],...i,rules:{...r,...i?.rules},ignorePatterns:e([...a.ignorePatterns??[],...n,...i?.ignorePatterns??[]])}}const a=i();export{a as n,n as r,i as t};
|
package/dist/react-native.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{r as REACT_NATIVE_TOOLCHAIN_IGNORE_PATTERNS,n as default,t as defineConfig}from"./react-native.entry-
|
|
1
|
+
export{r as REACT_NATIVE_TOOLCHAIN_IGNORE_PATTERNS,n as default,t as defineConfig}from"./react-native.entry-CRBcPvfA.js";
|
package/dist/react.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{s as e,t}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{s as e,t}from"./base.entry-Dap4Z6h_.js";import{t as n}from"./ui-consumption.rules-KvXiDxx6.js";const r={"@longzai-intelligence-oxlint/package-json-plugin/require-build-script-toolchain":[`warn`,{dev:[`lzi-vite`],build:[`lzi-vite`],buildProd:[`bun`]}]};function i(i){let a=t();return{extends:[a],plugins:[`react`,`jsx-a11y`],...i,rules:{...r,...n,...i?.rules},ignorePatterns:e([...a.ignorePatterns??[],...i?.ignorePatterns??[]])}}const a=i();export{a as default,i as defineConfig};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{o as e,s as t,t as n}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{o as e,s as t,t as n}from"./base.entry-Dap4Z6h_.js";const r=[`**`,`!package.json`,`!turbo.json`,`!tsconfig.json`,`!oxfmt.config.ts`,...e];function i(e){let i=n();return{extends:[i],...e,ignorePatterns:t([...i.ignorePatterns??[],...r,...e?.ignorePatterns??[]])}}const a=i();export{a as n,r,i as t};
|
package/dist/root.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{r as ROOT_WHITELIST_PATTERNS,n as default,t as defineConfig}from"./root.entry-
|
|
1
|
+
export{r as ROOT_WHITELIST_PATTERNS,n as default,t as defineConfig}from"./root.entry-DUE5WDMN.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-Dap4Z6h_.js";import{defineConfig as t}from"./library.js";const n={files:[`test/**`],rules:{"@longzai-intelligence-oxlint/architecture-library-plugin/test-file-placement":`off`,"@longzai-intelligence-oxlint/architecture-library-plugin/test-file-matches-source":`off`}},r=[`src/domains/**`];function i(i){let a={files:[...r,...i?.generatedPatterns??[]],rules:{"max-lines":`off`,"max-lines-per-function":`off`}},o=t();return{extends:[o],overrides:[a,n,...i?.overrides??[]],...i?.rules?{rules:i.rules}:{},ignorePatterns:e([...o.ignorePatterns??[],...i?.ignorePatterns??[]])}}const a=i();export{a as n,r,i as t};
|
package/dist/sdk.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{r as SDK_GENERATED_PATTERNS,n as default,t as defineConfig}from"./sdk.entry-
|
|
1
|
+
export{r as SDK_GENERATED_PATTERNS,n as default,t as defineConfig}from"./sdk.entry-CZjdN7jn.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-Dap4Z6h_.js";import{defineConfig as t}from"./react.js";const n=[`src/app.ts`,`config/dev.ts`,`config/prod.ts`],r=[`src/app.tsx`],i={"@longzai-intelligence-oxlint/package-json-plugin/require-build-script-toolchain":[`warn`,{dev:[`lzi-taro`],build:[`lzi-taro`],buildProd:[`bun`]}]};function a(a){let o=[...a?.typeSuffixBaseSkipPatterns??[],...n],s=[...a?.fileNamingBaseSkipPatterns??[],...r],c={files:[`**/*.ts`],rules:{"@longzai-intelligence-oxlint/file-naming-plugin/require-type-suffix":[`error`,{skipPatterns:o}]}},l={files:[`**/*.tsx`],rules:{"@longzai-intelligence-oxlint/file-naming-plugin/file-naming":[`error`,{skipPatterns:s}]}},u=t();return{extends:[u],overrides:[c,l,...a?.overrides??[]],rules:{...i,...a?.rules},ignorePatterns:e([...u.ignorePatterns??[],...a?.ignorePatterns??[]])}}const o=a();export{n as i,o as n,r,a as t};
|
package/dist/taro.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{r as TARO_FILE_NAMING_EXEMPT_PATTERNS,i as TARO_SPECIAL_FILE_PATTERNS,n as default,t as defineConfig}from"./taro.entry-
|
|
1
|
+
export{r as TARO_FILE_NAMING_EXEMPT_PATTERNS,i as TARO_SPECIAL_FILE_PATTERNS,n as default,t as defineConfig}from"./taro.entry-BbKrVHru.js";
|
package/dist/ui-application.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-Dap4Z6h_.js";import{defineConfig as t}from"./ui-base.js";const n={"@longzai-intelligence-oxlint/package-json-plugin/require-build-script-toolchain":[`warn`,{dev:[`lzi-vite`],build:[`lzi-vite`],buildProd:[`bun`]}]};function r(r){let i=t();return{extends:[i],...r,rules:{...n,...r?.rules},ignorePatterns:e([...i.ignorePatterns??[],...r?.ignorePatterns??[]])}}const i=r();export{i as default,r as defineConfig};
|
package/dist/ui-base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-Dap4Z6h_.js";import{defineConfig as t}from"./react.js";const n={"@longzai-intelligence-oxlint/package-json-plugin/require-build-script-toolchain":[`warn`,{}]};function r(r){let i=t();return{extends:[i],...r,rules:{...n,...r?.rules},ignorePatterns:e([...i.ignorePatterns??[],...r?.ignorePatterns??[]])}}const i=r();export{i as default,r as defineConfig};
|
package/dist/ui-library.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-
|
|
1
|
+
import"./rolldown-runtime-BqT_7tdF.js";import{s as e}from"./base.entry-Dap4Z6h_.js";import{defineConfig as t}from"./ui-base.js";const n={"@longzai-intelligence-oxlint/package-json-plugin/require-build-script-toolchain":[`warn`,{dev:[`lzi-builder`],build:[`lzi-builder`],buildProd:[`bun`]}]};function r(r){let i=t();return{extends:[i],...r,rules:{...n,...r?.rules},ignorePatterns:e([...i.ignorePatterns??[],...r?.ignorePatterns??[]])}}const i=r();export{i as default,r as defineConfig};
|