Coding Style
General Guidelines
These are guidelines to help us read, edit and share code with ease.
- Always use four-space indents. Many code editors allow you to set tabs as spaces.
- Comment liberally.
- Use semantic HTML5 markup. Do not use generic
<div>
or<span>
tags when there are more appropriate tags. - Always place paragraphs of text in
<p>
tags. Never use multiple<br>
tags. - Use double quotes around element attribute values. Make exceptions only in cases of data attributes.
- Use an ID on a page only once, e.g., the page ID.
Resources: Google HTML/CSS Style Guide, GitHub Styleguide
Accessibility
<a>
tags should always includetitle
attributes.<img>
tags should always includealt
attributes.- See Form Elements section for form accessibilty guidelines.
Git Best Practices
Create a new branch off master when you start a new feature. Sync with master first. Push it immediately to GitHub for others to track.
Give your new branch a short but meaningful name, using spaces or dots to separate words, e.g.
my.cool.feature
Do not push commits to someone else's branch without permission.
Commit and push code as often as possible. Share your progress and make it possible for others to collaborate. Do not keep changes local.
Make sure your branch stays current. Merge master to your branch at least once a day. Avoid painful conflict resolutions and last-minute bugs that stem from incompatible features.
Make sure other branches stay current with your branch. Delete obsolete branches and push changes to dependent branches. Never force push to master.
If you make changes on a released branch, merge the changes not only into the number branch but also into all subsequent number branches, all the way to master.
Review and double-check your own pull requests.
Go to the "Files" tab in the pull request to see the diffs.
Commit Message Format
[Ticket/Issue ID] - Short summary of changes If necessary, add a detailed explanation here after entering a blank line. The blank line separating the commit description from the commit message is important. Add more paragraphs with blank lines between paragraphs. - You can use bullet points. - Use hyphens or asterisks to start a bullet point.