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-apex-imo

v0.1.1

Published

Opinionated multiline formatting for Apex Lists and Maps - extends prettier-plugin-apex

Readme

prettier-plugin-apex-imo

npm version License: MIT CI

IMO = In My Opinion. Because Prettier is opinionated, and so am I.

An opinionated enhancement for prettier-plugin-apex that enforces multiline formatting for Apex Lists, Sets, and Maps with multiple entries.

The Problem

When using prettier-plugin-apex, code like this:

final String expectedJson = String.join(new List<String>{
  '{',
  '  "tags" : [ "reading", "gaming", "coding" ]',
  '}'
}, '\n');

Gets reformatted to a single line, defeating the purpose of readable formatting:

final String expectedJson = String.join(new List<String>{ '{', '  \"tags\" : [ \"reading\", \"gaming\", \"coding\" ]', '}' }, '\n');

The Solution

This plugin wraps prettier-plugin-apex and modifies the printing behaviour:

  • List literals with 2+ entries → Always multiline
  • Map literals with 2+ entries → Always multiline
  • Set literals with 2+ entries → Always multiline

This is non-configurable behaviour. Once installed, it just works.

Installation

pnpm add -D prettier prettier-plugin-apex prettier-plugin-apex-imo

Or with npm:

npm install --save-dev prettier prettier-plugin-apex prettier-plugin-apex-imo

Usage in Salesforce Projects

If you're working with a Salesforce project (created with sf project generate or Salesforce DX), follow these steps:

  1. Install the plugin:

    npm install --save-dev prettier-plugin-apex-imo

    Standard Salesforce projects already include prettier and prettier-plugin-apex in their package.json, so you only need to install prettier-plugin-apex-imo.

  2. Update your .prettierrc file:

    Replace prettier-plugin-apex with prettier-plugin-apex-imo in the plugins array:

    {
    	"trailingComma": "none",
    	"plugins": ["prettier-plugin-apex-imo", "@prettier/plugin-xml"]
    }

    The prettier-plugin-apex-imo plugin wraps prettier-plugin-apex, so you only need to specify prettier-plugin-apex-imo in your config. However, both plugins must be installed since prettier-plugin-apex is a peer dependency.

  3. Verify the configuration:

    npm run prettier:verify

    Or format your files:

    npm run prettier

    Standard Salesforce projects typically include a prettier script in package.json that formats all relevant files including Apex classes (.cls) and triggers (.trigger).

Examples

Before (prettier-plugin-apex)

List<String> items = new List<String>{ 'one', 'two', 'three' };
Set<String> tags = new Set<String>{ 'reading', 'gaming', 'coding' };
Map<String, Integer> counts = new Map<String, Integer>{ 'a' => 1, 'b' => 2 };

After (prettier-plugin-apex-imo)

List<String> items = new List<String>{
  'one',
  'two',
  'three'
};
Set<String> tags = new Set<String>{
  'reading',
  'gaming',
  'coding'
};
Map<String, Integer> counts = new Map<String, Integer>{
  'a' => 1,
  'b' => 2
};

Single Items (unchanged)

// These stay on one line
List<String> single = new List<String>{ 'only' };
Set<String> singleSet = new Set<String>{ 'only' };
Map<String, Integer> singleMap = new Map<String, Integer>{ 'key' => 1 };

Requirements

  • Node.js >= 20
  • Prettier >= 3.0.0
  • prettier-plugin-apex >= 2.0.0

Why "imo"?

Prettier has a strict option philosophy that discourages adding new formatting options. While I respect this philosophy, I believe the current behaviour for multi-item Lists and Maps is suboptimal for code readability.

Rather than fork prettier-plugin-apex or maintain options, this plugin provides a simple, opinionated wrapper that enforces the behaviour I (and hopefully others) prefer.

Contributing

Contributions are welcome! Please read CONTRIBUTING.md for details.

Security

For security issues, please email [email protected]. See SECURITY.md for details.

License

This project is licensed under the MIT License. See the LICENSE.md file for details.

Acknowledgements