npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

prettier-plugin-xml-salesforce

v1.0.0

Published

A Prettier plugin for formatting XML files in Salesforce projects

Downloads

171

Readme

prettier-plugin-xml-salesforce

This plugin extends the functionality of the plugin @prettier/plugin-xml, providing custom formatting for Salesforce XML files, specifically handling <flow> elements and formula tags.

This plugin also support (re-exports) all the standard features of @prettier/plugin-xml: see documentation.

Problem Statement

Flow Tags

Salesforce Permission Set XML files may contain <flow> tags which grant access to specific flows. These tags require to be formatted as single-line elements to maintain proper XML structure by design. Unfortunately, the default @prettier/plugin-xml does not handle this correctly, often breaking the intended single-line format.

Example:

<PermissionSet>
    <flow>SomeFlowAccess</flow>
</PermissionSet>

easily becomes:

<PermissionSet>
    <flow>
        SomeFlowAccess;
    </flow>
</PermissionSet>

This breaks the deployment of the *.permissionset-meta.xml files.

Formulas

Salesforce Formula Fields and Validation Rules often contain complex formula expressions. These formulas need to be formatted in a canonical way to ensure readability and maintainability. Unfortunately, there is no default formatting for these formulas, so they must be formatted manually or retriaved and left as-is by default.

Example:

<CustomField>
    <formula>AND(
ISPICKVAL ( Status__c , "quot;Active"quot;),
NOT( ISBLANK( End_Date__c) ))
    </formula>
</CustomField>

This plugin formats Salesforce formula tags in a canonical way:

<CustomField>
    <formula>
    AND(
        ISPICKVAL(Status__c, "Active"),
        NOT(ISBLANK(End_Date__c))
    )
    </formula>
</CustomField>

This allows easier readability and maintainability of complex Salesforce formulas within XML files.

Salesforce Limitations

Formula fields in Salesforce have a character limit, and overly complex formulas may exceed this limit when formatted with additional line breaks and indentation. Developers should be aware of this limitation when using the plugin to format formula tags.

| Limit | Value | | --------------- | --------------- | | Formula Field | 4000 characters | | Validation Rule | 3900 characters |

Usage

Prettier Configuration

In the Prettier configuration file (e.g., .prettierrc), you can enable the plugin and its custom options as follows:

{
    "plugins": ["prettier-plugin-xml-salesforce"],
    "xmlFlowSingleLine": true,
    "xmlFormulaFormat": true
}

This plugin should be used instead of the default @prettier/plugin-xml when working with Salesforce XML files to ensure proper formatting of <flow> tags (in permission sets) and formula tags.

Prettier Options

| Option | Type | Default | Description | | ----------------- | ------- | ------- | ---------------------------------------------------------------- | | xmlFlowSingleLine | boolean | true | Format <flow>...</flow> as a single line and drop trailing ; | | xmlFormulaFormat | boolean | false | Canonically format Salesforce formula tags |