apollographql / apollo

:rocket: Open source tools for GraphQL. Central repo for discussion.
https://www.apollographql.com
MIT License
2.62k stars 425 forks source link

Establish global .prettierrc settings, add to all packages #129

Open fbartho opened 6 years ago

fbartho commented 6 years ago

Apollo has a pretty uniform code style, in part due to running prettier in a lint-staged command that calls prettier.

Would it be a good idea to add those settings to a .prettierrc in this repo and then make sure all apollo projects run the same prettier setting?

This would expose the options so that editors like VSCode correctly auto format Apollo source-files for contributors.

This is an active problem for existing contributors, as VSCode's auto format will make formatting changes to package.json and other files regularly.

See: https://github.com/apollographql/apollo-client/pull/3042 for an example. While I had to disable auto-format in my latest changes to apollo-link-rest because it was changing the quote-type used in the file I was editing.

n1ru4l commented 6 years ago

Maybe something like https://github.com/kentcdodds/kcd-scripts (apollo-scripts) could help to keep those things for all the apollo projects in sync. Furthermore https://github.com/hexacta/prettier-check, which is used in the apollo-server repository, can guarantee that every file is actually prettified (for those who skip the githooks 😅), by checking code style on the ci level.