Skip to content
Esc

@noctcore/eslint-plugin-prisma

v1.0.012 rules7 recommended5 opt-innamespace noctcore-prisma

A bad fit if you are not multi-tenant, or if tenancy lives in Postgres row-level security rather than a Prisma client extension; most of these rules assume the extension pattern.

Prisma tenancy, data integrity and transaction guardrails around a tenant-scoping client extension.

Multi-tenant Prisma code fails quietly: a query through the unscoped client with no tenant filter, a tenant id taken from the request body, two writes that should be atomic and are not, an audit log written inside a transaction that rolls it back with the work, a soft-deleted row that comes back in a list.

It will yell at you about which client you query through and what your where contains. The six preset rules hold with no project knowledge. Four more need your model registry (tenantModels, softDeleteModels, restrictions) and are deliberately left out of the preset, because a rule that reports nothing would read as coverage you do not have. mutation-entry-must-reach-audit needs type information and follows calls across files. It is a bad fit if you are not multi-tenant, or if tenancy lives in Postgres row-level security rather than a Prisma client extension; most of these rules assume the extension pattern.

Install
npm install --save-dev @noctcore/eslint-plugin-prisma @typescript-eslint/parser
# or: bun add -D / pnpm add -D @noctcore/eslint-plugin-prisma @typescript-eslint/parser

The recommended preset enables 7 of 12 rules. The rules board below builds the flat config: start from a preset, switch single rules between error and off, and copy the result.

Each rule links to its page, with the options it takes and Incorrect and Correct examples. A good first read is no-unscoped-prisma-outside-allowlist.

7 of 12 at error

--fixsuggestionsneeds optionstype infoEach switch sets a rule to error or off.

mutation-entry-must-reach-audit
Require a mutation entry point whose type-resolved call graph reaches a Prisma write to also reach an audit write. Reports only when the whole graph was read.
Type information required
opt-in
no-audit-write-in-transaction
Disallow an audit-log write inside a $transaction callback, where it rolls back with the business work. It does not check that mutations are audited at all.
recommended
no-cross-tenant-id-in-where
Disallow a Prisma query or write whose tenant id in where or data is read from client input. Without row-level security, a client-supplied tenant id is a cross-tenant access (IDOR).
recommended
no-raw-sql-outside-allowlist
Disallow raw Prisma SQL ($queryRaw, $executeRaw, $queryRawTyped, *Unsafe) that can touch a table outside an allowlist. A raw query has no model, so a tenant-scope extension passes it through unscoped.
recommended
no-request-body-in-write
Disallow a Prisma write whose data (or where) is the raw request body. Passing client input straight through lets a caller set any column (mass assignment) or widen the filter.
recommended
no-unscoped-prisma-outside-allowlist
Disallow the unscoped Prisma client and tenant-scope escape-hatch functions outside an allowlist of seeds, migrations, isolation tests, and designated system files.
recommended
prisma-tx-uses-tx-not-client
Inside a $transaction(async (tx) => ...) callback, writes must go through the tx parameter, not the outer client, so they participate in the transaction and roll back together.
recommended
prisma-write-in-transaction
Disallow two or more Prisma writes in a single function/method body that are not wrapped in a $transaction. A partial failure between writes leaves half-written state.
recommended
restrict-model-writes
Restrict Prisma writes to configured models (or to configured columns of them) to the files that own those writes, including nested relation writes. It fences who writes; it does not validate which values or state transitions are legal.
Needs options
opt-in
soft-deletable-tables-require-deleted-at
Require a filtered read or bulk write on a soft-deletable Prisma model to exclude soft-deleted rows in its where. Soft delete is convention only, with no Prisma extension injecting the filter, so a query that omits it reads and mutates deleted rows.
Needs options
opt-in
tenant-scoped-tables-require-where
Require every tenant field in the where of a read or bulk write on a tenant-scoped model through the unscoped client, and a scope column in the where of any query on a hand-scoped model.
Needs options
opt-in
tenant-write-must-carry-tenant-id
Require every tenant field in the data of a create on a tenant-scoped Prisma model through the unscoped client, which does not inject the tenant scope.
Needs options
opt-in