Never Without Linter and Code Formatter
Code sometimes feels like language: there are many different ways to say something, and it's beautiful that way. But as with language, it makes sense to agree on a certain spelling so that you can concentrate on what's important: the code. You don't want to be distracted by formatting. That's exactly what linters and code formatters are for: they are tools that automatically detect spelling or grammatical errors and check the formatting of your code and adapt it to standards.
How does it work?
Linters and code formatters usually come as plugins for your editor and show you errors while you are writing your code and fix them when you save it. Code formatters like Prettier format your code according to clear rules that you don't have to configure, so religious discussions are a thing of the past: whether curly braces belong at the end of a line or in a new line is decided by Prettier, and you can concentrate on your code instead of formatting it.
Entry hurdle configuration
Once your linter and code formatter are up and running, you'll save time without end; however, sometimes configuration can take time and not work right away, especially if your linter and code formatter don't immediately want to work together the way you want them to. Don't be discouraged by this: once the configuration is set up, you will have peace of mind and the initial effort is by far outweighed by the time you will save in the end. It's worth the effort, if there even is one!
Everything can, nothing must?
Of course, you can do without and write your code whichever way you want: but I predict that you will spend countless hours reformatting your code. That you will find it harder to read code from others. And that your others might be unwilling to read or even accept your code: many open source projects have very clear guidelines for their code for a reason. It's just more efficient that way.
No one forces you to use linters and code formatters, just like no one forces you to use version control – but your life becomes so much easier when you do, that I cannot recommend it enough.
And as someone who has worked in programming long before automatic code formatters have been a thing, I cannot stress enough what a blessing it is to see your quickly written and more or less unformatted code format itself within milliseonds once you press CRTL+S. Still feels like magic to a programming geezer like me.
Not only do I not have to waste time to think about formatting anymore or discuss it with my peers, I also save time when writing the code itself. Why not leave that work to the machines; I'm there for thinking and not for stupid formatting, my computer can do that faster and better than I can.
Summary
- Linters show errors and optimization suggestions and correct them automatically if desired
- Code formatters automatically format your code according to fixed rules
- You make fewer mistakes
- You save time writing code
- You don't have to think about or discuss code style
- You can think about the "words", not the "spelling"