Skip to content

Instantly share code, notes, and snippets.

@martindale
Created January 22, 2014 20:56
Show Gist options
  • Save martindale/8567204 to your computer and use it in GitHub Desktop.
Save martindale/8567204 to your computer and use it in GitHub Desktop.
example CONTRIBUTING.md

Contributing to this Project

Here's how you can help.

Process

In the spirit of openness, this project follows the Forking Flow, a derivative of the Gitflow model. We use Pull Requests to develop conversations around ideas, and turn ideas into actions.

Some PR Basics

  • Anyone can submit a Pull Request with changes they'd like to see made.
  • Pull Requests should attempt to solve a single [1], clearly defined problem [2].
  • Everyone should submit Pull Requests early (within the first few commits), so everyone on the team is aware of the direction you're taking.
  • Authors are responsible for explicitly tagging anyone who might be impacted by the pull request and get the recipient's sign-off [3].
  • The Pull Request should serve as the authority on the status of a change, so everyone on the team is aware of the plan of action.
  • Relevant domain authority must sign-off on a pull request before it is merged [4].
  • Anyone except the author can merge a pull request once all sign-offs are complete.

[1]: if there are multiple problems you're solving, it is recommended that you create a branch for each. For example, if you are implementing a small change and realize you want to refactor an entire function, you might want to implement the refactor as your first branch (and pull request), then create a new branch (and pull request) from the refactor to implement your new feature. This helps resolve merge conflicts and separates out the logical components of the decision-making process.
[2]: include a description of the problem that is being resolved in the description field, or a reference to the issue number where the problem is reported. Examples include; "Follow Button doesn't Reflect State of Follow" or "Copy on Front-page is Converting Poorly".
[3]: notably, document the outcome of any out-of-band conversations in the pull request.
[4]: changes to marketing copy, for example, must be approved by the authority on marketing.

Coding Conventions

Detail and examples below; here are the basic principles.

tl;dr

  • 2 spaces, no tabs.
  • elide (remove) any trailing whitespace, except for formatting purposes in Jade.
  • use leading comma syntax for long lists (> 3).
  • vertically align logically similar items.
  • curly brace on the same line as the statement.
  • always use semicolons and braces; even though they're [sometimes] optional, focus on clarity.

Examples

Trailing Whitespace

You should remove whitespace at the end of lines. For example; Trailing Whitespace: Bad

...should be reduced to: Trailing Whitespace: Good

The only exception is in Jade, when a single space character is inserted into the HTML document using the | prefix. Trailing Whitespace: Exception

This allows, among other things, the enduser to copy-paste blocks of text that might include various types of elements without breaking formatting.

Leading Comma

To increase readability and reduce errors, we use the leading comma syntax when lists grow longer than 3 items in length.

This list of directives has the comma at the end of each line: Leading Comma: Bad

...but should be reformatted to: Leading Comma: Good

Curly Braces

Put your curly braces on the same line as the logical statement that requires them: Curly Braces: Bad

...should be: Curly Braces: Good

Always include curly braces, even though Javascript has some cases where you can exclude them: Curly Braces Include: Bad ...should be: Curly Braces Include: Good

For brevity in cases like this, you can reduce it to a single line, but keep your curly braces: Curly Braces: Good

Vertical Alignment

Logically similar blocks should be made visually pleasing where possible.

For example, without inserting any spaces to vertically align blocks: Vertical Alignment: Bad

...is much more readible when presented as follows: Vertical Alignment: Good

For a more in-depth guide to NodeJS conventions, you can use Felix's Node Styleguide.

@maraoz
Copy link

maraoz commented Mar 26, 2014

Awesome, will fork and edit for bitcore :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment