Archived
💬 Discussion | Use code formatter #1093
Open
opened 2019-08-04 04:23:39 +00:00 by dawidpotocki
·
4 comments
No Branch/Tag Specified
master
dependabot/bundler/nokogiri-1.13.6
dependabot/bundler/addressable-2.8.0
freddy-m-patch-3
pr-add_RemoveMyPhone_sponsor
pr-browser_cleanup_1257_1328_1430
freddy-m-patch-2
freddy-m-patch-1
pr-vpn_hated_one_video
cdn
update-nitrohorse-image
promote-metager-to-card
hardware
pr-add_azirevpn
pr-add_mailfence
shop
1673
pr/1658
i18n-simple
sponsorship-edits-nov2019
i18n
ipfs
blacklight447-ptio-patch-3
blog
remove-windows-icons
pr/1147
i18n-testing
add-beautify
No results found.
Labels
Clear labels
:mag:🤖 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
approved, waiting for a PR
Pull requests that update a dependency file
The Invisible Internet Project (I2P)
Operating Systems
A label for stalebot if it gets added
Anything related to media streaming.
Anything covering the Tor network
active work in progress, do not merge or PR (yet)!
Issues or bugs that will not be fixed and/or do not have significant impact on the project.
Extensible Messaging and Presence Protocol
Matrix protocol
Browser Extension related issues
Correction of content on the website
Firefox & forks, about:config etc.
Anything primarily related to site cleanup.
Virtual Private Network
*Technical* issues with the website.
Domain Name System
Anything covering a translated version of the site
No labels
🏠 housekeeping
Milestone
No items
No Milestone
No due date set.
Dependencies
No dependencies set.
Reference: privacyguides/privacytools.io#1093
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Related: https://github.com/privacytoolsIO/privacytools.io/pull/1089
Problem
There are many inconsistencies and code is hard to read.
_includes/sections/vpn.htmluses 2 spaces for indentation_includes/panel.htmluses 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
.editorconfigfile, 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.
prettierseems 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.editorconfigconfigured to this.Regards,
Gusted