mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
added rules about chained operations and indentation
This commit is contained in:
parent
6424334768
commit
3cc4a4d500
1 changed files with 37 additions and 0 deletions
|
@ -481,6 +481,43 @@ function isPercentage(val) {
|
|||
}
|
||||
```
|
||||
|
||||
## Chaining operations
|
||||
|
||||
When using a chaining syntax (jquery or promises, for example), do not indent the subsequent chained operations, unless there is a logical grouping in them.
|
||||
|
||||
Also, if the chain is long, each method should be on a new line.
|
||||
|
||||
*Right:*
|
||||
|
||||
```js
|
||||
$('.someClass')
|
||||
.addClass('another-class')
|
||||
.append(someElement)
|
||||
```
|
||||
|
||||
```js
|
||||
d3.selectAll('g.bar')
|
||||
.enter()
|
||||
.append('thing')
|
||||
.data(anything)
|
||||
.exit()
|
||||
.each(function() ... )
|
||||
```
|
||||
|
||||
*Wrong:*
|
||||
|
||||
```js
|
||||
$('.someClass')
|
||||
.addClass('another-class')
|
||||
.append(someElement)
|
||||
```
|
||||
|
||||
```js
|
||||
d3.selectAll('g.bar')
|
||||
.enter().append('thing').data(anything).exit()
|
||||
.each(function() ... )
|
||||
```
|
||||
|
||||
## Name your closures
|
||||
|
||||
Feel free to give your closures a descriptive name. It shows that you care about them, and
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue