简体   繁体   English

什么是更漂亮的文件注释?

[英]What is the prettier file annotation for?

I have seen some React files that start with:我见过一些以以下开头的 React 文件:

/**
 * @prettier
 */

What is the intention of this?这样做的意图是什么?

The term is called a pragma该术语称为pragma

Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file. Prettier 可以将自身限制为仅在文件顶部包含称为 pragma 的特殊注释的格式文件。 This is very useful when gradually transitioning large, unformatted codebases to prettier.当逐渐将大型未格式化的代码库转换为更漂亮的代码时,这非常有用。

Require pragma需要编译指示

Prettier can restrict itself to only format files that contain a special comment, called a pragma, at the top of the file. Prettier 可以将自身限制为仅在文件顶部包含称为 pragma 的特殊注释的格式文件。 This is very useful when gradually transitioning large, unformatted codebases to prettier.当逐渐将大型未格式化的代码库转换为更漂亮的代码时,这非常有用。

For example, a file with the following as its first comment will be formatted when --require-pragma is supplied:例如,当提供 --require-pragma 时,将格式化具有以下内容作为其第一条注释的文件:

/**
 * @prettier
 */

or或者

/**
 * @format
 */

API Override: API 覆盖:

requirePragma: <bool>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM