Skip to content

prisma lint #263

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 83 additions & 0 deletions docs/tools/prisma-lint.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
title: Prisma Lint
sidebar_label: Prisma Lint
description: CodeRabbit's guide to Prisma Lint.
---

```mdx-code-block
import ProPlanNotice from '@site/src/components/ProPlanNotice.mdx';

<ProPlanNotice />
```

[Prisma Lint](https://github.com/loop-payments/prisma-lint) is a linter for Prisma schema files that helps enforce consistent conventions and best practices in your Prisma schemas.

## Files

Prisma Lint will run on files with the following extensions:

- `.prisma`

## Configuration

Prisma Lint supports the following config files:

- `.prismalintrc.json`
- User-defined config file set at `reviews.tools.prismalint.config_file` in your project's `.coderabbit.yaml` file or setting the "Review → Tools → Prisma Lint → Config File" field in CodeRabbit's settings page.

:::note

By default, Prisma Lint looks for schema files at `prisma/schema.prisma`. If you have a custom schema path specified in the `prisma.schema` field within `package.json`, that will be used instead.

:::

## Rule Configuration

Rules can be configured in your `.prismalintrc.json` file. Here's an example configuration:

```json
{
"rules": {
"field-name-mapping-snake-case": [
"error",
{
"compoundWords": ["S3"]
}
],
"model-name-grammatical-number": [
"error",
{
"style": "singular"
}
],
"require-field-index": [
"error",
{
"forAllRelations": true,
"forNames": ["tenantId"]
}
]
}
}
```

## Ignoring Rules

You can ignore rules using three-slash (`///`) comments inside your Prisma models:

```prisma
model User {
/// prisma-lint-ignore-model
// Ignores all lint rules for this model
}

model Post {
/// prisma-lint-ignore-model require-field
// Ignores specific rules for this model
}
```

## Links

- [Prisma Lint GitHub Repository](https://github.com/loop-payments/prisma-lint)
- [Prisma Lint Rules Documentation](https://github.com/loop-payments/prisma-lint/blob/main/RULES.md)
2 changes: 2 additions & 0 deletions docs/tools/tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ Remove extraneous f prefix
| TSX | [Biome][Biome] | Code Quality |
| Typescript | [Biome][Biome] | Code Quality |
| YAML | [YAMLlint][YAMLlint] | Code Quality |
| Prisma | [Prisma Lint][PrismaLint] | Code Quality |

[ShellCheck]: ./shellcheck.md
[SQLFluff]: ./sqlfluff.md
Expand All @@ -100,3 +101,4 @@ Remove extraneous f prefix
[CircleCI]: ./circleci.md
[Semgrep]: ./semgrep.md
[Pipeline]: ./pipeline-remediation.md
[PrismaLint]: ./prisma-lint.md
Loading