Stop wasting time making sure your statements end with a semicolon. All that indenting and shifting of blocks of code left/right? Who’s got time for all that?
I’m in shock when I pair with developers and see that they’re spending so much time fidgeting about and making sure spacing and formatting is correct.
As programmers, we have the ability to make and use tools to help us do our work more effectively and efficiently. Why not make your computer to do the work of formatting so you don’t have to? Isn’t the whole point of writing software to offload work that machines can do rather than humans?
For any language, I’d be surprised if you couldn’t find a linter for it: so set one up, add it to your toolbelt, and save your time and your fingers for the more useful work of writing good code. You’ve got enough things to think about, so delegate the task of formatting to your computer instead.
Here are a few examples of linters:
This gives you quick and immediate feedback and updates to formatting. Rather than wait for a commit hook to run and show you which formatting rules have broken, let your editor/IDE clean up your code every time you save.
to format on save. After you hit save, you’ll see your code magically
cleaned up with all those missing
;’s and with cleaned up spaces between
Your linter or formatter should have a way to configure rules that it enforces, and you should probably do a small amount of tweaking to handle your most irksome divergences from standard configurations. But, I urge you not to keep tweaking and refining.
Here’s my advice: let it go.
If you’re spending so much time updating your rules all the time, you’re really not saving time with letting the computer to do the work for you. The convenience you get comes at a small price of control. Sure, there may be some pet peeves you have that you can’t let go, but for the most part, just set up a standard configuration and go with it.