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
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 (#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.
483
+
- [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).
485
+
> Why? Broken strings are painful to work with and make code less searchable.
487
486
488
487
```javascript
489
-
// bad
490
-
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.';
491
-
492
488
// bad
493
489
const errorMessage = 'This is a super long error that was thrown because \
494
490
ofBatman. When you stop to think about how Batman had anything to do \
495
491
withthis, you would get nowhere \
496
492
fast.';
497
493
498
-
// good
494
+
// bad
499
495
const errorMessage = 'This is a super long error that was thrown because ' +
500
496
'ofBatman. When you stop to think about how Batman had anything to do' +
501
497
'withthis, you would get nowhere fast.';
498
+
499
+
// good
500
+
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