tribou / react-template

Build a server-rendered React app and share code across web, React Native, and Electron
Apache License 2.0
4 stars 9 forks source link

Feature/prettier #70

Closed olivoil closed 6 years ago

olivoil commented 6 years ago

Here's a suggestion to let prettier handle all formatting. Changes include:

olivoil commented 6 years ago

I added .prettierignore, a prettier npm task to format all files, and ran it against the project.

I did not however add a prettier config block or set the project to use tabs, intentionally. I think it's more beneficial to not set these options.

I think it makes more sense, especially for a starter project, to stay as neutral as possible style-wise and just embrace the defaults. It goes in line with prettier's philosophy about options and is echoed by the community in one of the most +1'd issues arguing against them.

I could detail which ones I do not like and why from your request, but rather than doing that, I'm hoping prettier can avoid conflicts arising from differing tastes and opinions about styling, and not shift to conflicts about which prettier options to pick and choose. Nobody usually feels entirely good after resolving those conflicts. Using the defaults seems a good way to avoid that.

And if anyone really wants to set these options for their individual projects despite hearing these reasons, the PR makes it easy to do so after cloning the template. There might even be a way to set husky hooks to apply formatting on pull, and re-apply without options on push so everyone can look at a project with their particular option lens without imposing their choice onto others.

tribou commented 6 years ago

You know, you make a sound argument; and it does make more sense. 🙂 Approved!

tribou commented 6 years ago

@olivoil I've been consistently hitting an issue that I would like to bring up for consideration: trailing commas. It seems that if you add a new line/item to an array/object/etc and you forget to add a trailing comma on the previous line, prettier breaks because it can't parse the two lines without trailing commas. Consequently, the code doesn't run, and I find myself searching for the syntax error for a bit before realizing what happened. Maybe this is just particular to my coding habits? Regardless, it's causing a poor "continuous flow" experience for me. 😞

The reason for this consideration is I'm thinking it falls under the category of "safety" or "runtime error prevention" rather than "stylistic preference." So I'm wondering if this falls under the Principal of The Good Parts:

If a feature is sometimes useful and sometimes dangerous and if there is a better option then always use the better option.

Let me know your thoughts.