mirror of
https://github.com/airbnb/javascript.git
synced 2026-01-14 05:38:10 -05:00
Add section 18.12 on line length
This commit is contained in:
25
README.md
25
README.md
@@ -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)**
|
||||
|
||||
|
||||
Reference in New Issue
Block a user