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

171
Views
How do you stop prettier or beautify breaking JS objects onto multiple lines?

I need this:

    var short_sleeve = {
        type: "Short Sleeve",
        id: this.item.epos_code,
    };

To look like this:

var short_sleeve = { type: "Short Sleeve", id: this.item.epos_code, };

Here is my prettierrc.json:

{
    "bracketSpacing": false,
    "endOfLine": "auto",
    "printWidth": 300,
    "proseWrap": "never",
    "tabWidth": 4,
    "trailingComma": "all",
    "useTabs": true
}

and here is my vs code settings.json

{
    "prettier.singleQuote": true,
    "prettier.tabWidth": 4,
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "prettier.printWidth": 300,
    "editor.formatOnSave": true,
    "files.trimTrailingWhitespace": true,
    "diffEditor.ignoreTrimWhitespace": false,
    "prettier.proseWrap": "never",
    "materialTheme.accent": "Acid Lime",
    "twig-language.wrap": 100
}

I have tried the solutions here: Prevent Prettier from converting single line object declarations into multi line in Visual Studio Code? . Nothing

This is solution isn't relevant as HTML is working fine: How do you stop Prettier in VS code splitting attributes onto multiple lines?

I have played with printWidth, setting this to 1000. Nothing. I have checked to see no other formatters are installed and running. Still Nothing.

No idea why it won't condense smaller objects onto one line.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

This is probably caused because your printWidth value is really large ("printWidth": 300)

printWidth specifies the line length that the printer will wrap on. Try decrementing the value to something like "printWidth": 160 instead (the default value is actually 80)

You can read more about it at the prettier documentation option page

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!