Skip to content

Commit

Permalink
Tweak formatting in codestyle.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Aug 6, 2013
1 parent a7278fe commit 39a16fa
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions codestyle.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# 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.


## General Rules

- Tab indentation
- Single-quotes
- Semicolon
Expand All @@ -20,26 +23,28 @@ Example:
'use strict';

function foo(bar, fum) {
var i, l, ret;
var hello = 'Hello';
var i, l, ret;
var hello = 'Hello';

if (!bar) {
return;
}
if (!bar) {
return;
}

for (i = 0, l = bar.length; i < l; i++) {
if (bar[i] === hello) {
ret += fum(bar[i]);
}
}
for (i = 0, l = bar.length; i < l; i++) {
if (bar[i] === hello) {
ret += fum(bar[i]);
}
}

return ret;
return ret;
}
```

Read [idiomatic.js](https://github.com/rwldrn/idiomatic.js) for general JavaScript code style best practices.


## Anonymous Functions

When using anonymous functions, leave a space between the function name and opening parenthesis.

Example:
Expand All @@ -52,7 +57,9 @@ Example:
})
```


## Comments

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.
Expand Down Expand Up @@ -81,6 +88,7 @@ var removeTodo = function (todoItem) {
```

## RequireJS

When using RequireJS, please format your code to these specifications:

```js
Expand All @@ -95,6 +103,7 @@ define('Block', [
```

## JSHint

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:
Expand Down

0 comments on commit 39a16fa

Please sign in to comment.