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

@huaiyou/config-prettier

v1.0.0

Published

Shared Prettier configuration

Readme

@huaiyou/config-prettier

共享的 Prettier 配置,确保代码格式的一致性。

📦 安装

pnpm add -D @huaiyou/config-prettier prettier

🚀 使用方法

在 package.json 中使用

{
  "prettier": "@huaiyou/config-prettier"
}

在 .prettierrc.js 中使用

module.exports = require('@huaiyou/config-prettier');

使用 ES Module

import config from '@huaiyou/config-prettier';

export default config;

⚙️ 配置说明

| 选项 | 值 | 说明 | | ---------------- | ---------- | ---------------------- | | semi | true | 语句末尾添加分号 | | trailingComma | 'es5' | 尾随逗号(ES5 兼容) | | singleQuote | true | 使用单引号 | | printWidth | 100 | 每行最大字符数 | | tabWidth | 2 | 缩进空格数 | | useTabs | false | 使用空格缩进 | | endOfLine | 'lf' | 行尾符(LF) | | arrowParens | 'always' | 箭头函数参数始终加括号 | | bracketSpacing | true | 对象字面量括号内加空格 | | jsxSingleQuote | false | JSX 使用双引号 |

📝 Scripts 配置

package.json 中添加格式化脚本:

{
  "scripts": {
    "format": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md,yml,yaml}\"",
    "format:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,md,yml,yaml}\""
  }
}

🔧 自定义配置

扩展配置

import baseConfig from '@huaiyou/config-prettier';

export default {
  ...baseConfig,
  printWidth: 120, // 覆盖特定选项
};

忽略文件

创建 .prettierignore 文件:

# Dependencies
node_modules
pnpm-lock.yaml

# Build output
dist
build
.next
out

# Environment
.env
.env.local

🎨 编辑器集成

VSCode

安装 Prettier 扩展并在 .vscode/settings.json 中配置:

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true,
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescriptreact]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  }
}

WebStorm / IntelliJ IDEA

  1. 打开 Settings → Languages & Frameworks → JavaScript → Prettier
  2. 选择 Prettier package: node_modules/prettier
  3. 勾选 "On save" 和 "On code reformat"

🤝 与 ESLint 配合使用

本配置已经与 @huaiyou/config-eslint 完全兼容,不会产生规则冲突。

ESLint 负责代码质量检查,Prettier 负责代码格式化。

📄 License

MIT