Search code examples
javascriptreactjsvisual-studio-codeprettier

VSC extension Prettier doesn't format on save


I know there's a lot of duplicate questions, but generally the fix is to set Prettier as the default formatter. This is not the case here.

My Visual Studio Code settings are as follows:

// Settings.json
{
  "editor.formatOnSave": true,
  "prettier.configPath": ".prettierrc.json",
  "prettier.jsxSingleQuote": true,
  "prettier.requireConfig": true,
  "editor.defaultFormatter": "esbenp.prettier-vscode"
}

My Prettier config is as follows:

// .prettierrc.json
{
  "useTabs": false,
  "printWidth": 80,
  "tabWidth": 2,
  "singleQuote": true,
  "trailingComma": "none",
  "jsxBracketSameLine": true,
  "noSemi": true
}

Prettier was working properly until yesterday. I disabled it, didn't touch settings, and enabled it again. Now, it's gone. I've tried tinkering with the settings quite a while with no success. Reinstalling the extension, reactivating the extension does not seem to have any result. AutoDelay is disable on autoSave, as well, since I know that Prettier has a problem with that.


Solution

  • I figured it out. I wasn't linking to my prettier config properly. All I needed to do is change

    "prettier.configPath": "./web/proj/.prettierrc"
    

    If anyone else is encountering this issue, beware prettierrc!