mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 05:38:10 -05:00
[eslint-v2][whitespace] add newline-per-chained-call rule
This commit is contained in:
committed by
Jordan Harband
parent
fbd9c35dd3
commit
172dffbb52
@@ -387,6 +387,7 @@ Other Style Guides
|
||||
if (x > 2) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
```
|
||||
@@ -1664,8 +1665,8 @@ Other Style Guides
|
||||
})(this);↵
|
||||
```
|
||||
|
||||
- [18.6](#18.6) <a name='18.6'></a> Use indentation when making long method chains. Use a leading dot, which
|
||||
emphasizes that the line is a method call, not a new statement.
|
||||
- [18.6](#18.6) <a name='18.6'></a> Use indentation when making long method chains (more than 2 method chains). Use a leading dot, which
|
||||
emphasizes that the line is a method call, not a new statement. eslint: [newline-per-chained-call](http://eslint.org/docs/rules/newline-per-chained-call)
|
||||
|
||||
```javascript
|
||||
// bad
|
||||
@@ -1702,6 +1703,9 @@ Other Style Guides
|
||||
.append('svg:g')
|
||||
.attr('transform', 'translate(' + (radius + margin) + ',' + (radius + margin) + ')')
|
||||
.call(tron.led);
|
||||
|
||||
// good
|
||||
const leds = stage.selectAll('.led').data(data);
|
||||
```
|
||||
|
||||
- [18.7](#18.7) <a name='18.7'></a> Leave a blank line after blocks and before the next statement. jscs: [`requirePaddingNewLinesAfterBlocks`](http://jscs.info/rule/requirePaddingNewLinesAfterBlocks)
|
||||
|
||||
@@ -59,6 +59,9 @@ module.exports = {
|
||||
'new-parens': 0,
|
||||
// allow/disallow an empty newline after var statement
|
||||
'newline-after-var': 0,
|
||||
// enforces new line after each method call in the chain to make it more readable and easy to maintain
|
||||
// http://eslint.org/docs/rules/newline-per-chained-call
|
||||
'newline-per-chained-call': [2, { "ignoreChainWithDepth": 3 }],
|
||||
// disallow use of the Array constructor
|
||||
'no-array-constructor': 0,
|
||||
// disallow use of the continue statement
|
||||
|
||||
Reference in New Issue
Block a user