question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prettier-vscode "Format Selection" works differently on some blocks of code

See original GitHub issue

./node_modules/.bin/prettier --config ./.prettierrc --write "src/**/*.{ts,tsx}" formats the code as expected, as does vs-code under prettier-vscode “Format Document”.

I have no other lint or prettier vs-code extension running other than this one, prettier-vscode. I’ve reloaded vscode and restarted vscode to be sure.

Yet when I do ‘Format Selection’ (this is all with prettier-vscode turned on) on some blocks such as this:

  const foo = bar<Bat>(
    baz({
      fooz: bats,
      bazz,
      barz
    } as batz),
    foo1(foo2, foo3(...foo4)) as foo5
  );

get formatted to be all on one line, totally ignoring the 140 line limit set in .prettierrc at the root of my project (alongside package.json).

import statements however are formatted as expected by “Format Selection”.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:2
  • Comments:14 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
ntottencommented, Oct 22, 2019

Looks like this was a prettier issue and is now fixed.

1reaction
CiGitcommented, Apr 25, 2019

As pointed by @mathieulj, An issue with prettier. Thanks for fixing it @mathieulj 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Format Code with Prettier in Visual Studio Code
In the command palette, search for format and then choose Format Document. Then choose Prettier - Code Formatter.
Read more >
How to configure Prettier and VSCode - Gleb Bahmutov
This blog post shows how to configure Prettier to work from command line, from VSCode and from Git hooks. You can find the...
Read more >
VS Code - Prettier is formatting differently for me than others
Open any file, right click in the editor screen, click Format document with and choose Prettier - Code formatter . The local prettier...
Read more >
How to use Prettier in VS Code - Code Formatting - YouTube
In this video I will show you how to install and configure Prettier Code Formatter in VS Code. Formatting code consistently can be...
Read more >
VS Code - You don't need a formatting extension (Prettier and ...
However, at that time, the advice I gave came with some caveats. VS Code has builtin formatters for HTML, JavaScript, TypeScript, and JSON....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found