prefer-template option, allowing multiline concatenation
See original GitHub issueHi.
I think it would be useful to allow string concatenation, if user spreads the string across multiple lines(either because the string is too long to fit into a single line, or for readability purposes).
For example this code will throw:
/*eslint "prefer-template": "error" */
const name = "John";
const longStr = 'Hi, ' +
name +
'. I am a long string, ' +
'that\'s going to be spread across multiple lines.';
I propose an option, like allowMultiline
, so that this code doesn’t throw:
/*eslint "prefer-template": ["error", { "allowMultiline": true }]*/
const name = "John";
const longStr = 'Hi, ' +
name +
'. I am a long string, ' +
'that\'s going to be spread across multiple lines.';
Issue Analytics
- State:
- Created 7 years ago
- Comments:8 (6 by maintainers)
Top Results From Across the Web
prefer-template - ESLint - Pluggable JavaScript Linter
A pluggable and configurable linter tool for identifying and reporting on patterns in JavaScript. Maintain your code quality with ease.
Read more >typescript asking for template literal - javascript - Stack Overflow
I'm using typescript, and is complaining when concatenating a string, const content = senderDisplay ...
Read more >Getting Literal With ES6 Template Strings - Chrome Developers
Template Strings significantly simplify multiline strings. Simply include newlines where they are needed and BOOM. Here's an example: Any ...
Read more >Template Literals are Strictly Better Strings - Ponyfoo
This article explores how template literals are strictly better than strings, and how they too should become the new default of a post-ES6 ......
Read more >Concatenating strings with template literals. Tagged templates
A noteworthy aspect of using template literals are multi-line strings. If you press enter in the middle of a template literal, you insert...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@EnoahNetzach You can use concatenations.
prefer-template
is not warning concatenations between literals.Thanks for your interest in improving eslint. Unfortunately, it looks like consensus couldn’t be reached on this issue and so I’m closing it. While we wish we’d be able to accommodate everyone’s requests, we do need to prioritize. We’ve found that issues failing to reach consensus after 21 days tend never to reach consensus, and as such, we close those issues. This doesn’t mean the idea isn’t interesting, just that it’s not something the team can commit to.