Enforce code formatting via Prettier #44
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "prettier"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Fixes #43 by introducing Prettier.
Prettier is an extremely opinionated formatter. It will reformat every single line according to its style. There are virtually no configuration options so there can be no discussion about formatting rules.
There are two parameters that are configurable; indent length and line length. Indent length has been set to 4 because that's the Java standard.
Line length defaults to 80 but has been increased to 100. The rational for this is that Prettier was created for JavaScript which is much less verbose than Java. Not only does every Java line start with 8 spaces of indentation vs. JavaScripts 0 or 2, it also has types wile JavaScript does not and uses
const
for variable declarations. Compare the two below examples as well as an actual example from the source code that is too long for the default 80 characters. I have no problem dropping down to the default 80 if that is preferred I just felt that with the average length of a line of Java code being pretty long, excessive wrapping would reduce readability.Or the following real code which is 97 characters long.
I agree that 100 characters is a good balance for readability and how much screen real estate it takes up in our development environments.
I suggest 120 characters, screens are big today, and Java is verbose.
WIP: Enforce code formatting via Prettierto Enforce code formatting via PrettierOnce merged, if anyone has work that will cause conflicts, since this is just formatting changes, discard the remote changes and keep your own and then re-run formatting to fix those files with your local changes intact.