简体   繁体   中英

Prettier is not formatting code at all in vscode

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

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
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM