From 5a06e8ec989c677beb919996658cace78cf8713b Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 2 Apr 2025 13:20:21 -0400 Subject: [PATCH 1/2] lint --- docs/tools/prisma-lint.md | 83 +++++++++++++++++++++++++++++++++++++++ docs/tools/tools.md | 2 + 2 files changed, 85 insertions(+) create mode 100644 docs/tools/prisma-lint.md diff --git a/docs/tools/prisma-lint.md b/docs/tools/prisma-lint.md new file mode 100644 index 00000000..0b6c415f --- /dev/null +++ b/docs/tools/prisma-lint.md @@ -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'; + + +``` + +[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) diff --git a/docs/tools/tools.md b/docs/tools/tools.md index 00a3efc2..a700825f 100644 --- a/docs/tools/tools.md +++ b/docs/tools/tools.md @@ -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 @@ -100,3 +101,4 @@ Remove extraneous f prefix [CircleCI]: ./circleci.md [Semgrep]: ./semgrep.md [Pipeline]: ./pipeline-remediation.md +[PrismaLint]: ./prisma-lint.md From cf0e65aa1ac624d940e1cd51aa5497ec19fbc6a5 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 2 Apr 2025 13:23:59 -0400 Subject: [PATCH 2/2] dont show rules direct to docs --- docs/tools/prisma-lint.md | 49 +++++---------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/docs/tools/prisma-lint.md b/docs/tools/prisma-lint.md index 0b6c415f..33a36904 100644 --- a/docs/tools/prisma-lint.md +++ b/docs/tools/prisma-lint.md @@ -23,6 +23,11 @@ Prisma Lint will run on files with the following extensions: Prisma Lint supports the following config files: - `.prismalintrc.json` +- `.prismalintrc` +- `.prismalintrc.js` +- `.prismalintrc.yaml` +- `.prismalintrc.yml` +- `prismalint.config.js` - 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 @@ -33,49 +38,7 @@ By default, Prisma Lint looks for schema files at `prisma/schema.prisma`. If you ## 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 -} -``` +Rules can be configured in your `.prismalintrc.json` file. See the [Prisma Lint Rules Documentation](https://github.com/loop-payments/prisma-lint/blob/main/RULES.md) for more information on the available rules and their configuration options. ## Links