Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

232
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda