@longzai-intelligence-oxlint/package-json-plugin 0.1.0
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 +17 -0
- package/dist/configs/recommended.d.ts +10 -0
- package/dist/configs/recommended.js +1 -0
- package/dist/index.d.ts +27 -0
- package/dist/index.js +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @longzai-intelligence-oxlint/package-json-plugin
|
|
2
|
+
|
|
3
|
+
## 意图
|
|
4
|
+
|
|
5
|
+
在静态检查阶段守护 package.json 文件规范,避免组织内出现不合规的许可证声明。
|
|
6
|
+
|
|
7
|
+
## 定位
|
|
8
|
+
|
|
9
|
+
Oxlint 生态的 package.json 治理插件,通过 `eslintCompatPlugin` 包装以同时兼容 Oxlint 与 ESLint 运行时。
|
|
10
|
+
|
|
11
|
+
## 职能
|
|
12
|
+
|
|
13
|
+
提供 `no-mit-license` 规则,校验 package.json 文件中是否使用 MIT 许可证并予以拦截;同时导出 `isPackageJson` 文件判断工具供外部复用。
|
|
14
|
+
|
|
15
|
+
## 实现情况
|
|
16
|
+
|
|
17
|
+
当前仅落地许可证治理一条规则,规则、工具与插件对象均已导出;整体处于聚焦单点的成熟形态,未见其他规则占位。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={"@longzai-intelligence-oxlint/package-json-plugin/no-mit-license":`error`};export{e as recommended};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//#region src/rules/no-mit-license/index.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* 判断文件是否为 package.json
|
|
4
|
+
*
|
|
5
|
+
* @param filePath - 文件的绝对路径或相对路径
|
|
6
|
+
* @returns 如果是 package.json 返回 true,否则返回 false
|
|
7
|
+
*/
|
|
8
|
+
declare function isPackageJson(filePath: string): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* 禁止 MIT 协议的 Oxlint 规则
|
|
11
|
+
*
|
|
12
|
+
* 该规则会检查 package.json 文件中的 license 字段:
|
|
13
|
+
* 如果发现 license 字段值为 MIT,会报告错误。
|
|
14
|
+
* 使用 createOnce 替代 create 以获得 Oxlint 最佳性能。
|
|
15
|
+
*/
|
|
16
|
+
declare const noMitLicenseRule: import("@oxlint/plugins").Rule;
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/index.d.ts
|
|
19
|
+
/**
|
|
20
|
+
* package-json 插件
|
|
21
|
+
*
|
|
22
|
+
* 提供 package.json 文件规范检查的 Oxlint 规则,
|
|
23
|
+
* 通过 eslintCompatPlugin 包装以同时支持 Oxlint 和 ESLint 运行时
|
|
24
|
+
*/
|
|
25
|
+
declare const packageJsonPlugin: import("@oxlint/plugins").Plugin;
|
|
26
|
+
//#endregion
|
|
27
|
+
export { packageJsonPlugin as default, packageJsonPlugin, isPackageJson, noMitLicenseRule };
|
package/dist/index.js
ADDED
|
@@ -0,0 +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};
|
package/package.json
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@longzai-intelligence-oxlint/package-json-plugin",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist"
|
|
7
|
+
],
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "./dist/index.js",
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./configs/recommended": {
|
|
17
|
+
"types": "./dist/configs/recommended.d.ts",
|
|
18
|
+
"import": "./dist/configs/recommended.js"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "lzi-builder",
|
|
23
|
+
"build:prod": "NODE_ENV=production lzi-builder",
|
|
24
|
+
"prepublishOnly": "bun run build:prod",
|
|
25
|
+
"dev": "lzi-builder --watch",
|
|
26
|
+
"clean": "rimraf dist",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest",
|
|
29
|
+
"test:coverage": "vitest run --coverage",
|
|
30
|
+
"lint": "oxlint && oxfmt --check",
|
|
31
|
+
"lint:fix": "oxlint --fix && oxfmt",
|
|
32
|
+
"typecheck": "bun run typecheck:app && bun run typecheck:node && bun run typecheck:test",
|
|
33
|
+
"typecheck:app": "tsgo --noEmit -p tsconfig/app.json",
|
|
34
|
+
"typecheck:node": "tsgo --noEmit -p tsconfig/node.json",
|
|
35
|
+
"typecheck:test": "tsgo --noEmit -p tsconfig/test.json"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@longzai-intelligence-oxlint/core": "0.1.0",
|
|
39
|
+
"@oxlint/plugins": "^1.74.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
43
|
+
"typescript": "^6.0.3"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"oxlint": ">=1.0.0"
|
|
47
|
+
}
|
|
48
|
+
}
|