-
Notifications
You must be signed in to change notification settings - Fork 5
Prismalint Showcase #29
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"rules": { | ||
"field-name-mapping-snake-case": [ | ||
"error", | ||
{ | ||
"compoundWords": ["S3"] | ||
} | ||
], | ||
"field-order": [ | ||
"error", | ||
{ | ||
"order": ["tenantId", "..."] | ||
} | ||
], | ||
"forbid-required-ignored-field": ["error"], | ||
"model-name-grammatical-number": [ | ||
"error", | ||
{ | ||
"style": "singular" | ||
} | ||
], | ||
"model-name-mapping-snake-case": [ | ||
"error", | ||
{ | ||
"compoundWords": ["GraphQL"] | ||
} | ||
], | ||
"require-field-index": [ | ||
"error", | ||
{ | ||
"forAllRelations": true, | ||
"forNames": ["tenantId"] | ||
} | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
generator client { | ||
provider = "prisma-client-js" | ||
output = "../generated/prisma/client" | ||
} | ||
|
||
datasource db { | ||
provider = "postgresql" | ||
url = "fake-url" | ||
} | ||
|
||
model Users { | ||
id String @id | ||
emailAddress String | ||
tenantId String | ||
removeMe String @ignore | ||
tenant Tenant @relation(fields: [tenantId], references: [id]) | ||
@@map(name: "users") | ||
} | ||
Comment on lines
+11
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion
• Model name is plural – linter rule expects singular. -model Users {
- id String @id
- emailAddress String
- tenantId String
- removeMe String @ignore
- tenant Tenant @relation(fields: [tenantId], references: [id])
- @@map(name: "users")
-}
+model User {
+ id String @id @default(uuid())
+ emailAddress String @unique
+ tenantId String
+ tenant Tenant @relation(fields: [tenantId], references: [id])
+
+ @@map(name: "users")
+ @@index([tenantId])
+} Note: Renaming the model is a breaking change; plan a migration accordingly. 🤖 Prompt for AI Agents
|
||
|
||
model Tenant { | ||
id String @id | ||
name String | ||
@@map(name: "tenant") | ||
} | ||
|
||
model UserRoleFoo { | ||
id String @id | ||
@@map(name: "unexpected_snake_case") | ||
} | ||
|
||
model UserRole { | ||
id String @id | ||
userId String @map(name: "userid") | ||
// No mapping. | ||
} | ||
Comment on lines
+31
to
+35
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion
model UserRole {
id String @id
- userId String @map(name: "userid")
- // No mapping.
+ userId String @map(name: "userid")
+ user User @relation(fields: [userId], references: [id])
+
+ @@map(name: "user_role")
+ @@index([userId])
} 🤖 Prompt for AI Agents
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Database URL must come from environment variable
Hard-coding a placeholder string will break migrations & deployments. Prisma recommends
env("DATABASE_URL")
to pick up per-environment credentials.📝 Committable suggestion
🤖 Prompt for AI Agents