# @btmills/prettier 中文文档

规范地址：https://npmcn.com/package/%40btmills/prettier/

版本：3\.3\.3
npm 元数据更新时间：2024-07-28T21:31:56.984Z
中文译文更新时间：2026-11-08T17:33:54.275Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40btmills/prettier
原文对照：https://npmcn.com/package/%40btmills/prettier/?lang=original
项目主页：https://prettier.io/
源码仓库：https://github.com/btmills/prettier

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：7.7 MB，53 个文件
- 模块格式：ESM + CJS
- TypeScript 类型：包内自带
- Node.js 要求：\>=14
- 运行依赖：0 个
- 首次发布：2018-11-02T05:12:30.085Z
- 最新版本发布：2024-07-28T21:31:56.777Z
- 近 30 天下载量：15112（2026-10-09 至 2026-11-07，npm 官方下载统计）
- 已发布版本数：65（近 12 个月 0 个）

## 中文简介

Pretier 是一个有观点的代码

## 安装

```sh
npm install @btmills/prettier
```

也可以使用：`pnpm add @btmills/prettier`、`yarn add @btmills/prettier`、`bun add @btmills/prettier`

## README

# :叉 和 刀:这是叉.

比较 `prettier`, (中文(简体) ), `@btmills/prettier` 将二进制运算符移动到长表达式中的新行开头,而不是上行的结尾。 就是这样.

```js
// prettier:
const before =
  bom.length >= 2 &&
  ((bom.charCodeAt(0) === 0xff && bom.charCodeAt(1) === 0xfe) ||
    (bom.charCodeAt(0) === 0xfe && bom.charCodeAt(1) === 0xff));

// @btmills/prettier:
const after =
  bom.length >= 2
  && ((bom.charCodeAt(0) === 0xff && bom.charCodeAt(1) === 0xfe)
    || (bom.charCodeAt(0) === 0xfe && bom.charCodeAt(1) === 0xff));
```

## 使用量

