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

v1.1.2

Published

a Prettier plugin for vertically aligning your code.

Readme

prettier-plugin-verticalize

这是一个 Prettier v3+ 插件,用于对代码中的变量声明、枚举属性、赋值表达式等进行垂直对齐

目前支持的对齐:

  • 变量声明
  • 枚举值
  • 赋值表达式
  • 行尾注释

⚠️ 本插件依赖等宽字体才能正确显示对齐效果。请确保编辑器使用的是等宽(monospace)字体,例如 Fira Code, JetBrains Mono, Consolas, Monaco 等。

效果预览

效果预览

安装

npm install -D prettier prettier-plugin-verticalize

需要 Prettier 3.x。

启用

在 Prettier 配置文件(prettier.config.js、prettier.config.cjs 或 .prettierrc)中注册插件。

// prettier.config.js
import prettierPluginVerticalize from 'prettier-plugin-verticalize'
export default {
  plugins: [prettierPluginVerticalize],
}
// prettier.config.cjs
module.exports = {
  plugins: [require('prettier-plugin-verticalize')],
}
// .prettierrc
{
  "plugins": ["prettier-plugin-verticalize"]
}

配置选项

| 选项 | 类型 | 默认值 | 说明 | | -------------------------------------- | --------- | ------ | ----------------------------- | | minGroupSize | number | 2 | 最少几条语句视为一组进行对齐 | | maxWidthDiff | number | 20 | 组内语句之间最大宽度差异 | | alignTrailingComments | boolean | true | 是否启用行尾注释对齐 | | alignEnums | boolean | true | 是否启用枚举对齐 | | alignVariableDeclaration | boolean | true | 是否启用变量声明对齐 | | alignAssignment | boolean | true | 是否启用赋值语句对齐 | | alignTrailingCommentsMinGroupSize | number | - | 单独设置行尾注释 minGroupSize | | alignTrailingCommentsMaxWidthDiff | number | - | 单独设置行尾注释 maxWidthDiff | | alignEnumsMinGroupSize | number | - | 单独设置枚举 minGroupSize | | alignEnumsMaxWidthDiff | number | - | 单独设置枚举 maxWidthDiff | | alignVariableDeclarationMinGroupSize | number | - | 单独设置变量声明 minGroupSize | | alignVariableDeclarationMaxWidthDiff | number | - | 单独设置变量声明 maxWidthDiff | | alignAssignmentMinGroupSize | number | - | 单独设置赋值语句 minGroupSize | | alignAssignmentMaxWidthDiff | number | - | 单独设置赋值语句 maxWidthDiff |

minGroupSize

// 当 `minGroupSize` 设置为 3 时,少于 3 行,不对齐
const name = 'rio'
const age = 18

// 当 `minGroupSize` 设置为 3 时,大于等于 3 行,对齐
const foo       = 1
const barz      = 2
const component = 3

maxWidthDiff

// 当 `maxWidthDiff` 设置为 20 时
console.log('1234')       // 注释前长度差距为6
console.log('1234567890') // 注释前长度差距为6

const number1234       = 1 
const number1234567890 = 1

// 当 `maxWidthDiff` 设置为 5 时
console.log('1234') // 注释前长度差距为6
console.log('1234567890') // 注释前长度差距为6

const number1234 = 1
const number1234567890 = 1