ESLint plugin ensuring best practices and code quality for Prisma with TypeScript
npm install eslint-plugin-prismaESLint plugin ensuring best practices and code quality for Prisma with TypeScript
This ESLint plugin is designed to help developers maintain best practices and enforce code quality when using Prisma in TypeScript projects. It includes a set of custom rules tailored to the specific requirements and idioms of Prisma, aiming to prevent common pitfalls and encourage efficient, clean, and secure database interactions.
You'll first need to install ESLint:
``sh`
npm install eslint --save-dev
Next, install eslint-plugin-prisma:
`sh`
npm install eslint-plugin-prisma --save-dev
Load the recommended configuration:
`json`
{
"extends": ["plugin:eslint-plugin-prisma/recommended"]
}
Add prisma to the plugins section of your .eslintrc configuration file. You can omit the eslint-plugin- prefix.
Then configure the rules you want to use under the rules section:
`json`
{
"plugins": ["prisma"],
"rules": {
"prisma/no-unsafe": "error",
"prisma/require-select": "error"
}
}
| | Name |
| :- | :------------ |
| ✅ | recommended |
💼 Configurations enabled in.\
✅ Set in the recommended` configuration.\
💡 Manually fixable by editor suggestions.
| Name | Description | 💼 | 💡 |
| :--------------------------------------------- | :-------------------------------------------------------- | :- | :- |
| no-unsafe | Disallow the use of potentially unsafe Prisma methods | ✅ | |
| require-select | Forces explicit selection of all fields in Prisma queries | ✅ | 💡 |