Piotr Gajek
written byPiotr Gajek
posted on December 10, 2023
Technical Architect and Full-stack Salesforce Developer. He started his adventure with Salesforce in 2017. Clean code lover and thoughtful solutions enthusiast.

Format your code with formatting tool


Do you need a Code Formatting Tool? Maybe code formatting is just a preference?

Let's figure it out.


Unformatted code leads to problems.

Let's say you agree with the statement: "Code formatting is just a preference." Each developer on your project has different preferences, different formatting tools, or maybe they format code themselves.

What will happen when you try to change something in an existing class?

A lot of changes.

not formatted code

Try to find where your changes are.
Try to stage only your small part.

It's hard, right?

Best Practice

The rule is simple:

Code formatting across the project should be consistent.
Choose a formatting tool, configure it, and stick to it no matter what.

You can have different formatting preferences, but:
Team/Consistency > My preferences.

When common formatting is applied for the whole project, code is much easier and faster to read and understand. Developers know what to expect. It also makes our work much more efficient. Take a look at the diff. How easy is to figure out where your change is?

formatted code

The most popular code formatting tool is Prettier, however there are some alternatives such as:

Use formatter, but don't forget to install eslint as well.

If you have any questions feel free to ask in the comment section below. 🙂

Was it helpful? Check out our other great posts here.


Buy Me A Coffee