-
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code Formatter: Prettier #14
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
A code formatter is a essential part of a project setup to ensure a good and consistent code style without requiring relatively time-consuming manual corrections found by a code linter. With code being automatically formatted on actions like saving a file the developer can focus entirely on the code instead of spending time and energy on indenting code line by line. That's where one special project comes in: Prettier [1], the opinionated code formatter with support for almost any language and integration with almost every popular editor. I've been using it since the first version and I totally forgot about the fact that formatting is even a thing. That could also be because Gophers [2] are already used to `gofmt` [3] anyway. Prettier is a absolute must-have for every project setup and I'm not aware of any other projects with such advanced parsers and language support. The only negative point is that it is written in JavaScript instead of Go [4] so it always pulls in NodeJS [5] as a development dependency. This is not a problem at all for web-based projects, but for Go or any other non-NodeJS project it inflates the setup unnecessarily. Anyway, the fantastic developer experience and project benefits clearly outweigh the negative points. In addition many developers today already have Node installed locally since it's large ecosystem has already spread by far further than just the web but already powers many system, desktop and CLI applications. >>> Configuration This is one of the main features of Prettier: It already provides the best and recommended style configurations of-out-the-box. The only option that has been changed is the print width [6]. It is set to `80` by default which is not up-to-date for modern screens (might only be relevant when working in terminals only like e.g. with Vim). It has been changed to `120` like defined in all of my style guides [7]. The `prettier.config.js` configuration file is placed in the project root as well as the `.prettierignore` file to also define ignore pattern. >>> Package Script To allow to format all sources a `format:pretty` package script has been added that also runs in the main `format` script flow. The new `lint:pretty` script also allows to check if all supported files are formatted correctly. It is included in the main `lint` script flow. [1]: https://prettier.io [2]: https://blog.golang.org/gopher [3]: https://golang.org/cmd/gofmt [4]: https://go.dev [5]: https://nodejs.org [6]: https://prettier.io/docs/en/options.html#print-width [7]: https://github.com/arcticicestudio?tab=repositories&q=styleguide GH-13
svengreb
added a commit
that referenced
this pull request
Aug 22, 2020
A code formatter is a essential part of a project setup to ensure a good and consistent code style without requiring relatively time-consuming manual corrections found by a code linter. With code being automatically formatted on actions like saving a file the developer can focus entirely on the code instead of spending time and energy on indenting code line by line. That's where one special project comes in: Prettier [1], the opinionated code formatter with support for almost any language and integration with almost every popular editor. I've been using it since the first version and I totally forgot about the fact that formatting is even a thing. That could also be because Gophers [2] are already used to `gofmt` [3] anyway. Prettier is a absolute must-have for every project setup and I'm not aware of any other projects with such advanced parsers and language support. The only negative point is that it is written in JavaScript instead of Go [4] so it always pulls in NodeJS [5] as a development dependency. This is not a problem at all for web-based projects, but for Go or any other non-NodeJS project it inflates the setup unnecessarily. Anyway, the fantastic developer experience and project benefits clearly outweigh the negative points. In addition many developers today already have Node installed locally since it's large ecosystem has already spread by far further than just the web but already powers many system, desktop and CLI applications. >>> Configuration This is one of the main features of Prettier: It already provides the best and recommended style configurations of-out-the-box. The only option that has been changed is the print width [6]. It is set to `80` by default which is not up-to-date for modern screens (might only be relevant when working in terminals only like e.g. with Vim). It has been changed to `120` like defined in all of my style guides [7]. The `prettier.config.js` configuration file is placed in the project root as well as the `.prettierignore` file to also define ignore pattern. >>> Package Script To allow to format all sources a `format:pretty` package script has been added that also runs in the main `format` script flow. The new `lint:pretty` script also allows to check if all supported files are formatted correctly. It is included in the main `lint` script flow. [1]: https://prettier.io [2]: https://blog.golang.org/gopher [3]: https://golang.org/cmd/gofmt [4]: https://go.dev [5]: https://nodejs.org [6]: https://prettier.io/docs/en/options.html#print-width [7]: https://github.com/arcticicestudio?tab=repositories&q=styleguide Closes GH-13
svengreb
added a commit
that referenced
this pull request
Aug 22, 2020
A code formatter is a essential part of a project setup to ensure a good and consistent code style without requiring relatively time-consuming manual corrections found by a code linter. With code being automatically formatted on actions like saving a file the developer can focus entirely on the code instead of spending time and energy on indenting code line by line. That's where one special project comes in: Prettier [1], the opinionated code formatter with support for almost any language and integration with almost every popular editor. I've been using it since the first version and I totally forgot about the fact that formatting is even a thing. That could also be because Gophers [2] are already used to `gofmt` [3] anyway. Prettier is a absolute must-have for every project setup and I'm not aware of any other projects with such advanced parsers and language support. The only negative point is that it is written in JavaScript instead of Go [4] so it always pulls in NodeJS [5] as a development dependency. This is not a problem at all for web-based projects, but for Go or any other non-NodeJS project it inflates the setup unnecessarily. Anyway, the fantastic developer experience and project benefits clearly outweigh the negative points. In addition many developers today already have Node installed locally since it's large ecosystem has already spread by far further than just the web but already powers many system, desktop and CLI applications. >>> Configuration This is one of the main features of Prettier: It already provides the best and recommended style configurations of-out-the-box. The only option that has been changed is the print width [6]. It is set to `80` by default which is not up-to-date for modern screens (might only be relevant when working in terminals only like e.g. with Vim). It has been changed to `120` like defined in all of my style guides [7]. The `prettier.config.js` configuration file is placed in the project root as well as the `.prettierignore` file to also define ignore pattern. >>> Package Script To allow to format all sources a `format:pretty` package script has been added that also runs in the main `format` script flow. The new `lint:pretty` script also allows to check if all supported files are formatted correctly. It is included in the main `lint` script flow. [1]: https://prettier.io [2]: https://blog.golang.org/gopher [3]: https://golang.org/cmd/gofmt [4]: https://go.dev [5]: https://nodejs.org [6]: https://prettier.io/docs/en/options.html#print-width [7]: https://github.com/arcticicestudio?tab=repositories&q=styleguide Closes GH-13
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #13