Skip to content

Commit 6d00939

Browse files
committed
Merge pull request airbnb#639 from chrisngobanh/max-len
[eslint config] [breaking] Define a max line length of 100 characters
2 parents fbf81eb + e2e4724 commit 6d00939

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

README.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ Other Style Guides
421421
const name = 'Capt. Janeway';
422422
```
423423
424-
- [6.2](#6.2) <a name='6.2'></a> Strings longer than 100 characters should be written across multiple lines using string concatenation.
424+
- [6.2](#6.2) <a name='6.2'></a> Strings that cause the line to go over 100 characters should be written across multiple lines using string concatenation.
425425
- [6.3](#6.3) <a name='6.3'></a> Note: If overused, long strings with concatenation could impact performance. [jsPerf](http://jsperf.com/ya-string-concat) & [Discussion](https://github.com/airbnb/javascript/issues/40).
426426
427427
```javascript
@@ -1692,6 +1692,31 @@ Other Style Guides
16921692
// good
16931693
const foo = { clark: 'kent' };
16941694
```
1695+
- [18.12](#18.12) <a name='18.12'></a> Avoid having lines of code that are longer than 100 characters (including whitespace).
1696+
> Why? This ensures readability and maintainability.
1697+
1698+
eslint rules: [`max-len`](http://eslint.org/docs/rules/max-len.html).
1699+
1700+
```javascript
1701+
// bad
1702+
const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. Whatever wizard constrains a helpful ally. The counterpart ascends!';
1703+
1704+
// bad
1705+
$.ajax({ method: 'POST', url: 'https://airbnb.com/', data: { name: 'John' } }).done(() => console.log('Congratulations!')).fail(() => console.log('You have failed this city.'));
1706+
1707+
// good
1708+
const foo = 'Whatever national crop flips the window. The cartoon reverts within the screw. ' +
1709+
'Whatever wizard constrains a helpful ally. The counterpart ascends!';
1710+
1711+
// good
1712+
$.ajax({
1713+
method: 'POST',
1714+
url: 'https://airbnb.com/',
1715+
data: { name: 'John' },
1716+
})
1717+
.done(() => console.log('Congratulations!'))
1718+
.fail(() => console.log('You have failed this city.'));
1719+
```
16951720

16961721
**[⬆ back to top](#table-of-contents)**
16971722

linters/.jshintrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
// Prohibit use of a variable before it is defined.
3535
"latedef": true,
3636

37-
// Enforce line length to 80 characters
38-
"maxlen": 80,
37+
// Enforce line length to 100 characters
38+
"maxlen": 100,
3939

4040
// Require capitalized names for constructor functions.
4141
"newcap": true,

packages/eslint-config-airbnb/rules/legacy.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ module.exports = {
22
'rules': {
33
// specify the maximum depth that blocks can be nested
44
'max-depth': [0, 4],
5-
// specify the maximum length of a line in your program
6-
'max-len': [0, 80, 4],
75
// limits the number of parameters that can be used in the function declaration.
86
'max-params': [0, 3],
97
// specify the maximum number of statement allowed in a function

packages/eslint-config-airbnb/rules/style.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ module.exports = {
3434
'lines-around-comment': 0,
3535
// disallow mixed 'LF' and 'CRLF' as linebreaks
3636
'linebreak-style': 0,
37+
// specify the maximum length of a line in your program
38+
// https://github.com/eslint/eslint/blob/master/docs/rules/max-len.md
39+
'max-len': [2, {
40+
'code': 100,
41+
'comments': 100,
42+
'commentLength': 100,
43+
'tabWidth': 2,
44+
'ignoreUrls': false,
45+
'ignorePattern': null,
46+
'ignoreTrailingComments': false,
47+
'ignoreComments': false
48+
}],
3749
// specify the maximum depth callbacks can be nested
3850
'max-nested-callbacks': 0,
3951
// require a capital letter for constructors

0 commit comments

Comments
 (0)