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

@su-labs/prettier-plugin-single-line-imports

v1.0.0

Published

Prettier plugin that keeps every import on a single line, whatever its length. Everything else is formatted by Prettier as usual.

Readme

Prettier Plugin: Single-Line Imports

@su-labs/prettier-plugin-single-line-imports

npm Prettier License

Keeps every import on a single line, whatever its length. Everything else is formatted by Prettier exactly as before.

// Always this
import { ChangeDetectionStrategy, Component, computed, inject, input, signal } from '@angular/core';

// Never this
import {
  ChangeDetectionStrategy,
  Component,
  computed,
  inject,
  input,
  signal,
} from '@angular/core';

Table of Contents

Why

Many teams keep imports on one line so the list of dependencies stays compact and diffs stay readable. Prettier has no option for this: any import longer than printWidth is wrapped. Since ESLint (through eslint-plugin-prettier) and format-on-save both run Prettier, the imports keep getting split again, whatever other settings are used.

This plugin changes how Prettier itself prints imports, so every tool that runs Prettier produces the same single-line output. It replaces extensions such as TypeScript Hero, which are no longer maintained.

Installation

npm install --save-dev @su-labs/prettier-plugin-single-line-imports

Requires Prettier 3.

Setup

Add the plugin to your Prettier configuration:

// prettier.config.js
module.exports = {
  printWidth: 100,
  plugins: ['@su-labs/prettier-plugin-single-line-imports'],
};

or in .prettierrc:

{
  "plugins": ["@su-labs/prettier-plugin-single-line-imports"]
}

Prettier reads only one configuration file. If your package.json has a "prettier" key, that one wins over prettier.config.js and .prettierrc, so add the plugin there or remove the key.

VS Code

With the Prettier extension, this workspace setup organizes imports and keeps them on one line on every save:

// .vscode/settings.json
{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true,
  "editor.codeActionsOnSave": {
    "source.organizeImports": "explicit"
  }
}

VS Code runs source.organizeImports first and the formatter afterwards, so imports added automatically or merged by TypeScript are joined into one line by Prettier at the end.

ESLint

eslint-plugin-prettier uses your Prettier configuration, so eslint --fix keeps imports on one line too. No extra rule is needed.

If you use the core max-len rule (or @stylistic/max-len), exclude imports from it:

'max-len': ['error', { code: 100, ignorePattern: '^import\\s.+\\sfrom\\s.+;$' }],

What It Changes

| Code | Result | |------|--------| | import { A, B } from 'x', import type { … }, import Default, { … }, import * as name, import 'side-effect' | Always one line | | An import with a // or /* */ comment inside | Formatted by Prettier as usual, so a // comment can't hide the rest of the import | | A comment after the import (import { a } from 'x'; // why) | Joined; the comment stays at the end of the line | | // prettier-ignore above an import | Left exactly as written | | Re-exports (export { … } from 'x'), dynamic import(), import x = require() and all other code | Formatted by Prettier as usual |

Supported parsers: typescript, babel-ts and babel. These are Prettier's defaults for .ts, .tsx, .mts, .cts, .js, .jsx, .mjs and .cjs files, and for TypeScript code blocks in Markdown. JSON, CSS, HTML and Angular templates are not affected.

Compatibility

The plugin depends only on Prettier, not on Angular or your TypeScript version (Prettier ships its own parser). It works in any project that uses Prettier 3, for example Angular 17, 18, 19 and newer.

| Tested with | Versions | |-------------|----------| | Prettier | Every minor release from 3.0.0 to 3.9.10 | | ESLint with eslint-plugin-prettier | ESLint 9.15 and 9.39 (flat config), eslint --fix included | | Toolchain of an Angular 19 project | Prettier 3.3.3, ESLint 9.15, typescript-eslint 8.15, TypeScript 5.6 | | Prettier configuration files | .prettierrc.json, prettier.config.js, prettier.config.mjs, prettier.config.cjs | | Editor | VS Code with the Prettier extension, format on save and source.organizeImports |

The published code is compiled to ES2020, so it runs on every Node.js version Prettier 3 supports.

Troubleshooting

npm install fails with peer prettier@"^3.0.0". Your project uses Prettier 2. Upgrade to Prettier 3 (npm install --save-dev prettier@3); its plugin system is different and this plugin needs it.

Imports still break onto several lines.

  • Check that Prettier finds the configuration that lists the plugin: npx prettier --find-config-path src/main.ts. Remember that a "prettier" key in package.json wins over other config files.
  • In VS Code, open View → Output → Prettier to see which configuration was loaded.
  • An import that contains a comment is formatted by Prettier as usual. This is on purpose.

require() of the plugin fails in a CommonJS config. The package is an ES module. List it by name (plugins: ['@su-labs/prettier-plugin-single-line-imports']) and Prettier loads it for you, in both .cjs and .mjs configs.

Limitations

  • Other Prettier plugins that also replace the typescript or babel parser (for example import-sorting plugins) have not been tested together with this one.
  • The plugin decides on line breaks only. It doesn't add, sort or merge imports; leave that to source.organizeImports or your import-sorting tool.

License

MIT © 2026 Yevheniy Alekseyev