0

can someone confirm how to get prettier working with visualforce pages on save in VSCode? I have tried in a fresh project but it never works.

Steps taken:

  1. SFDX: Create Project
  2. npm install
  3. SFD: Create Visualforce Page
  4. edit and save test visualforce page - prettier doesn't run...

Settings below confirmed:

  • Default formatter = Prettier - Code Formatter
  • Format on Save
  • .prettierrc is present
{
  "trailingComma": "none",
  "overrides": [
    {
      "files": "**/lwc/**/*.html",
      "options": { "parser": "lwc" }
    },
    {
      "files": "*.{cmp,page,component}",
      "options": { "parser": "html" }
    }
  ]
}

Am I missing something?

4
  • .prettierrc looks ok, check if you have any errors related to prettier on the output panel, you can filter the output for prettier only. – Rahul Gawale Jun 18 at 11:28
  • No output so looks like its being ignored? – jonny-harte Jun 18 at 11:29
  • hmm check in the package.json's script tag, if you have prettier and it should be something like this -> "prettier": "prettier --write \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"", "prettier:verify": "prettier --list-different \"**/*.{cls,cmp,component,css,html,js,json,md,page,trigger,xml,yaml,yml}\"" – Rahul Gawale Jun 18 at 11:31
  • Yep got the script and if I run from the terminal it formats correctly – jonny-harte Jun 18 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.