Tag: tools

If you have been coding javascript for a while and working with multiple people that used to use different languages. Do you ever reviewing your code project and there are many coding standards mixed up and wasting your time to reformat each file to match your coding standard. A simple example of that is using tabs vs space to indent the code.

I got this problem, especially lately when my team is growing but our team is lack people that experienced in javascript. Which is why on today post, I will introduce you all to javascript formater called Prettier.

What it do is formatting your javascript code automatically so you don’t have to waste your time, reviewing each line and files, spending an hour just to format the code which provides nothing to the product. With this tools, you got both pretty code and time to spend on the more important task (or more time to be lazy).

It works by converting your javascript code to AST (Abstract Syntax Tree) and then pretty-printing the AST which give you with pretty and formatted code. Pretty simple, I know.

Not only that, it even got an option to set which javascript format you are going to use. I know that in javascript or similar language there has been style war. If you don’t know what it is, as you know there are many different coding standards available to use in javascript and people has trouble to agree which standard is the standard. So they decide to use their own standard. If you are using coding standard that didn’t really match with Prettier default, you can change it in the option.

If you are using Atom which is a powerful editor and my favorite programming editor, you can install it on your atom package manager or use command:

1

apm install prettier-atom

There is a downside tough. There is still some bug and the options are pretty limited. But since it still a new project, give it some time. It will be better. Regardless, it is a promising project and really useful especially if you have trouble or being overwhelmed by messy code in your project.

One note on the stability. Based on their blog post, it being used to format React, Jest, immutable-js, Haul, and many more. So you can expect good stability and less bug. You don’t have yo worry that much.