Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prettier is giving inconsistent results on different machines

My colleague and I are working on same project in different parts of app. But we got certain files which his prettier and my prettier are overwriting each time we push our code to the github. Here is the example of his prettier:

const initialState = {
  login: {
    testValue1: "hello",
    testValue2: "world",
    testValue3: true,
    testValue4: "SomeValue",
  },
} as unknown as { example: InitialState; example1: ExampleState };

Example of my prettier:

const initialState = ({
 login: {
    testValue1: "hello",
    testValue2: "world",
    testValue3: true,
    testValue4: "SomeValue",
  },
} as unknown) as { example: InitialState; example1: ExampleState };

So the difference are brackets which one machine putting there and another one is removing. How can we solve this small issue and have a consistent Prettier?

Forgot to mention that I have .prettierrc:

{
  "printWidth": 100,
  "trailingComma": "all",
  "tabWidth": 2,
  "semi": true,
  "singleQuote": false
}
like image 302
Sonny49 Avatar asked Sep 14 '25 21:09

Sonny49


1 Answers

Faced the same problem

What i did:

  1. npx prettier --version to check what version installed in node_modules/. (in my case versions from package.json and one from node_modules/ were different)

  2. rm -rf node_modules to delete node_modules folder

  3. yarn or npm install

Done.

like image 63
Sergii Avatar answered Sep 17 '25 11:09

Sergii