@longzai-intelligence-oxlint/package-json-plugin 0.1.18 → 0.1.20

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/README.md CHANGED
@@ -1,17 +1,13 @@
1
1
  # @longzai-intelligence-oxlint/package-json-plugin
2
2
 
3
- ## 意图
3
+ Longzai Intelligence Oxlint 的 package.json 治理插件,守护包元数据的许可证合规。
4
4
 
5
- 在静态检查阶段守护 package.json 文件规范,避免组织内出现不合规的许可证声明。
5
+ ## 简介
6
6
 
7
- ## 定位
7
+ 治理包声明不合规的问题:package.json 文件中不合规的许可证声明在静态检查阶段校验并拦截,防止违规协议流入包元数据。
8
8
 
9
- Oxlint 生态的 package.json 治理插件,通过 `eslintCompatPlugin` 包装以同时兼容 Oxlint 与 ESLint 运行时。
9
+ ## 能力
10
10
 
11
- ## 职能
12
-
13
- 提供 `no-mit-license` 规则,校验 package.json 文件中是否使用 MIT 许可证并予以拦截;同时导出 `isPackageJson` 文件判断工具供外部复用。
14
-
15
- ## 实现情况
16
-
17
- 当前仅落地许可证治理一条规则,规则、工具与插件对象均已导出;整体处于聚焦单点的成熟形态,未见其他规则占位。
11
+ - `no-mit-license` — 校验 package.json 是否使用 MIT 许可证并予以拦截
12
+ - `isPackageJson` 文件判断工具导出
13
+ - 同时兼容 Oxlint 与 ESLint 运行时
@@ -3,7 +3,7 @@ import { OxlintRules } from "@longzai-intelligence-oxlint/core";
3
3
  /**
4
4
  * 推荐规则配置
5
5
  *
6
- * 启用 no-mit-license 规则为 error 级别
6
+ * 启用 no-mit-license 与领域包边界两规则为 error 级别(ADR 0101 门禁)
7
7
  */
8
8
  declare const recommended: OxlintRules;
9
9
  //#endregion
@@ -1 +1 @@
1
- const e={"@longzai-intelligence-oxlint/package-json-plugin/no-mit-license":`error`};export{e as recommended};
1
+ const e={"@longzai-intelligence-oxlint/package-json-plugin/no-app-infrastructure-dependency":`error`,"@longzai-intelligence-oxlint/package-json-plugin/no-domain-layer-subpath-export":`error`,"@longzai-intelligence-oxlint/package-json-plugin/no-mit-license":`error`,"@longzai-intelligence-oxlint/package-json-plugin/no-sibling-implementation-dependency":`error`};export{e as recommended};
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";function n(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function r(e){return typeof e==`object`&&!!e}const i={noMitLicense:`禁止使用 MIT 协议。项目中的所有包都应使用 "license": "UNLICENSED"。`},a=e({meta:{type:`problem`,docs:{description:`禁止在 package.json 中使用 MIT 协议`}},createOnce(e){return{before(){let t=e.filename;if(!n(t))return!1},Program(t){let n=e.sourceCode.text;try{let a=JSON.parse(n);r(a)&&a.license===`MIT`&&e.report({node:t,message:i.noMitLicense})}catch{}}}}}),o=t({meta:{name:`@longzai-intelligence-oxlint/package-json-plugin`},rules:{"no-mit-license":a}});export{o as default,o as packageJsonPlugin,n as isPackageJson,a as noMitLicenseRule};
1
+ 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/\/domains\/[^/]+\/implementation\/package\.json$/.test(e)}function s(e){return typeof e==`object`&&!!e}function c(e,t){if(e===`./domain`)return!0;let n=typeof t==`string`?t:s(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 l={noDomainLayerSubpathExport:"禁止领域实现包声明领域分层子路径导出(ADR 0101):领域分层(domain/)为 implementation 包内私有,仓储端口应落位 contract 包;`./domain` 类子导出属违规逃逸通道。"},u=e({meta:{type:`problem`,docs:{description:`禁止领域实现包声明领域分层子路径导出(ADR 0101 违规逃逸通道)`}},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)||!s(r.exports))return;for(let[n,i]of Object.entries(r.exports))n!==`.`&&c(n,i)&&e.report({node:t,message:`${l.noDomainLayerSubpathExport}(发现子路径 "${n}")`})}catch{}}}}});function d(e){return e.replace(/\\/g,`/`).endsWith(`/package.json`)}function f(e){return typeof e==`object`&&!!e}const p={noMitLicense:`禁止使用 MIT 协议。项目中的所有包都应使用 "license": "UNLICENSED"。`},m=e({meta:{type:`problem`,docs:{description:`禁止在 package.json 中使用 MIT 协议`}},createOnce(e){return{before(){let t=e.filename;if(!d(t))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);f(r)&&r.license===`MIT`&&e.report({node:t,message:p.noMitLicense})}catch{}}}}});function h(e){return/\/domains\/[^/]+\/infrastructure\/package\.json$/.test(e)}function g(e){return e.endsWith(`-infrastructure`)?`${e.slice(0,-15)}-implementation`:null}function _(e){return typeof e==`object`&&!!e}const v=e({meta:{type:`problem`,docs:{description:`禁止领域基础设施包依赖同域实现包(ADR 0101 依赖图只允许 infrastructure ──> contract)`}},createOnce(e){return{before(){if(!h(e.filename.replace(/\\/g,`/`)))return!1},Program(t){let n=e.sourceCode.text;try{let r=JSON.parse(n);if(!_(r)||typeof r.name!=`string`)return;let i=g(r.name);if(!i||!_(r.dependencies))return;i in r.dependencies&&e.report({node:t,message:`禁止领域基础设施包依赖同域实现包(ADR 0101):依赖图只允许 infrastructure ──> contract,发现依赖 "${i}"。`})}catch{}}}}}),y=t({meta:{name:`@longzai-intelligence-oxlint/package-json-plugin`},rules:{"no-app-infrastructure-dependency":a,"no-domain-layer-subpath-export":u,"no-mit-license":m,"no-sibling-implementation-dependency":v}});export{y as default,y as packageJsonPlugin,d as isPackageJson,m as noMitLicenseRule};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@longzai-intelligence-oxlint/package-json-plugin",
3
- "version": "0.1.18",
3
+ "version": "0.1.20",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist"
@@ -35,7 +35,7 @@
35
35
  "typecheck:test": "lzi-tsgo typecheck tsconfig/test.json"
36
36
  },
37
37
  "dependencies": {
38
- "@longzai-intelligence-oxlint/core": "0.1.18",
38
+ "@longzai-intelligence-oxlint/core": "0.1.20",
39
39
  "@oxlint/plugins": "^1.74.0"
40
40
  },
41
41
  "devDependencies": {