-
Notifications
You must be signed in to change notification settings - Fork 6
Preview/prismalint #36
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"] | ||
} | ||
] | ||
Comment on lines
+28
to
+34
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 Option name Up-stream docs use - "forNames": ["tenantId"] + "forFieldNames": ["tenantId"] 📝 Committable suggestion
Suggested change
"require-field-index": [
"error",
{
"forAllRelations": true,
"forNames": ["tenantId"]
}
]
"require-field-index": [
"error",
{
"forAllRelations": true,
"forFieldNames": ["tenantId"]
}
]
🤖 Prompt for AI Agents
|
||
} | ||
} |
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" | ||
} | ||
Comment on lines
+6
to
+9
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 Hard-coding the connection string makes local & CI setup brittle Replace the literal - url = "fake-url" + url = env("DATABASE_URL") 📝 Committable suggestion
Suggested change
datasource db {
provider = "postgresql"
url = "fake-url"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
🤖 Prompt for AI Agents
|
||
|
||
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 Users { +model User { id String @id - emailAddress String - tenantId String - removeMe String @ignore + tenantId String + emailAddress String + // removeMe was required but ignored. Either make it optional or drop it entirely. + // removeMe String? @ignore + + @@index([tenantId]) Renaming the model will require cascading changes in your codebase & migrations, but it brings the schema in line with the configured rules. 📝 Committable suggestion
Suggested change
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
tenantId String
emailAddress String
// removeMe was required but ignored. Either make it optional or drop it entirely.
// removeMe String? @ignore
@@index([tenantId])
tenant Tenant @relation(fields: [tenantId], references: [id])
@@map(name: "users")
}
🤖 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]) + + @@index([userId]) } 📝 Committable suggestion
Suggested change
model UserRole {
id String @id
userId String @map(name: "userid")
// No mapping.
}
model UserRole {
id String @id
userId String @map(name: "userid")
user User @relation(fields: [userId], references: [id])
@@index([userId])
}
🤖 Prompt for AI Agents
|