-
Notifications
You must be signed in to change notification settings - Fork 6
Preview/prismalint #39
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,2 @@ | ||
reviews: | ||
path_filters: ["**/.prismalintrc.json",".prismalintrc.json", "**/example.prisma", "example.prisma"] |
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" | ||
} | ||
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. Datasource URL should come from env var Hard-coding - 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 | ||
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. Ignored field is required
🤖 Prompt for AI Agents
|
||
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
A minimal conforming refactor: -model Users { - id String @id - emailAddress String - tenantId String - removeMe String @ignore - tenant Tenant @relation(fields: [tenantId], references: [id]) - @@map(name: "users") -} +model User { + tenantId String + id String @id + emailAddress String + // removeMe removed – ignored required fields not allowed + tenant Tenant @relation(fields: [tenantId], references: [id]) + + @@index([tenantId]) + @@map(name: "users") +} 📝 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 {
tenantId String
id String @id
emailAddress String
// removeMe removed – ignored required fields not allowed
tenant Tenant @relation(fields: [tenantId], references: [id])
@@index([tenantId])
@@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") | ||
} | ||
Comment on lines
+26
to
+29
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
Rule model UserRoleFoo { id String @id - @@map(name: "unexpected_snake_case") + @@map(name: "user_role_foo") } 📝 Committable suggestion
Suggested change
model UserRoleFoo {
id String @id
@@map(name: "unexpected_snake_case")
}
model UserRoleFoo {
id String @id
@@map(name: "user_role_foo")
}
🧰 Tools🪛 PrismaLint (0.10.2)26-26: Model name must be mapped to "user_role_foo". (model-name-mapping-snake-case) 🤖 Prompt for AI Agents
|
||
|
||
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") + 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
|