New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

prisma-lint

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-lint

A linter for Prisma schema files.

  • 0.0.16
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17K
decreased by-2.07%
Maintainers
1
Weekly downloads
 
Created
Source

prisma-lint

A linter for Prisma schema files.

Installation

> npm install --save-dev prisma-lint
# or
> yarn add --dev prisma-lint

Usage

> npx prisma-lint path/to/schema.prisma
# or
> yarn prisma-lint path/to/schema.prisma

The arguments can be globs, directories, or file paths. The default path is prisma/schema.prisma.

Run yarn prisma-lint --help for all options.

Rules

The file RULES.md contains documentation for each rule. All rules are disabled by default. Create a configuration file to enable the rules you'd like to enforce.

Configuration

The configuration file format is loosely based on eslint's conventions. Here's an example .prismalintrc.json:

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

See Loop's configuration for a more thorough example. Configuration files are loaded with cosmiconfig.

Ignore comments

Rules can be ignored with three-slash (///) comments inside models.

To ignore all lint rules for a model and its fields:

model User {
  /// prisma-lint-ignore-model
}

To ignore specific lint rules for a model and its fields:

model User {
  /// prisma-lint-ignore-model require-field
  /// prisma-lint-ignore-model require-field-type
}

Some rules support parameterized ignore comments like this:

model User {
  /// prisma-lint-ignore-model require-field revisionNumber,revisionCreatedAt
}

Omitting revisionNumber and revisionCreatedAt fields from this model will not result in a violation. Other required fields remain required.

FAQs

Package last updated on 31 May 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc