mirror of
https://github.com/Drop-OSS/drop.git
synced 2025-11-22 12:41:10 +10:00
fix: add no-prisma-delete lint
This commit is contained in:
32
rules/no-prisma-delete.mts
Normal file
32
rules/no-prisma-delete.mts
Normal file
@ -0,0 +1,32 @@
|
||||
import type { TSESLint } from "@typescript-eslint/utils";
|
||||
|
||||
export default {
|
||||
meta: {
|
||||
type: "problem",
|
||||
docs: {
|
||||
description: "Don't use Prisma error-prone .delete function",
|
||||
},
|
||||
messages: {
|
||||
noPrismaDelete:
|
||||
"Prisma .delete(...) function is used. Use .deleteMany(..) and check count instead.",
|
||||
},
|
||||
schema: [],
|
||||
},
|
||||
create(context) {
|
||||
return {
|
||||
CallExpression: function (node) {
|
||||
const funcId = node.callee.property;
|
||||
if (!funcId || funcId.name !== "delete") return;
|
||||
const tableExpr = node.callee.object;
|
||||
if (!tableExpr) return;
|
||||
const prismaExpr = tableExpr.object;
|
||||
if (!prismaExpr || prismaExpr.name !== "prisma") return;
|
||||
context.report({
|
||||
node,
|
||||
messageId: "noPrismaDelete",
|
||||
});
|
||||
},
|
||||
};
|
||||
},
|
||||
defaultOptions: [],
|
||||
} satisfies TSESLint.RuleModule<"noPrismaDelete">;
|
||||
Reference in New Issue
Block a user