UNPKG

@wisely-company/eslint-plugin

Version:
55 lines (51 loc) 1.55 kB
"use strict"; module.exports = { meta: { type: "problem", docs: { description: "MikroORM 엔티티 매니저에서 fork() 사용을 지양합니다.", category: "Best Practices", recommended: true, }, messages: { noMikroOrmFork: "MikroORM 엔티티 매니저에서 fork() 사용을 지양합니다. 대신 요청별 엔티티 매니저를 위해 RequestContext를 사용하세요.", }, schema: [], }, create(context) { return { CallExpression(node) { if (node.callee.type !== "MemberExpression") { return; } if ( node.callee.property.type === "Identifier" && node.callee.property.name === "fork" ) { // Heuristic check: if the object being called upon is named `em` or `entityManager`, // or if it's a member access like `orm.em`, it's likely the entity manager. const object = node.callee.object; if ( object.type === "Identifier" && (object.name === "em" || object.name === "entityManager") ) { context.report({ node, messageId: "noMikroOrmFork", }); } else if ( object.type === "MemberExpression" && object.property.type === "Identifier" && object.property.name === "em" ) { context.report({ node, messageId: "noMikroOrmFork", }); } } }, }; }, };