💬 Discussion | Use code formatter #1093
Labels
No Label
🔍🤖 Search Engines
approved
dependencies
duplicate
feedback wanted
high priority
I2P
iOS
low priority
OS
Self-contained networks
Social media
stale
streaming
todo
Tor
WIP
wontfix
XMPP
[m]
₿ cryptocurrency
ℹ️ help wanted
↔️ file sharing
⚙️ web extensions
✨ enhancement
❌ software removal
💬 discussion
🤖 Android
🐛 bug
💢 conflicting
📝 correction
🆘 critical
📧 email
🔒 file encryption
📁 file storage
🦊 Firefox
💻 hardware
🌐 hosting
🏠 housekeeping
🔐 password managers
🧰 productivity tools
🔎 research required
🌐 Social News Aggregators
🆕 software suggestion
👥 team chat
🔒 VPN
🌐 website issue
🚫 Windows
👁️ browsers
🖊️ digital notebooks
🗄️ DNS
🗨️ instant messaging (im)
🇦🇶 translations
No Milestone
No Assignees
1 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: privacyguides/privacytools.io#1093
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
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?
Related: https://github.com/privacytoolsIO/privacytools.io/pull/1089
Problem
There are many inconsistencies and code is hard to read.
_includes/sections/vpn.html
uses 2 spaces for indentation_includes/panel.html
uses 4 spaces for indentationin some places we can see 3 spaces used by mistake
Many <> HTML tags are used next to each other, instead of under.
instead of
or this
Problem with giving everything on one line is readability. There is a reason why books don't have enormous pages. It is easier and faster to not move eyes so much. Also on smaller screens it is hard to read it, as either we get a scrollbar or it overflows to next line.
Solution
Using code formatter. It would make code more readable, consistent and easier to maintain. Formatting could be check by Travis, so code would always be formatted properly.
prettier
It is formatter for HTML/JavaScript/CSS/YAML/Markdown, can be used in CLI and integrated with many of popular editors (Vim, Emacs, VS Code, Web Storm, Sublime Text…)
js-beautify
It is formatter for HTML/JavaScript/CSS. Can also be used in CLI and integrated with code editors, but there are less plugins for them and seem to be worse quality than prettier's.
Also related is https://github.com/privacytoolsIO/privacytools.io/pull/900.
https://github.com/privacytoolsIO/privacytools.io/pull/1089 is now a working MR with pre-commit and Travis integration working 👍 Will do some testing with Prettier to see if I can configure it properly for this repo too. Then we could compare.
The repository could also have a
.editorconfig
file, which would help everyone to use the same coding style.EditorConfig
I would support this as its hard to know what the "standard" should be.
Just want to add my 2 cents into this discussion.
Everyone has their own personal preference for their indents and tabs etc.
Therefore standards where created e.g. Google Airbnb standard/standard.
Everyone has their own reasons for why x has to be y, so why not follow some basic principles.
Linux coding-style has good principles for why x has to be y.
Let's take for example the indents.
If you take this principle you can throw 2 indents over board and choose for 4 or 8. Ultimately following this principle, however that introduce another problem.
Well, I disagree with the last sentence as we are mainly speaking about HTML that can have short tags or tags with attributes and can have easily more than 3 levels indentation. Following those 2 simple understandable principles a 4 indent is a good and reasonable choice.
As for the tool using, with considering the main language of this repo is html.
prettier
seems to have a better fit for this and can be customized with config(.prettierrc
), which most IDE's automatically will use and don't need an.editorconfig
configured to this.Regards,
Gusted