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:
- Created 6 years ago
- Reactions:2
- Comments:14 (5 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Looks like this was a prettier issue and is now fixed.
As pointed by @mathieulj, An issue with prettier. Thanks for fixing it @mathieulj 😉