How can I modify how Prettier formats JavaScript?

Prettier formats classes like this:

class Foo {
  bar = 1
}

I want to change this behavior to

class Foo {

  bar = 1
}

How can I write a Prettier Plugin or something that modifies a single behavior?

Related:

>Solution :

to quote the Prettier docs:

Prettier is not a kitchen-sink code formatter that attempts to print your code in any way you wish. It is opinionated.

So, short answer: you can’t.

A few options due exist (you can see them in the linked docs), but only serve as either compatibility fixes or due to "high demand", but I would not expect any functionality of the kind you’re looking for to ever be added.

Edit:

A full list of available options can be found here

Leave a Reply