Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading