@prisma-next/eslint-plugin
ESLint plugin for Prisma Next query builder that provides TypeScript-powered linting and validation of query builder build() calls.
Installation
npm install --save-dev @prisma-next/eslint-plugin @typescript-eslint/parser
Configuration
ESLint 9 (Flat Config)
Add to your ESLint configuration:
import prismaNext from '@prisma-next/eslint-plugin';
export default [
{
files: ['**/*.ts', '**/*.tsx'],
languageOptions: {
parser: '@typescript-eslint/parser',
parserOptions: {
project: './tsconfig.json',
},
},
plugins: {
'@prisma-next': prismaNext,
},
rules: {
'@prisma-next/lint-build-call': 'error',
},
},
];
Or use the recommended flat configuration:
import prismaNext from '@prisma-next/eslint-plugin';
export default [
prismaNext.configs['flat/recommended'],
];
ESLint 8 (Legacy Configuration)
{
"plugins": ["@prisma-next"],
"rules": {
"@prisma-next/lint-build-call": "error"
}
}
Rules
lint-build-call
Validates query builder build() calls using TypeScript type information to catch common issues and enforce best practices.
What it checks
- Unbounded Queries: Detects SELECT queries without
.limit() calls that could fetch unlimited rows
- Excessive Limits: Warns when
.limit() exceeds a configurable maximum value
Options
{
requireLimit?: boolean;
maxLimit?: number;
}
Examples
❌ Incorrect - Unbounded query:
const plan = sql
.from(userTable)
.select({
id: userTable.columns.id,
email: userTable.columns.email,
})
.build();
✅ Correct - Bounded query:
const plan = sql
.from(userTable)
.select({
id: userTable.columns.id,
email: userTable.columns.email,
})
.limit(100)
.build();
Configuration Examples
Basic usage:
{
'@prisma-next/lint-build-call': 'error'
}
Custom configuration:
{
'@prisma-next/lint-build-call': [
'error',
{
requireLimit: true,
maxLimit: 500,
}
]
}
Disable limit requirement:
{
'@prisma-next/lint-build-call': [
'error',
{
requireLimit: false
}
]
}
TypeScript Integration
This plugin leverages TypeScript's type checker to provide accurate analysis of query builder calls. For best results:
- Ensure
@typescript-eslint/parser is configured
- Include
project in parser options pointing to your tsconfig.json
- Run ESLint on TypeScript files (
.ts, .tsx)
Contributing
This plugin is part of the Prisma Next project. See the main repository for contribution guidelines.
License
See the main Prisma Next repository for license information.