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

@tker/prettier-config

v2.0.0

Published

共享的 Prettier 配置包,提供统一的代码格式化规则。

Readme

@tker/prettier-config

共享的 Prettier 配置包,提供统一的代码格式化规则。

安装

pnpm add -D @tker/prettier-config prettier

使用方式

package.json 方式

package.json 中添加:

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

配置文件方式

创建 prettier.config.js.prettierrc.js

import config from '@tker/prettier-config'
export default config

自定义配置

扩展或覆盖默认配置:

import baseConfig from '@tker/prettier-config'

export default {
  ...baseConfig,
  // 覆盖规则
  printWidth: 100,
  // 添加自定义规则
  overrides: [
    ...baseConfig.overrides,
    {
      files: '*.md',
      options: {
        proseWrap: 'always'
      }
    }
  ]
}

配置规则

| 选项 | 值 | 说明 | |------|-----|------| | printWidth | 80 | 每行最大字符数 | | tabWidth | 4 | 缩进空格数 | | useTabs | false | 使用空格缩进 | | semi | true | 语句末尾分号 | | singleQuote | false | 使用双引号 | | jsxSingleQuote | false | JSX 使用双引号 | | trailingComma | 'all' | 尽可能使用尾逗号 | | bracketSpacing | true | 对象字面量空格 | | arrowParens | 'always' | 箭头函数参数括号 | | endOfLine | 'auto' | 行尾格式自动 | | proseWrap | 'never' | 文本不换行 |

JSON5 特殊配置

overrides: [
  {
    files: ['*.json5'],
    options: {
      quoteProps: 'preserve',
      singleQuote: false
    }
  }
]

配合 ESLint 使用

建议同时使用 @tker/eslint-config,它已集成 Prettier 检查:

pnpm add -D @tker/eslint-config @tker/prettier-config

格式问题会通过 ESLint 报告,无需单独运行 Prettier 检查。

编辑器集成

VS Code

安装 Prettier 扩展,配置 .vscode/settings.json

{
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true
}

WebStorm / IntelliJ

在设置中启用 Prettier:

  1. Preferences → Languages & Frameworks → JavaScript → Prettier
  2. Prettier package: 选择项目中的 prettier
  3. 配置文件: 选择 @tker/prettier-config

运行格式化

# 格式化所有文件
prettier --write .

# 格式化特定文件
prettier --write "src/**/*.ts"

# 检查格式(不修改)
prettier --check .

License

MIT