Commit 39a16fa4 authored by Sindre Sorhus's avatar Sindre Sorhus

Tweak formatting in codestyle.md

parent a7278feb
# Code Style # Code Style
We think it's best for the project if the code you write looks like the code the last developer wrote. Please read this document in its entirety, and be sure to refer back to it throughout the development of your contribution. We greatly appreciate your cooperation. We think it's best for the project if the code you write looks like the code the last developer wrote. Please read this document in its entirety, and be sure to refer back to it throughout the development of your contribution. We greatly appreciate your cooperation.
## General Rules ## General Rules
- Tab indentation - Tab indentation
- Single-quotes - Single-quotes
- Semicolon - Semicolon
...@@ -20,26 +23,28 @@ Example: ...@@ -20,26 +23,28 @@ Example:
'use strict'; 'use strict';
function foo(bar, fum) { function foo(bar, fum) {
var i, l, ret; var i, l, ret;
var hello = 'Hello'; var hello = 'Hello';
if (!bar) { if (!bar) {
return; return;
} }
for (i = 0, l = bar.length; i < l; i++) { for (i = 0, l = bar.length; i < l; i++) {
if (bar[i] === hello) { if (bar[i] === hello) {
ret += fum(bar[i]); ret += fum(bar[i]);
} }
} }
return ret; return ret;
} }
``` ```
Read [idiomatic.js](https://github.com/rwldrn/idiomatic.js) for general JavaScript code style best practices. Read [idiomatic.js](https://github.com/rwldrn/idiomatic.js) for general JavaScript code style best practices.
## Anonymous Functions ## Anonymous Functions
When using anonymous functions, leave a space between the function name and opening parenthesis. When using anonymous functions, leave a space between the function name and opening parenthesis.
Example: Example:
...@@ -52,7 +57,9 @@ Example: ...@@ -52,7 +57,9 @@ Example:
}) })
``` ```
## Comments ## Comments
Inline comments are a great way of giving new users a better understanding of what you're doing and why. Inline comments are a great way of giving new users a better understanding of what you're doing and why.
It's also helpful to let your functions breathe, by leaving additional lines between statements. It's also helpful to let your functions breathe, by leaving additional lines between statements.
...@@ -81,6 +88,7 @@ var removeTodo = function (todoItem) { ...@@ -81,6 +88,7 @@ var removeTodo = function (todoItem) {
``` ```
## RequireJS ## RequireJS
When using RequireJS, please format your code to these specifications: When using RequireJS, please format your code to these specifications:
```js ```js
...@@ -95,6 +103,7 @@ define('Block', [ ...@@ -95,6 +103,7 @@ define('Block', [
``` ```
## JSHint ## JSHint
When you submit your pull request, one of the first things we will do is run JSHint against your code. When you submit your pull request, one of the first things we will do is run JSHint against your code.
You can help speed the process by running it yourself: You can help speed the process by running it yourself:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment