Formatting JavaScript

I have been doing much research without figuring out how to use Prettier or Beautify to achieve what I want.

First, I want to align colons:
image

Second, I want to format braces like this (first brace on new line):
image

Does anyone know how to do it?

Using some C++ style braces can result in strange errors related to automatic semicolon insertion, beware

Thanks that is good to know. However, I think the colon alignment would be a good thing to have in JavaScript. It should become standard for object literals according to me.

I can understand that, we could have a script that converts from one format to a commonly accepted format.

I really like the aligned colons. They make my code cleaner. I don’t see reason why that is not standard practice.

I also enjoy aligned colons. I’m not sure how to force that is JS, only a couple of C formatters.

I think ESLint can do it.


Prettier is an opinionated formatter, they intentionally do not allow for many options.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.