Reputation: 8950
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
And this is how prettier formats the line on my machine (then devops complaint that it is a wrong formatting)
Upvotes: 6
Views: 8167
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
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
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