Add section 18.12 on line length

This commit is contained in:
Christopher Banh
2015-12-23 17:13:55 -08:00
parent fbf81eba3a
commit b7fbc7b6df

View File

@@ -1692,6 +1692,31 @@ Other Style Guides
// good
const foo = { clark: 'kent' };
```
- [18.12](#18.12) <a name='18.12'></a> Avoid having lines of code that are longer than 100 characters (including whitespace).
> Why? This ensures readability and maintainability.
eslint rules: [`max-len`](http://eslint.org/docs/rules/max-len.html).
```javascript
// bad
const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. Whatever wizard constrains a helpful ally. The counterpart ascends!';
// bad
$.ajax({ method: 'POST', url: 'https://airbnb.com/', data: { name: 'John' } }).done(() => console.log('Congratulations!')).fail(() => console.log('You have failed this city.'));
// good
const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. ' +
'Whatever wizard constrains a helpful ally. The counterpart ascends!';
// good
$.ajax({
method: 'POST',
url: 'https://airbnb.com/',
data: { name: 'John' },
})
.done(() => console.log('Congratulations!'))
.fail(() => console.log('You have failed this city.'));
```
**[⬆ back to top](#table-of-contents)**