Skip to content

Commit 8e8a9ae

Browse files
ljharbjaylaw81
authored andcommitted
[guide] fix “long lines” example to not include strings.
Fixes airbnb#1027.
1 parent 0767e02 commit 8e8a9ae

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

README.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2149,20 +2149,24 @@ Other Style Guides
21492149
```
21502150

21512151
<a name="whitespace--max-len"></a><a name="18.12"></a>
2152-
- [18.12](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). eslint: [`max-len`](http://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength)
2152+
- [18.12](#whitespace--max-len) Avoid having lines of code that are longer than 100 characters (including whitespace). Note: per [above](#strings--line-length), long strings are exempt from this rule, and should not be broken up. eslint: [`max-len`](http://eslint.org/docs/rules/max-len.html) jscs: [`maximumLineLength`](http://jscs.info/rule/maximumLineLength)
21532153

21542154
> Why? This ensures readability and maintainability.
21552155

21562156
```javascript
21572157
// bad
2158-
const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. Whatever wizard constrains a helpful ally. The counterpart ascends!';
2158+
const foo = jsonData && jsonData.foo && jsonData.foo.bar && jsonData.foo.bar.baz && jsonData.foo.bar.baz.quux && jsonData.foo.bar.baz.quux.xyzzy;
21592159
21602160
// bad
21612161
$.ajax({ method: 'POST', url: 'https://airbnb.com/', data: { name: 'John' } }).done(() => console.log('Congratulations!')).fail(() => console.log('You have failed this city.'));
21622162
21632163
// good
2164-
const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. ' +
2165-
'Whatever wizard constrains a helpful ally. The counterpart ascends!';
2164+
const foo = jsonData
2165+
&& jsonData.foo
2166+
&& jsonData.foo.bar
2167+
&& jsonData.foo.bar.baz
2168+
&& jsonData.foo.bar.baz.quux
2169+
&& jsonData.foo.bar.baz.quux.xyzzy;
21662170
21672171
// good
21682172
$.ajax({

0 commit comments

Comments
 (0)