Prettier suddenly Does not format Visualforce .page files
See original GitHub issueSummary
Does not format Visualforce .page files.
Steps To Reproduce:
- Create a Salesforce DX project in VS Code with the Salesforce Extension Pack installed.
- Follow the Prettier Code Formatter instructions.
- In Settings, set Editor: Default Formatter to Prettier.
- In Settings, check Editor:Format on Save.
- Create a Visualfoce page with the following code
<apex:page controller="myAccountController" lightningStylesheets="true">
<apex:form>
<apex:pageBlock title="Edit Account">
<apex:pageBlockSection columns="1">
<apex:inputField value="{! Account.Name }" ignoreEditPermissionForRendering="true"/>
<apex:inputField value="{! Account.Phone }" ignoreEditPermissionForRendering="true"/>
<apex:inputField value="{! Account.Industry }" ignoreEditPermissionForRendering="true"/>
<apex:inputField value="{! Account.AnnualRevenue }" ignoreEditPermissionForRendering="true"/>
</apex:pageBlockSection>
<apex:pageBlockButtons>
<apex:commandButton action="{! save }" value="Save" />
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
- Save the Visualforce .page file
Expected result
Prettier formats the document.
Actual result
Error shows at bottom of window, with message that Prettier cannot format the file.
Additional information
VS Code Version: Version: 1.57.1 (user setup)
SFDX CLI Version: sfdx-cli/7.107.0 win32-x64 node-v14.17.1
OS and version: OS: Windows_NT x64 10.0.19041
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Visual Studio Code Prettier plugin for Apex not formatting ...
Type 'Beautify File' in the search box and select it. Select 'HTML' from out of the three options which are getting populated.
Read more >Why does Prettier not format code in VS Code? - Stack Overflow
Select File -> Preferences -> Settings ( Ctrl + comma ) and search form formatter; Set Prettiers as Default formatter. enter image ...
Read more >Prettier for Apex Errors - Salesforce Developer Community
I'm new to Apex and programming in general, so wanted to use a code formatter to help me get used to formatting standards....
Read more >Inconsistent Formatting between Prettier and Org · Issue #4162
Create an Aura/LWC. Prettier files. Commit to Repo. Deploy to Org. Retrieve from Org. Review source control panel in VSCode. Expected result. No...
Read more >Prettier for SFDX: Format Apex and LWC
Add Prettier to your SFDX project and configure it for Apex, Visualforce and LWC. Automatically format your code on type and save.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you are using Prettier as the code formatter for visualforce, you should also add the following glob pattern to your
.vscode/settings.json
file.Otherwise, if you are using the formatter from visualforce language server, add the following setting to override the default formatter setting.
Thanks @xyc the glob pattern didnt work but the below did.
"prettier.documentSelectors": ["**/*.{cmp,page,component}"],