Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

235
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda