@longzai-intelligence-oxlint/typeorm-plugin 0.1.2 → 0.1.4
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/configs/recommended.js +1 -1
- package/dist/index.d.ts +17 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
const e={"@longzai-intelligence-oxlint/typeorm-plugin/no-string-entity-ref":`error`};export{e as recommended};
|
|
1
|
+
const e={"@longzai-intelligence-oxlint/typeorm-plugin/no-string-entity-ref":`error`,"@longzai-intelligence-oxlint/typeorm-plugin/require-take-with-skip":`error`};export{e as recommended};
|
package/dist/index.d.ts
CHANGED
|
@@ -13,6 +13,22 @@ declare const RELATION_DECORATORS: ReadonlySet<string>;
|
|
|
13
13
|
*/
|
|
14
14
|
declare const noStringEntityRefRule: import("@oxlint/plugins").Rule;
|
|
15
15
|
//#endregion
|
|
16
|
+
//#region src/rules/require-take-with-skip/index.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* 受检的 Repository 查询方法名称集合
|
|
19
|
+
*
|
|
20
|
+
* find / findAndCount 是 TypeORM Repository 接受 FindManyOptions 的分页查询方法,
|
|
21
|
+
* skip/take 在此处生效。findOne / count 等不接受分页参数,不在检测范围。
|
|
22
|
+
*/
|
|
23
|
+
declare const PAGINATED_QUERY_METHODS: ReadonlySet<string>;
|
|
24
|
+
/**
|
|
25
|
+
* require-take-with-skip 规则定义
|
|
26
|
+
*
|
|
27
|
+
* 检测 TypeORM Repository.find/findAndCount 只传 skip 不传 take 的反模式。
|
|
28
|
+
* 使用 createOnce 替代 create 以获得 Oxlint 最佳性能。
|
|
29
|
+
*/
|
|
30
|
+
declare const requireTakeWithSkipRule: import("@oxlint/plugins").Rule;
|
|
31
|
+
//#endregion
|
|
16
32
|
//#region src/index.d.ts
|
|
17
33
|
/**
|
|
18
34
|
* TypeORM 插件
|
|
@@ -22,4 +38,4 @@ declare const noStringEntityRefRule: import("@oxlint/plugins").Rule;
|
|
|
22
38
|
*/
|
|
23
39
|
declare const typeormPlugin: import("@oxlint/plugins").Plugin;
|
|
24
40
|
//#endregion
|
|
25
|
-
export { RELATION_DECORATORS, typeormPlugin as default, typeormPlugin, noStringEntityRefRule };
|
|
41
|
+
export { PAGINATED_QUERY_METHODS, RELATION_DECORATORS, typeormPlugin as default, typeormPlugin, noStringEntityRefRule, requireTakeWithSkipRule };
|
package/dist/index.js
CHANGED
|
@@ -1 +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,
|
|
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=new Set([`find`,`findAndCount`]);function s(e){if(e.type!==`CallExpression`)return null;let t=e.callee;if(t.type!==`MemberExpression`)return null;let n=t.property;return n.type!==`Identifier`||!o.has(n.name)?null:e}function c(e){let t=null,n=!1;for(let r of e.properties){if(r.type===`SpreadElement`)return null;if(r.type!==`Property`)continue;let e=l(r.key);e!==null&&(e===`skip`?t=r:e===`take`&&(n=!0))}return t!==null&&!n?t:null}function l(e){if(e.type===`Identifier`)return e.name;if(e.type===`Literal`){let t=e.value;if(typeof t==`string`)return t}return null}const u=e({meta:{type:`problem`,docs:{description:`禁止 TypeORM Repository.find/findAndCount 只传 skip 不传 take。MySQL 系 driver 对 OFFSET 不带 LIMIT 抛 OffsetWithoutLimitNotSupportedError,该错误仅在运行时、针对 MySQL 方言触发,类型系统与 SQLite 方言测试均无法捕获。`}},createOnce(e){return{CallExpression(t){let n=s(t);if(n===null)return;let r=n.arguments[0];if(r===void 0||r.type!==`ObjectExpression`)return;let i=c(r);if(i===null)return;let a=n.callee.property.name;e.report({node:i,message:`${a} 的 FindManyOptions 含 skip 但缺少 take。MySQL 系 driver 对 OFFSET 不带 LIMIT 抛 OffsetWithoutLimitNotSupportedError(仅运行时、仅 MySQL 方言触发,类型系统与 SQLite 测试无法捕获)。请配对设置 take(分页场景用 @longzai-intelligence-pagination/typeorm 的 paginateWithRepository 等工具,它们强制 skip+take 成对;批量删除场景改用 QueryBuilder.delete().limit() 在 SQL 层直接删除)。`})}}}}),d=t({meta:{name:`@longzai-intelligence-oxlint/typeorm-plugin`},rules:{"no-string-entity-ref":a,"require-take-with-skip":u}});export{o as PAGINATED_QUERY_METHODS,n as RELATION_DECORATORS,d as default,d as typeormPlugin,a as noStringEntityRefRule,u as requireTakeWithSkipRule};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@longzai-intelligence-oxlint/typeorm-plugin",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"scripts": {
|
|
22
22
|
"build": "lzi-builder",
|
|
23
|
-
"build:prod": "NODE_ENV=production
|
|
23
|
+
"build:prod": "NODE_ENV=production bun run build",
|
|
24
24
|
"prepublishOnly": "bun run build:prod",
|
|
25
25
|
"dev": "lzi-builder --watch",
|
|
26
26
|
"clean": "lzi-dev-cli clean",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"typecheck:test": "tsgo --noEmit -p tsconfig/test.json"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@longzai-intelligence-oxlint/core": "0.1.
|
|
38
|
+
"@longzai-intelligence-oxlint/core": "0.1.4",
|
|
39
39
|
"@oxlint/plugins": "^1.74.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|