Pawan Nogariya
Pawan Nogariya

Reputation: 8950

VS Code - Prettier is formatting differently for me than others

Prettier is behaving differently for me compared to my team mates.

We all have same version 9.5.0 of prettier installed on our VS Code. We all have same configuration of prettier.

Still it is formatting my typescript file differently for one particular line than others and because of this the deployment is failing when I push anything from my machine and works for everybody else.

Does anybody face this?

Which part should I check to see the difference?

Update 1

One thing we found that is different is the VS Code version.

I have version 1.67.2 installed my colleague has 1.63.2 installed.

Could this be the reason?

Update 2

This is the exact line where I am getting prettier error on my machine for wrong formatting while this same formatting is considered correct by prettier for other machines

enter image description here

And this is how prettier formats the line on my machine (then devops complaint that it is a wrong formatting)

enter image description here

Upvotes: 6

Views: 8167

Answers (3)

wc203
wc203

Reputation: 1217

I think there is a bug with the prettier extension. Although I had my default formatter set to the prettier extension in the settings UI, I had to re do it manually.

Open any file, right click in the editor screen, click Format document with and choose Prettier - Code formatter.

The local prettier config and the one vscode uses should work now

Upvotes: 11

eli chen
eli chen

Reputation: 878

I faced the same isssue. in my case I run
npx prettier --version
on both computer and each one return different prettier version. so although the prettier extension in vscode was 9.5.0 for both pcs. the npm module installed for the project in node_modules was different.

I installed the same prettier module for both computer and the restart vscode and problem solved

Upvotes: 4

Grekkq
Grekkq

Reputation: 766

You might have installed multiple formatters and you aren't using the correct one. Try to specify it manually in command palette. Check out this answer (Solution A)

Upvotes: 0

Related Questions