You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Reverse rule on string concatenation for long lines (airbnb#995)
Broken and concatenated long strings are painful to work with and
produce less readable and searchable code. I think we should reverse
this rule.
Unfortunately, the max-len rule currently does not allow for this, but
there is currently a proposal to add an option to ESLint's max-len rule
that would allow for strings to be ignored.
eslint/eslint#5805
There have also been discussions around performance of string
concatenation (airbnb#40), but I
don't think that is very relevant here so I removed the links to them.
- [6.2](#strings--line-length) Strings that cause the line to go over 100 characters should be written across multiple lines using string concatenation.
486
+
- [6.2](#strings--line-length) Strings that cause the line to go over 100 characters should not be written across multiple lines using string concatenation.
- [6.3](#strings--concat-perf) 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).
488
+
> Why? Broken strings are painful to work with and make code less searchable.
490
489
491
490
```javascript
492
-
// bad
493
-
const errorMessage = 'This is a super long error that was thrown because ofBatman. When you stop to think about how Batman had anything to dowiththis, you would get nowhere fast.';
494
-
495
491
// bad
496
492
const errorMessage = 'This is a super long error that was thrown because \
497
493
ofBatman. When you stop to think about how Batman had anything to do \
498
494
withthis, you would get nowhere \
499
495
fast.';
500
496
501
-
// good
497
+
// bad
502
498
const errorMessage = 'This is a super long error that was thrown because ' +
503
499
'ofBatman. When you stop to think about how Batman had anything to do' +
504
500
'withthis, you would get nowhere fast.';
501
+
502
+
// good
503
+
const errorMessage = 'This is a super long error that was thrown because ofBatman. When you stop to think about how Batman had anything to dowiththis, you would get nowhere fast.';
0 commit comments