Use js-beautify for formatting HTML #1089

Closed
nitrohorse wants to merge 21 commits from add-beautify into master
nitrohorse commented 2019-08-03 21:05:59 +00:00 (Migrated from github.com)

Description

Related: https://github.com/privacytoolsIO/privacytools.io/pull/900

This PR introduces "js-beautify" for auto-formatting the HTML code on code commits and git pushes based on specified rules in .jsbeautifyrc (here's a larger example). The rule I added for now includes using tabs over spaces. Overall, this tooling will increase style consistency and maintainability for contributors 😄

Example of trying to commit unformatted code:

husky-fail

Example of committing unformatted code and Travis failing the build:

travis-checks-fail

travis-fail

Alternatively, @dawidpotocki mentioned Prettier which could also do this job. I also have a working, local branch for that but felt Beautify to be more tailored and simpler for our needs at the moment. I also ran into some weird HTML formatting issues (such as https://github.com/prettier/prettier-vscode/issues/646) when using Prettier.

<!-- PLEASE READ OUR [CONTRIBUTING GUIDELINES](https://github.com/privacytoolsIO/privacytools.io/blob/master/.github/CONTRIBUTING.md) BEFORE SUBMITTING --> ## Description Related: https://github.com/privacytoolsIO/privacytools.io/pull/900 This PR introduces ["js-beautify"](https://github.com/beautify-web/js-beautify) for auto-formatting the HTML code on code commits and git pushes based on specified rules in `.jsbeautifyrc` ([here's a larger example](https://gist.github.com/wzup/fc3254562236c1ec3f69)). The rule I added for now includes using [tabs over spaces](https://old.reddit.com/r/javascript/comments/c8drjo/nobody_talks_about_the_real_reason_to_use_tabs/). Overall, this tooling will increase style consistency and maintainability for contributors :smile: Example of trying to commit unformatted code: ![husky-fail](https://user-images.githubusercontent.com/1514352/62419235-07cad500-b66b-11e9-9513-2fdfcb64a251.png) Example of committing unformatted code and Travis failing the build: ![travis-checks-fail](https://user-images.githubusercontent.com/1514352/62419060-7efe6a00-b667-11e9-9ae8-95d9691066c3.png) ![travis-fail](https://user-images.githubusercontent.com/1514352/62419062-83c31e00-b667-11e9-84fc-f8701d08e4ec.png) Alternatively, @dawidpotocki mentioned [Prettier](https://prettier.io/) which could also do this job. I also have a working, local branch for that but felt Beautify to be more tailored and simpler for our needs at the moment. I also ran into some weird HTML formatting issues (such as https://github.com/prettier/prettier-vscode/issues/646) when using Prettier.
netlify[bot] commented 2019-08-03 21:06:44 +00:00 (Migrated from github.com)

Deploy preview for privacytools-io ready!

Built with commit c9f9cf255b

https://deploy-preview-1089--privacytools-io.netlify.com

Deploy preview for *privacytools-io* ready! Built with commit c9f9cf255b02819b8d3bd80a829bab3519bcc1d6 https://deploy-preview-1089--privacytools-io.netlify.com
netlify[bot] commented 2019-08-03 21:06:44 +00:00 (Migrated from github.com)

Deploy preview for privacytools-io ready!

Built with commit c7937a241a

https://deploy-preview-1089--privacytools-io.netlify.com

Deploy preview for *privacytools-io* ready! Built with commit c7937a241a3be7695cafc996913cb08ad70eb16f https://deploy-preview-1089--privacytools-io.netlify.com
jonah reviewed 2019-08-03 21:33:18 +00:00
jonah left a comment

Okay

Okay
jonah reviewed 2019-08-03 21:43:47 +00:00
jonah left a comment

Still okay

Still okay
jonah requested changes 2019-08-03 22:41:49 +00:00
@ -2,3 +2,3 @@
<div class="alert alert-success" role="alert">
<strong>All providers listed here are operating outside the US and support <a data-toggle="tooltip" data-placement="bottom" data-original-title="When sending or receiving emails, if both the sending and receiving servers support TLS encryption, the email is sent between servers using an encrypted connection.">SMTP TLS.</a> The table is sortable.</strong>
<strong>All providers listed here are operating outside the US and support <a data-toggle="tooltip" data-placement="bottom" data-original-title="When sending or receiving emails, if both the sending and receiving servers support TLS encryption, the email is sent between servers using an encrypted connection.">SMTP TLS.</a> The table is sortable.</strong>

This doesn't seem right

This doesn't seem right
nitrohorse (Migrated from github.com) reviewed 2019-08-03 22:51:37 +00:00
@ -2,3 +2,3 @@
<div class="alert alert-success" role="alert">
<strong>All providers listed here are operating outside the US and support <a data-toggle="tooltip" data-placement="bottom" data-original-title="When sending or receiving emails, if both the sending and receiving servers support TLS encryption, the email is sent between servers using an encrypted connection.">SMTP TLS.</a> The table is sortable.</strong>
<strong>All providers listed here are operating outside the US and support <a data-toggle="tooltip" data-placement="bottom" data-original-title="When sending or receiving emails, if both the sending and receiving servers support TLS encryption, the email is sent between servers using an encrypted connection.">SMTP TLS.</a> The table is sortable.</strong>
nitrohorse (Migrated from github.com) commented 2019-08-03 22:51:37 +00:00

Good catch! Fixed.

Good catch! Fixed.
nitrohorse (Migrated from github.com) reviewed 2019-08-03 22:52:13 +00:00
nitrohorse (Migrated from github.com) commented 2019-08-03 22:52:13 +00:00

What... hmm

What... hmm
nitrohorse (Migrated from github.com) reviewed 2019-08-03 22:58:52 +00:00
nitrohorse (Migrated from github.com) commented 2019-08-03 22:58:52 +00:00

Okay, fixed.

Okay, fixed.
jonah reviewed 2019-08-03 23:06:08 +00:00
jonah reviewed 2019-08-03 23:14:50 +00:00
Mikaela commented 2019-08-09 21:44:51 +00:00 (Migrated from github.com)

This looks scarily big to me, but there are conflicting files so I won't read deeper right now.

This looks scarily big to me, but there are conflicting files so I won't read deeper right now.
nitrohorse commented 2019-08-11 20:01:34 +00:00 (Migrated from github.com)

This looks scarily big to me, but there are conflicting files so I won't read deeper right now.

Yeah, I'm unsure what direction we want to take with this at the moment. It should be fairly straightforward to get auto-formatting tooling integrated, but for the proposed solutions (Prettier and JS-Beautify) both will introduce NodeJS to the project which will add some complexity and increase maintainability a bit (making sure packages are up-to-date)...

> This looks scarily big to me, but there are conflicting files so I won't read deeper right now. Yeah, I'm unsure what direction we want to take with this at the moment. It should be fairly straightforward to get auto-formatting tooling integrated, but for the proposed solutions (Prettier and JS-Beautify) both will introduce NodeJS to the project which will add some complexity and increase maintainability a bit (making sure packages are up-to-date)...
nitrohorse commented 2019-08-21 03:06:56 +00:00 (Migrated from github.com)

Going to close this until the right formatter tool is decided 👍

Going to close this until the right formatter tool is decided :+1:
This repo is archived. You cannot comment on pull requests.
No reviewers
No Milestone
No Assignees
1 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: privacyguides/privacytools.io#1089
No description provided.