Skip to content

Latest commit

 

History

History
83 lines (62 loc) · 1.9 KB

prisma-lint.md

File metadata and controls

83 lines (62 loc) · 1.9 KB
title sidebar_label description
Prisma Lint
Prisma Lint
CodeRabbit's guide to Prisma Lint.
import ProPlanNotice from '@site/src/components/ProPlanNotice.mdx';

<ProPlanNotice />

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:

{
	"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:

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