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

Declare leading-commas to be consistent in style. #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 60 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1189,10 +1189,10 @@ function onThingHappended(cb){

// good
var hero = {
firstName: 'Bob'
, lastName: 'Parr'
, heroName: 'Mr. Incredible'
, superPower: 'strength'
firstName: 'Bob'
, lastName: 'Parr'
, heroName: 'Mr. Incredible'
, superPower: 'strength'
}
```

Expand All @@ -1204,28 +1204,78 @@ function onThingHappended(cb){
// bad
var hero = {
firstName: 'Kevin'
, lastName: 'Flynn'
,
, lastName: 'Flynn'
,
}

var heroes = [
'Batman'
, 'Superman'
,
, 'Superman'
,
]

// good
var hero = {
firstName: 'Kevin'
, lastName: 'Flynn'
, lastName: 'Flynn'
}

var heroes = [
'Batman'
, 'Superman'
, 'Superman'
]
```


- Finally, commas should be aligned to be flush with the scope/declaration they exist under. This avoids using unecesarry whitespace/line-width bloating, as well as avoids the appearance of nesting where such is not the case. Think of it like a bullet-point list.

```javascript
// bad
var hero = {
firstName: 'Bob'
, lastName: 'Parr'
, heroName: 'Mr. Incredible'
, superPower: 'strength'
}

hero.extend({
mask: true
, cape: {
color: 'red'
, length: 'medium'
}
, hairstyle: 'pompadour'
})

// good
var hero = {
firstName: 'Bob'
, lastName: 'Parr'
, heroName: 'Mr. Incredible'
, superPower: 'strength'
}

hero.extend({
mask: true
, cape: {
color: 'red'
, length: 'medium'
}
, hairstyle: 'pompadour'
})

//acceptable
var hero = {
firstName: 'Bob'
, lastName: 'Parr'
, heroName: 'Mr. Incredible'
, superPower: 'strength'
}

var mecha
, lecha
, hiney
```


### Semicolons
Expand Down