The Hardest Program I've Ever Written – How a code formatter works (2015)
AFAIK no formatting can understand intent. Example. I want my canvas.drawImage calls that take 9 arguments to be formatted with arguments 2-5 on one line, and 6-9 on another line because 2-5 are sourceX, sourceY, sourceWidth, sourceHeight, and 6-9 are destX, destY, destWidth, destHeight.<p>That's just one example of 100s where an auto formatter can not figure out intent.<p>Another example, I often align numbers and width and height<p><pre><code>    // convert from screen coords to clip space
    clipX = mouseX / screenWidth  *  2 - 1
    clipY = mouseY / screenHeight * -2 + 1  
</code></pre>
Another example would be how to format an if block. Depending on your style guide<p><pre><code>    if (cond) single-statement
</code></pre>
might be ok. Or maybe you want them on different lines. Or maybe you require brackets. Or maybe you don't. But there will almost ways be some place in the code where an exception to your style guide makes the code more readable. Auto formatters don't understand those exceptions.<p>This is why AFAIK many major projects do NOT use an auto-formatter. Firefox, Safari, Chrome for example. Because there are places where an auto-formatter will make the code far less readable. They'll give the advice that you are free to run an auto-formatter on your own changes but adding an automated one is a no-go. Even the Flutter team does not use an auto-formatter<p><a href="https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#formatting" rel="nofollow">https://github.com/flutter/flutter/wiki/Style-guide-for-Flut...</a>