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

594
Visualizações
I wish to know how I can prevent Prettier to format my js code in this strange form

I started to use Prettier inside my Microsoft Visual Studio Code (MVSC), but, when formatting a javascript file, I get some strange formatting.

For example, if I have this code:

    if ($("#epgprogramdescription" + channelListIndexOffset + ":nth-of-type(" + (programListIndexOffset + 1) + ")" ).length) {
        $("#epgprogramdescription" + channelListIndexOffset + ":nth-of-type(" + programListIndexOffset + ")").removeClass("epgtablerowselected");
        $("#epgprogramdescription" + channelListIndexOffset + ":nth-of-type(" + (programListIndexOffset + 1) + ")").addClass("epgtablerowselected");
    } else {
        programListIndexOffset--;
    }

It get it formatted as:

    if (
        $(
            "#epgprogramdescription" +
                channelListIndexOffset +
                ":nth-of-type(" +
                (programListIndexOffset + 1) +
                ")"
        ).length
    ) {
        $(
            "#epgprogramdescription" +
                channelListIndexOffset +
                ":nth-of-type(" +
                programListIndexOffset +
                ")"
        ).removeClass("epgtablerowselected");
        $(
            "#epgprogramdescription" +
                channelListIndexOffset +
                ":nth-of-type(" +
                (programListIndexOffset + 1) +
                ")"
        ).addClass("epgtablerowselected");
    } else {
        programListIndexOffset--;
    }

Any way to configure Prettier to maintain the original formatting?

Thanks.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Prettier gonna always try to give line break your code if it exceeds your print width configuration.

You can change that by accessing vscode settings

  1. Go to File -> Preferences -> Settings
  2. Search for "Prettier"
  3. Look for configuration called "Prettier: Print Width"
  4. And change it to suit your needs !

Give it bigger value if you want your code to stay in the same line. Prettier only break your code into new lines if it exceeds the given configuration

about 4 years ago · Juan Pablo Isaza Relatório
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