prisma-lint
raw JSON → 0.13.1 verified Fri May 01 auth: no javascript
A linter for Prisma schema files, currently at v0.13.1. It provides a configurable set of rules (e.g., naming conventions, field order, index requirements) similar to ESLint, all disabled by default. Supports Prisma 7+ config files (prisma.config.ts) and legacy package.json schema path. Uses ignore comments (/// prisma-lint-ignore-model, /// prisma-lint-ignore-field) and multiple output formats (simple, contextual). Released frequently with new rules and fixes. Differentiates from other Prisma tools by focusing purely on linting schema files, not migrations or querying.
Common errors
error Error: Cannot find module 'prisma-lint' ↓
cause prisma-lint not installed or installed globally instead of locally.
fix
Install as dev dependency: npm install --save-dev prisma-lint
error Error: No configuration found for prisma-lint ↓
cause Missing .prismalintrc.json or similar config file.
fix
Create a configuration file (e.g., .prismalintrc.json) with a "rules" field.
error Error: Unknown rule 'model-name-camel-case' ↓
cause Rule name is misspelled or does not exist.
fix
Check the RULES.md file for valid rule names. Common rules: 'model-name-camel-case', 'field-name-camel-case'.
error Error: Failed to load schema from 'prisma/schema.prisma' ↓
cause Schema file does not exist or path is incorrect.
fix
Verify the schema path. Provide explicit path via CLI argument or configure in prisma.config.ts / package.json#prisma.schema.
Warnings
breaking Schema path resolution changed in v0.13.0. Prisma 7+ config files (prisma.config.ts or .config/prisma.ts) are now preferred over package.json#prisma.schema. ↓
fix If you use Prisma 7+, migrate your schema path to prisma.config.ts. If you rely on package.json#prisma.schema, ensure no conflicting Prisma 7 config exists.
deprecated Rule `enum-value-snake-case` is deprecated in v0.11.0 in favor of `enum-value-case`. ↓
fix Replace `enum-value-snake-case` with `enum-value-case` and configure `case: 'lower'` (or adjust as needed).
gotcha All rules are disabled by default. You must create a configuration file (e.g., .prismalintrc.json) to enable rules. ↓
fix Create a .prismalintrc.json file with a "rules" object listing the rules you want to enable and their severity.
gotcha Ignore comments require exactly three slashes (///). Two slashes (//) or four slashes (////) are ignored. ↓
fix Use /// prisma-lint-ignore-model or /// prisma-lint-ignore-field with exactly three slashes.
gotcha The `compoundWords` option in snake-case rules is case-sensitive. Wrong case causes false positives. ↓
fix Ensure compound words match the exact casing used in your schema (e.g., 'S3' not 's3').
Install
npm install prisma-lint yarn add prisma-lint pnpm add prisma-lint Imports
- default wrong
const prismaLint = require('prisma-lint')correctimport prismaLint from 'prisma-lint' - lint wrong
const { lint } = require('prisma-lint')correctimport { lint } from 'prisma-lint' - LoadConfigOptions wrong
import { LoadConfigOptions } from 'prisma-lint'correctimport type { LoadConfigOptions } from 'prisma-lint'
Quickstart
import { lint } from 'prisma-lint';
async function main() {
const results = await lint({
schemaPath: 'prisma/schema.prisma',
config: {
rules: {
'model-name-camel-case': 'error',
'field-name-camel-case': ['error', { allowUnderscore: false }],
},
},
});
console.log(JSON.stringify(results, null, 2));
}
main().catch(console.error);