@longzai-intelligence-oxlint/typeorm-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.
@@ -0,0 +1,10 @@
1
+ import { OxlintRules } from "@longzai-intelligence-oxlint/core";
2
+ //#region src/configs/recommended.config.d.ts
3
+ /**
4
+ * 推荐规则配置对象
5
+ *
6
+ * 包含 TypeORM 插件的推荐规则设置
7
+ */
8
+ declare const recommended: OxlintRules;
9
+ //#endregion
10
+ export { recommended };
@@ -0,0 +1 @@
1
+ const e={"@longzai-intelligence-oxlint/typeorm-plugin/no-string-entity-ref":`error`};export{e as recommended};
@@ -0,0 +1,25 @@
1
+ //#region src/rules/no-string-entity-ref/index.d.ts
2
+ /**
3
+ * 受检的 TypeORM 关系装饰器名称集合
4
+ *
5
+ * 这四个装饰器的第一个参数是关系目标实体,必须用箭头函数引用类。
6
+ */
7
+ declare const RELATION_DECORATORS: ReadonlySet<string>;
8
+ /**
9
+ * no-string-entity-ref 规则定义
10
+ *
11
+ * 检测 TypeORM 关系装饰器使用字符串类名引用的反模式。
12
+ * 使用 createOnce 替代 create 以获得 Oxlint 最佳性能。
13
+ */
14
+ declare const noStringEntityRefRule: import("@oxlint/plugins").Rule;
15
+ //#endregion
16
+ //#region src/index.d.ts
17
+ /**
18
+ * TypeORM 插件
19
+ *
20
+ * 提供 TypeORM 相关的 Oxlint 规则,
21
+ * 通过 eslintCompatPlugin 包装以同时支持 Oxlint 和 ESLint 运行时
22
+ */
23
+ declare const typeormPlugin: import("@oxlint/plugins").Plugin;
24
+ //#endregion
25
+ export { RELATION_DECORATORS, typeormPlugin as default, typeormPlugin, noStringEntityRefRule };
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ import{defineRule as e,eslintCompatPlugin as t}from"@oxlint/plugins";const n=new Set([`ManyToOne`,`OneToMany`,`OneToOne`,`ManyToMany`]);function r(e){if(e.type!==`CallExpression`)return null;let t=e.callee;return t.type!==`Identifier`||!n.has(t.name)?null:e}function i(e){if(e.type!==`Literal`)return null;let t=e.value;return typeof t==`string`?t:null}const a=e({meta:{type:`problem`,docs:{description:`禁止 TypeORM 关系装饰器(@ManyToOne/@OneToMany/@OneToOne/@ManyToMany)使用字符串类名引用,生产构建 minify 会压缩类名导致运行时关系解析失败`}},createOnce(e){return{Decorator(t){let n=r(t.expression);if(n===null)return;let a=n.arguments[0];if(a===void 0)return;let o=i(a);if(o===null)return;let s=n.callee.name;e.report({node:a,message:`@${s} 的第一个参数禁止使用字符串类名 "${o}"。生产构建 minify 会压缩类名(如 ${o} → y),导致 TypeORM 运行时抛出 "Entity metadata for y#<属性> was not found"。请改用箭头函数引用类:@${s}(() => ${o}, ...)。`})}}}}),o=t({meta:{name:`@longzai-intelligence-oxlint/typeorm-plugin`},rules:{"no-string-entity-ref":a}});export{n as RELATION_DECORATORS,o as default,o as typeormPlugin,a as noStringEntityRefRule};
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@longzai-intelligence-oxlint/typeorm-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
+ }