Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prefer-template option, allowing multiline concatenation

See original GitHub issue


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:closed
  • Created 7 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

mysticateacommented, May 4, 2016

@EnoahNetzach You can use concatenations.

/* eslint prefer-template: "error" */
/* eslint-env es6 */

const name = 'John'
if (check) {
    const string = `This line spans multiple lines, but when I go` +
        `to a new line all my efforts to maintain a nice-looking` +
        `indentation are gone. By the way, hi, ${name}!`

prefer-template is not warning concatenations between literals.

albertocommented, Aug 1, 2016

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found