intellij-prisma icon indicating copy to clipboard operation
intellij-prisma copied to clipboard

add prettier reformat?

Open johhansantana opened this issue 5 years ago • 2 comments

Hello and thank you for this plugin!

Is there a way to reformat in a similar way that you can in VSCode? I think this is something done via prettier but I'm not really sure.

https://github.com/prisma/prisma/issues/1761

johhansantana avatar May 11 '20 10:05 johhansantana

Hello! There is a prisma format command that does exactly that. I will take a look at how to integrate this in the plugin but in the meantime, you should be able to add a custom file watcher directly in webstorm.

gabrielcolson avatar May 11 '20 12:05 gabrielcolson

if I do format code -- it will autoformat .prisma files for me

example if I have:

model Expense {
  id        String   @id @default(auto()) @map("_id") @db.ObjectId
  title     String
  amount    Float
  date      DateTime
  dateAdded DateTime @default(now())
}

model User {
  id       String    @id @default(auto()) @map("_id") @db.ObjectId
  email    String
  password String
  expenses Expense[]
}

it will autoformat that to:

model Expense {
  id        String   @id @default(auto()) @map("_id") @db.ObjectId
  title     String
  amount    Float
  date      DateTime
  dateAdded DateTime @default(now())
  User      User?    @relation(fields: [userId], references: [id])
  userId    String?  @db.ObjectId
}

model User {
  id       String    @id @default(auto()) @map("_id") @db.ObjectId
  email    String
  password String
  expenses Expense[]
}

rstudner avatar May 31 '23 19:05 rstudner