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

593
Views
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 answers
Answer question

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 Report
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!