Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

237
Views
ESLint: Rule to disallow and fix line breaks in template literal placeholder expressions

If I have this Javascript code which uses string concatenation spread across multiple lines:

const htmlString = '<span style="' +
    STYLE +
    '">Test</span>";

And I run ESLint with the prefer-template rule to fix with this config:

.eslintrc.json:

{
    "parserOptions": {
        "ecmaVersion": 2020
    },
    "rules": {
        "prefer-template": "error",
        "template-curly-spacing": ["error", "never"]
    }
}

The code is corrected to:

const htmlString = `<span style="${ 
    STYLE 
    }">Test</span>`;

The template-curly-spacing rule disallows spaces but not line breaks.

Is there an ESLint rule that could be used to disallow and remove the line breaks in the placeholder expression so that it could be automatically fixed to be this?

const htmlString = `<span style="${STYLE}">Test</span>`;

I understand that newline characters are preserved in template literal multi-line strings, but in this case it would be cleaner in my code for there to not be line breaks inside my placeholder expressions.

If this can't be done with an existing ESLint rule, I suppose I could do a global find/replace in VS Code, but it would be ideal to be able to enforce this with ESLint.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!