Skip to content

Commit 40773bc

Browse files
ljharbramasilveyra
authored andcommitted
[guide] fix “long lines” example to not include strings.
Fixes airbnb#1027.
1 parent 08821c8 commit 40773bc

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

README.md

+8-4
Original file line numberDiff line numberDiff line change
@@ -2142,20 +2142,24 @@ Other Style Guides
21422142
```
21432143

21442144
<a name="whitespace--max-len"></a><a name="18.12"></a>
2145-
- [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)
2145+
- [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)
21462146

21472147
> Why? This ensures readability and maintainability.
21482148

21492149
```javascript
21502150
// bad
2151-
const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. Whatever wizard constrains a helpful ally. The counterpart ascends!';
2151+
const foo = jsonData && jsonData.foo && jsonData.foo.bar && jsonData.foo.bar.baz && jsonData.foo.bar.baz.quux && jsonData.foo.bar.baz.quux.xyzzy;
21522152
21532153
// bad
21542154
$.ajax({ method: 'POST', url: 'https://auth0.com/', data: { name: 'John' } }).done(() => console.log('Congratulations!')).fail(() => console.log('You have failed this city.'));
21552155
21562156
// good
2157-
const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. ' +
2158-
'Whatever wizard constrains a helpful ally. The counterpart ascends!';
2157+
const foo = jsonData
2158+
&& jsonData.foo
2159+
&& jsonData.foo.bar
2160+
&& jsonData.foo.bar.baz
2161+
&& jsonData.foo.bar.baz.quux
2162+
&& jsonData.foo.bar.baz.quux.xyzzy;
21592163
21602164
// good
21612165
$.ajax({

0 commit comments

Comments
 (0)