使用别名安装( I)[无](https://docs.npmjs.com/cli/v8/commands/npm-install), (中文(简体) ), [线条](https://yarnpkg.com/lang/en/docs/cli/add/#toc-yarn-add-alias)所以,这样 `require('prettier')` 透明地决定了这个分叉:

```sh
npm install --save-dev prettier@npm:@btmills/prettier
yarn add --dev prettier@npm:@btmills/prettier
```

此软件包将像 `prettier`,编辑集成器应该用它来当真.

## 释放

叉套件的放出是通过重置 `line-before-operator` 在最近版本标签上方的分支 `main`。 。 。 .

```sh
# Get the latest changes and update the main branch:
git checkout main
git pull
git push fork

# Rebase the release branch on the latest version:
git checkout line-before-operator
git rebase x.y.z

# Fix conflicts as necessary.
git rebase --continue
# There will be a merge conflict in `yarn.lock`. To resolve it:
yarn && yarn dedupe && yarn dedupe --check
# If any conflicts in snapshots, discard and update automatically:
yarn test -u

# With rebasing done, run tests, push tags, build, and publish:
yarn run lint
yarn test
git tag x.y.z-fork
git push --force-with-lease
git push --tags
yarn run build
yarn run test:dist
cd dist
npm publish
```

[![Prettier Banner](https://unpkg.com/prettier-logo@1.0.3/images/prettier-banner-light.svg)](https://prettier.io/)

## 预览代码

_Java 脚本 类型脚本 流动 联合来文X • JSON_  
_支助科 • 常设委员会 减_  
_HTML 语言 · 韦 角 角_  
_图QL 降级 - 也门_  
_[你最喜欢的语言?](https://prettier.io/docs/en/plugins.html)_

[![Github Actions Build Status](https://img.shields.io/github/actions/workflow/status/prettier/prettier/prod-test.yml?label=Prod&style=flat-square)](https://github.com/prettier/prettier/actions?query=workflow%3AProd+branch%3Amain) [![Github Actions Build Status](https://img.shields.io/github/actions/workflow/status/prettier/prettier/dev-test.yml?label=Dev&style=flat-square)](https://github.com/prettier/prettier/actions?query=workflow%3ADev+branch%3Amain) [![Github Actions Build Status](https://img.shields.io/github/actions/workflow/status/prettier/prettier/lint.yml?label=Lint&style=flat-square)](https://github.com/prettier/prettier/actions?query=workflow%3ALint+branch%3Amain) [![Codecov Coverage Status](https://img.shields.io/codecov/c/github/prettier/prettier.svg?style=flat-square)](https://codecov.io/gh/prettier/prettier) [![Blazing Fast](https://img.shields.io/badge/speed-blazing%20%F0%9F%94%A5-brightgreen.svg?style=flat-square)](https://twitter.com/acdlite/status/974390255393505280)  
[![npm version](https://img.shields.io/npm/v/prettier.svg?style=flat-square)](https://www.npmjs.com/package/prettier) [![weekly downloads from npm](https://img.shields.io/npm/dw/prettier.svg?style=flat-square)](https://www.npmjs.com/package/prettier) [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://npmcn.com/package/%40btmills/prettier/#readme-badge) [![Follow Prettier on Twitter](https://img.shields.io/badge/%40PrettierCode-9f9f9f?style=flat-square&logo=x&labelColor=555)](https://twitter.com/PrettierCode)

## 介绍

Pretier是一个有观点的代码 对于物质。 它通过解析你的代码并用自己的规则重新打印来执行一个一致的样式,这些规则考虑到了最大行长,必要时会包接代码.

### 投入

```js
foo(reallyLongArg(), omgSoManyParameters(), IShouldRefactorThis(), isThereSeriouslyAnotherOne());
```

### 产出

```js
foo(
  reallyLongArg(),
  omgSoManyParameters(),
  IShouldRefactorThis(),
  isThereSeriouslyAnotherOne(),
);
```

Pretier 可以运行 [在编辑器中](https://prettier.io/docs/en/editors.html) 保存,在一个 [承诺前钩](https://prettier.io/docs/en/precommit.html),或在 [CI 环境](https://prettier.io/docs/en/cli.html#list-different) 保证你的代码库有一致的风格 不再让devs在代码审查上贴出一首非选评论!

* * *

**[文档](https://prettier.io/docs/en/)**

[安装](https://prettier.io/docs/en/install.html) • 妇女 [选项](https://prettier.io/docs/en/options.html) • 妇女 [国 际](https://prettier.io/docs/en/cli.html) • 妇女 [API 密码](https://prettier.io/docs/en/api.html)

**[游戏场](https://prettier.io/playground/)**

* * *

## 徽标

向世界展示你的用法 _高级_ → [![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)

```md
[![code style: prettier](https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square)](https://github.com/prettier/prettier)
```

## 捐款

见 [捐款额](https://npmcn.com/package/%40btmills/prettier/CONTRIBUTING.md)。 。 。 .

## 常见问题

### @btmills/prettier 是什么？

Pretier 是一个有观点的代码

### 如何安装 @btmills/prettier？

在项目目录运行 npm install @btmills/prettier，或使用 pnpm add / yarn add / bun add。它还提供命令行工具 prettier，可以用 npx prettier 直接运行。

### @btmills/prettier 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @btmills/prettier 支持 ESM 还是 CommonJS？

同时提供 ES Module 与 CommonJS 入口，import 和 require\(\) 都可以使用，打包工具会自动选择合适的版本。

### @btmills/prettier 需要什么版本的 Node\.js？

package\.json 的 engines 字段要求 Node\.js \>=14。版本不符时 npm 默认只给出警告，开启 engine-strict 后会拒绝安装。

### @btmills/prettier 可以商用吗？

@btmills/prettier 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @btmills/prettier 的下载量有多少？

根据 npm 官方下载统计，@btmills/prettier 在 2026/10/09 – 2026/11/07 这 30 天内被下载 15,112 次，日均约 504 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @btmills/prettier 还在维护吗？

最新版本 3\.3\.3 发布于 2024/07/29（2 年前）；至今共发布 65 个版本，其中过去 12 个月发布了 0 个；首次发布于 2018/11/02。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

