@longzai-intelligence-oxlint/tsconfig-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 +5 -0
- package/dist/configs/recommended.js +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +1 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# @longzai-intelligence-oxlint/tsconfig-plugin
|
|
2
|
+
|
|
3
|
+
## 意图
|
|
4
|
+
|
|
5
|
+
在静态检查阶段守护 TypeScript 项目引用配置的规范性,避免 tsconfig 引用缺失导致的项目边界混乱。
|
|
6
|
+
|
|
7
|
+
## 定位
|
|
8
|
+
|
|
9
|
+
Oxlint 生态的 tsconfig 治理插件,通过 `eslintCompatPlugin` 包装以同时兼容 Oxlint 与 ESLint 运行时。
|
|
10
|
+
|
|
11
|
+
## 职能
|
|
12
|
+
|
|
13
|
+
提供 `tsconfig-references` 规则,校验 tsconfig.json 中 references 字段的完整性与规范性。
|
|
14
|
+
|
|
15
|
+
## 实现情况
|
|
16
|
+
|
|
17
|
+
当前仅落地项目引用约束一条规则,规则与插件对象均已导出;整体处于聚焦单点的成熟形态,未见其他规则占位。
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e={"@longzai-intelligence-oxlint/tsconfig-plugin/tsconfig-references":`error`};export{e as recommended};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
//#region src/rules/tsconfig-references.rule.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* tsconfig-references 规则定义
|
|
4
|
+
*/
|
|
5
|
+
declare const tsconfigReferencesRule: import("@oxlint/plugins").Rule;
|
|
6
|
+
//#endregion
|
|
7
|
+
//#region src/index.d.ts
|
|
8
|
+
declare const tsconfigPlugin: import("@oxlint/plugins").Plugin;
|
|
9
|
+
//#endregion
|
|
10
|
+
export { tsconfigPlugin as default, tsconfigPlugin, tsconfigReferencesRule };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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=[`app.json`,`node.json`,`test.json`],s=[`./tsconfig/app.json`,`./tsconfig/node.json`,`./tsconfig/test.json`];function c(e){let t=e.replace(/\\/g,`/`);return(t.split(`/`).pop()??``)===`tsconfig.json`&&!t.includes(`/tsconfig/`)}function l(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function u(e,t){return n(e)?!0:(t(`缺少 tsconfig/ 目录。请创建 tsconfig/ 目录并配置子配置文件。`),!1)}function d(e,t){for(let r of o)n(a(e,r))||t(`缺少必需的 tsconfig 子配置文件 tsconfig/${r}。`)}function f(e,t){(!(`files`in e)||!Array.isArray(e.files)||e.files.length>0)&&t(`tsconfig.json 的 files 字段应为空数组 []。根配置仅用于引用子配置。`)}function p(e){return l(e)&&`path`in e}function m(e,t){if(!(`references`in e)||!Array.isArray(e.references)){t(`tsconfig.json 必须包含 references 字段。请配置项目引用。`);return}let n=new Set(e.references.map(e=>p(e)?String(e.path):``));for(let e of s)n.has(e)||t(`tsconfig.json 缺少必需的引用 "${e}"。`)}function h(e,t){let n=JSON.parse(e);if(!l(n)){t(`tsconfig.json 内容不是有效的对象。`);return}f(n,t),m(n,t)}function g(e,t){try{let n=r(e,`utf-8`),o=a(i(e),`tsconfig`);if(!u(o,t))return;d(o,t),h(n,t)}catch{}}const _=e({meta:{type:`problem`,docs:{description:`检查 tsconfig.json 是否正确使用 references 配置`}},createOnce(e){return{before(){if(!c(e.filename))return!1},Program(t){g(e.filename,n=>{e.report({node:t,message:n})})}}}}),v=t({meta:{name:`@longzai-intelligence-oxlint/tsconfig-plugin`},rules:{"tsconfig-references":_}});export{v as default,v as tsconfigPlugin,_ as tsconfigReferencesRule};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@longzai-intelligence-oxlint/tsconfig-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
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"oxlint": ">=1.0.0"
|
|
46
|
+
}
|
|
47
|
+
}
|