Skip to content

Commit b6aa2fb

Browse files
lencionihibearpanda
authored andcommitted
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.
1 parent ced9744 commit b6aa2fb

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
@@ -483,25 +483,24 @@ Other Style Guides
483483
```
484484
485485
<a name="strings--line-length"></a><a name="6.2"></a>
486-
- [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.
487487
488-
<a name="strings--concat-perf"></a><a name="6.3"></a>
489-
- [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.
490489
491490
```javascript
492-
// bad
493-
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.';
494-
495491
// bad
496492
const errorMessage = 'This is a super long error that was thrown because \
497493
of Batman. When you stop to think about how Batman had anything to do \
498494
with this, you would get nowhere \
499495
fast.';
500496
501-
// good
497+
// bad
502498
const errorMessage = 'This is a super long error that was thrown because ' +
503499
'of Batman. When you stop to think about how Batman had anything to do ' +
504500
'with this, you would get nowhere fast.';
501+
502+
// good
503+
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.';
505504
```
506505
507506
<a name="es6-template-literals"></a><a name="6.4"></a>

0 commit comments

Comments
 (0)