块编辑器开发文档

@wordpress/prettier-config

💡 云策文档标注

概述

本文档介绍了 WordPress 的 Prettier 可共享配置包 @wordpress/prettier-config,用于统一代码格式化。它提供了安装、使用和贡献指南,适用于 WordPress 开发者。

关键要点

  • 安装方式:通过 npm install @wordpress/prettier-config --save-dev 安装,要求 Node.js 长期支持版本。
  • 使用方法:可在 package.json、.prettierrc 或 .prettierrc.js 文件中配置为 "@wordpress/prettier-config"。
  • 项目背景:此包是 Gutenberg 项目的一部分,采用 monorepo 结构,用于 WordPress 和其他软件项目。

📄 原文内容

WordPress Prettier shareable config for Prettier.

Installation

Install the module

$ npm install @wordpress/prettier-config --save-dev

Note: This package requires Node.js version with long-term support status (check Active LTS or Maintenance LTS releases). It is not compatible with older versions.

Usage

Add this to your package.json file:

"prettier": "@wordpress/prettier-config"

Alternatively, add this to .prettierrc file:

"@wordpress/prettier-config"

Or add this to .prettierrc.js file:

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

Contributing to this package

This is an individual package that’s part of the Gutenberg project. The project is organized as a monorepo. It’s made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to npm and used by WordPress as well as other software projects.

To find out more about contributing to this package or Gutenberg as a whole, please read the project’s main contributor guide.