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-multiline

v1.1.0

Published

Prettier plugin for multiline formatting and safe sorting

Readme

Prettier Multiline Plugin

A Prettier plugin that formats imports, arrays, and objects on multiple lines to minimize merge conflicts in collaborative development environments.

npm version License: MIT

Why Multi-line Formatting Matters

The Problem: Merge Conflicts in Collaborative Development

In large projects with multiple developers working simultaneously, merge conflicts are a common pain point that slow down development and integration. One of the most frequent sources of these conflicts is single-line formatting of imports, arrays, and objects.

Consider this common scenario:

  1. Developer A adds a new import to a file:

    import { alpha, beta, delta, gamma } from 'module';
  2. Meanwhile, Developer B also adds a different import to the same line:

    import { alpha, beta, epsilon, gamma } from 'module';
  3. When merging these changes, a conflict occurs that must be manually resolved:

    <<<<<<< HEAD
    import { alpha, beta, delta, gamma } from 'module';
    =======
    import { alpha, beta, epsilon, gamma } from 'module';
    >>>>>>> feature-branch

These conflicts are:

  • Time-consuming: Each must be manually resolved
  • Error-prone: Easy to accidentally remove someone's import
  • Frequent: Happens constantly in active projects

The Solution: Multi-line Formatting

By formatting imports, arrays, and objects with one item per line, merge conflicts become both less frequent and easier to resolve:

import {
  alpha,
  beta,
  delta,
  gamma,
} from 'module';

Benefits:

  1. Reduced Conflict Frequency: Changes to different items won't conflict
  2. Clearer Diffs: Git diffs show exactly which item was added/removed
  3. Easier Resolution: When conflicts do occur, they're isolated to specific items
  4. Better Code Reviews: Reviewers can clearly see which items were modified
  5. Improved Maintainability: Easier to alphabetize or organize imports

Real-world Example

With single-line formatting:

- import { alpha, beta, gamma } from 'module';
+ import { alpha, beta, delta, gamma } from 'module';

If two developers add different items, this creates a merge conflict.

With multi-line formatting:

  import {
    alpha,
    beta,
+   delta,
    gamma,
  } from 'module';

Even if two developers add different items, Git can often auto-merge these changes without conflicts.

Installation

npm install --save-dev prettier-plugin-multiline

Usage

Configuration File

Add the plugin to your Prettier configuration:

{
  "plugins": ["prettier-plugin-multiline"],
  "multilineImports": true,
  "multilineArrays": true,
  "multilineObjects": true,
  "sortImports": true,
  "minItemsForMultiline": 2
}

Command Line

You can also use the plugin directly from the command line:

# Format with multiline imports
npx prettier --plugin=prettier-plugin-multiline --parser=typescript --multiline-imports file.ts

# Format with sorted imports
npx prettier --plugin=prettier-plugin-multiline --parser=typescript --sort-imports file.ts

# Format with both multiline and sorted imports
npx prettier --plugin=prettier-plugin-multiline --parser=typescript --multiline-imports --sort-imports file.ts

# Set minimum items for multiline formatting
npx prettier --plugin=prettier-plugin-multiline --parser=typescript --multiline-imports --min-items-for-multiline=2 file.ts

Configuration Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | multilineImports | boolean | false | Format imports on multiple lines | | multilineArrays | boolean | false | Format array literals on multiple lines | | multilineObjects | boolean | false | Format object literals on multiple lines | | sortImports | boolean | false | Sort import specifiers | | minItemsForMultiline | number | 1 | Minimum number of items to trigger multiline formatting | | debug | boolean | false | Enable debug output for the plugin |

Example Configuration

For optimal merge conflict reduction in large projects:

{
  "plugins": ["prettier-plugin-multiline"],
  "multilineImports": true,
  "multilineArrays": true,
  "multilineObjects": true,
  "minItemsForMultiline": 2
}

This configuration will format all imports, arrays, and objects with 2 or more items on multiple lines, significantly reducing merge conflicts in collaborative environments.

License

MIT