0

I just cloned my job reactJs project that has following .prettierrc config in /src directory

{
"arrowParens": "avoid",
"bracketSpacing": true,
"endOfLine": "auto",
"jsxBracketSameLine": false,
"printWidth": 120,
"requirePragma": true,
"semi": true,
"singleQuote": true,
"tabWidth": 4,
"trailingComma": "all",
"lineLength": 120}

and my prettier now is not formatting my .js files at all. It ignores not only on save event also

shift + alt + f 

I tried putting relative and absolute paths in config path field(in settings -> extensions -> prettier) Maybe the problem is that my project has its backend next to frontend(Symfony). So I am not able to follow formatting rules of my project. Any help is highly appreciated

howard wolowitz
  • 477
  • 5
  • 21
  • default formatter is set to prettier. right click -> format document with-> configure -> prettier – howard wolowitz Jun 15 '21 at 16:53
  • have you installed the dependencies yet? either `npm install` or `yarn install` depending on which package manager your project uses – kennyvh Jun 15 '21 at 16:56
  • maybe i am specifiing path to .prettierrc in th wrong way... but formatting does not worl at all without it too – howard wolowitz Jun 15 '21 at 16:56
  • do i need to run npm install ? because i just tested it in other project( just new folder with only nodemon and body-parser in package.json) and it worked for it – howard wolowitz Jun 15 '21 at 17:01

1 Answers1

0

Go to VSCode settings, click on JSON add the following section if missing.

    "editor.defaultFormatter": "esbenp.prettier-vscode"

or try this..

{
  "window.zoomLevel": 1,
  "editor.formatOnPaste": true,
  "editor.formatOnSave": true,
  "editor.formatOnType": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "emmet.includeLanguages": {
    "javascript": "javascriptreact"
  },
  "prettier.singleQuote": true
}
gsb22
  • 2,112
  • 2
  • 10
  • 25