Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Update common function body comment
Browse files Browse the repository at this point in the history
- This commit provides a canonical way of describing
  that the function body contains code of some sort.
- The convention chosen was '// ...'.
- This change is persisted throughout the readme file
  where appropriate
  • Loading branch information
oshalygin committed Jan 11, 2017
1 parent 73e27ef commit 712e010
Showing 1 changed file with 51 additions and 22 deletions.
73 changes: 51 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,14 +581,17 @@ Other Style Guides
```javascript
// bad
const foo = function () {
// ...
};

// bad
function foo() {
// ...
}

// good
const foo = function bar() {
// ...
};
```
Expand Down Expand Up @@ -632,13 +635,13 @@ Other Style Guides
```javascript
// bad
function nope(name, options, arguments) {
// ...stuff...
function foo(name, options, arguments) {
// ...
}

// good
function yup(name, options, args) {
// ...stuff...
function foo(name, options, args) {
// ...
}
```
Expand Down Expand Up @@ -774,18 +777,22 @@ Other Style Guides
// bad
function f1(a) {
a = 1;
// ...
}
function f2(a) {
if (!a) { a = 1; }
// ...
}
// good
function f3(a) {
const b = a || 1;
// ...
}
function f4(a = 1) {
// ...
}
```

Expand Down Expand Up @@ -818,7 +825,7 @@ Other Style Guides
function foo(bar,
baz,
quux) {
// body
// ...
}
// good
Expand All @@ -827,7 +834,7 @@ Other Style Guides
baz,
quux,
) {
// body
// ...
}
// bad
Expand Down Expand Up @@ -1347,39 +1354,56 @@ Other Style Guides
```js
// bad
function * foo() {
// ...
}
// bad
const bar = function * () {
// ...
}
// bad
const baz = function *() {
// ...
}
// bad
const quux = function*() {
// ...
}
// bad
function*foo() {
// ...
}
// bad
function *foo() {
// ...
}
// very bad
function
*
foo() {
// ...
}
// very bad
const wat = function
*
() {
// ...
}
// good
function* foo() {
// ...
}
// good
const foo = function* () {
// ...
}
```
Expand Down Expand Up @@ -1721,32 +1745,32 @@ Other Style Guides
```javascript
// bad
if (isValid === true) {
// ...stuff...
// ...
}

// good
if (isValid) {
// ...stuff...
// ...
}

// bad
if (name) {
// ...stuff...
// ...
}

// good
if (name !== '') {
// ...stuff...
// ...
}

// bad
if (collection.length) {
// ...stuff...
// ...
}

// good
if (collection.length > 0) {
// ...stuff...
// ...
}
```
Expand All @@ -1770,7 +1794,9 @@ Other Style Guides
const y = 2;
break;
case 3:
function f() {}
function f() {
// ...
}
break;
default:
class C {}
Expand All @@ -1787,7 +1813,9 @@ Other Style Guides
break;
}
case 3: {
function f() {}
function f() {
// ...
}
break;
}
case 4:
Expand Down Expand Up @@ -1910,7 +1938,7 @@ Other Style Guides
// @return {Element} element
function make(tag) {
// ...stuff...
// ...
return element;
}
Expand All @@ -1922,7 +1950,7 @@ Other Style Guides
*/
function make(tag) {
// ...stuff...
// ...
return element;
}
Expand Down Expand Up @@ -1985,7 +2013,7 @@ Other Style Guides
*/
function make(tag) {
// ...stuff...
// ...
return element;
}
Expand All @@ -1997,7 +2025,7 @@ Other Style Guides
*/
function make(tag) {
// ...stuff...
// ...
return element;
}
Expand Down Expand Up @@ -2624,12 +2652,12 @@ Other Style Guides
```javascript
// bad
function q() {
// ...stuff...
// ...
}

// good
function query() {
// ..stuff..
// ...
}
```
Expand Down Expand Up @@ -2756,6 +2784,7 @@ Other Style Guides
```javascript
function makeStyleGuide() {
// ...
}

export default makeStyleGuide;
Expand Down Expand Up @@ -2933,7 +2962,7 @@ Other Style Guides
function setSidebar() {
$('.sidebar').hide();

// ...stuff...
// ...

$('.sidebar').css({
'background-color': 'pink'
Expand All @@ -2945,7 +2974,7 @@ Other Style Guides
const $sidebar = $('.sidebar');
$sidebar.hide();

// ...stuff...
// ...

$sidebar.css({
'background-color': 'pink'
Expand Down

0 comments on commit 712e010

Please sign in to comment.