Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates out styleguide to include ES6 specific sections based on Embe… #8

Merged
merged 1 commit into from Sep 2, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
69 changes: 68 additions & 1 deletion README.md
Expand Up @@ -1113,7 +1113,7 @@
console.log(_this);
};
}

// bad
function() {
return function() {
Expand Down Expand Up @@ -1349,6 +1349,73 @@

**[⬆ back to top](#table-of-contents)**

## Rest Parameters

** Note: ** this section isn't part of the original AirBnB guide. It comes from [Ember's Styleguide](https://github.com/emberjs/ember.js/blob/master/STYLEGUIDE.md)

Since [Babel implements](https://babeljs.io/repl/#?experimental=true&playground=true&evaluate=true&loose=false&spec=false&code=function%20foo\(...args\)%20%7B%0A%20%20%0A%7D) Rest parameters in a non-leaking matter you should use them whenever applicable.

```javascript
function foo(...args) {
args.forEach((item) => {
console.log(item);
});
}
```
**[⬆ back to top](#table-of-contents)**


## Destructuring

** Note: ** this section isn't part of the original AirBnB guide. It comes from [Ember's Styleguide](https://github.com/emberjs/ember.js/blob/master/STYLEGUIDE.md)

When decomposing simple arrays or objects, prefer [destructuring](http://babeljs.io/docs/learn-es6/#destructuring).

```javascript
// array destructuring
var fullName = 'component:foo-bar';
var [
first,
last
] = fullName.split(':');
```

```javascript
// object destructuring
var person = {
firstName: 'Stefan',
lastName: 'Penner'
};

var {
firstName,
lastName
} = person;
```
**[⬆ back to top](#table-of-contents)**


## Comments

** Note: ** this section isn't part of the original AirBnB guide. It comes from [Ember's Styleguide](https://github.com/emberjs/ember.js/blob/master/STYLEGUIDE.md)

+ Use [YUIDoc](http://yui.github.io/yuidoc/syntax/index.html) comments for
documenting functions.
+ Use `//` for single line comments.

```javascript
function foo() {
var bar = 5;

// multiplies `bar` by 2.
fooBar(bar);

console.log(bar);
}
```
**[⬆ back to top](#table-of-contents)**


## jQuery

- Prefix jQuery object variables with a `$`.
Expand Down