1

It seems there are 2 tools that you can use for code formatting: Uncrustify and Prettier. I find the config for both incredibly frustrating because it has to be repeated for each org you set up. Does anyone have a workaround for this? Here's what I've tried:

With Uncrustify, the error is that it can't find the expected config file. This can be fixed by adding

"uncrustify.configPath.windows": "C:\\...Uncrustify\\uncrustify.cfg"

At this point, it does not throw this, or any, error when you run Alt+Shift+F but VS Code throws a "Command 'Format Document' Resulted In Error" error when I run >Format Document. I don't see a clear way to debug beyond this (and honestly Im pretty sick of this thing, I shouldn't have to install a binary and do their debugging to get an extension to work).


With Prettier, it sort of works out of the box. The issue is it has several settings which don't match standard VS Code: using spaces, not tabs, and setting a tab size to 2 spaces mostly.

They have settings that would change this globally, but SF Extensions add a default .prettierrc file with each new org so prettier will handle LWCs which overrides the settings. This means you have to add prettier settings in every single org you want to use this in.

I create a lot of orgs, usually a new one every couple weeks. Does anyone have any workarounds that actually allows for formatting without setting up the formatters every time?

2
  • 2
    I'm sure someone else can help. From me I only have a facetious answer, which is to use IntelliJ IDEA with Illuminated Cloud 2 where all the formatting is part of your project configuration which you can store in git along with all your lovely metadata etc. Comes down to whether you will pay for licenses or not.
    – Phil W
    Oct 15, 2019 at 20:28
  • Haha with all the issues Im having with the SF Extensions Im seriously considering the move
    – Apexing
    Oct 15, 2019 at 20:47

1 Answer 1

0

For anyone else running into this, you have to set up uncrustify, uninstall the plugin. Close VS Code, re-open and reinstall the plugin. This worked for me

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .