Skip to content

Commit fc8442f

Browse files
committed
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.
1 parent bfc842e commit fc8442f

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

README.md

+6-7
Original file line numberDiff line numberDiff line change
@@ -480,25 +480,24 @@ Other Style Guides
480480
```
481481
482482
<a name="strings--line-length"></a><a name="6.2"></a>
483-
- [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.
484484
485-
<a name="strings--concat-perf"></a><a name="6.3"></a>
486-
- [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.
487486
488487
```javascript
489-
// bad
490-
const errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';
491-
492488
// bad
493489
const errorMessage = 'This is a super long error that was thrown because \
494490
of Batman. When you stop to think about how Batman had anything to do \
495491
with this, you would get nowhere \
496492
fast.';
497493
498-
// good
494+
// bad
499495
const errorMessage = 'This is a super long error that was thrown because ' +
500496
'of Batman. When you stop to think about how Batman had anything to do ' +
501497
'with this, you would get nowhere fast.';
498+
499+
// good
500+
const errorMessage = 'This is a super long error that was thrown because of Batman. When you stop to think about how Batman had anything to do with this, you would get nowhere fast.';
502501
```
503502
504503
<a name="es6-template-literals"></a><a name="6.4"></a>

0 commit comments

Comments
 (0)