[英]Prettier Pragma Support in non JS files
Adding "requirePragma": true
, to the prettier config makes it format a files that contain a special comment only.在更漂亮的配置中添加
"requirePragma": true
使其格式化仅包含特殊注释的文件。
Here is a special comment for .js and similar files, according to the docs :根据文档,这是.js和类似文件的特殊注释:
/**
* @prettier
*/
or或者
/**
* @format
*/
How to make such a comment in files, such as .html or .json , where comments of this kind are not allowed?如何在.html或.json等文件中进行此类注释,其中不允许此类注释?
For example <!-- @prettier -->
is not recognised as a special comment in .html files例如
<!-- @prettier -->
在.html文件中不被识别为特殊注释
For anyone ending up here in the future:对于将来在这里结束的任何人:
This appears to be partially solved today, but not for all formats.这似乎在今天得到了部分解决,但并非适用于所有格式。
<!-- @format -->
<!-- @format -->
<!-- @format -->
<!-- @format -->
# @format
# @format
JSON still doesn't get anything, which makes sense. JSON 仍然没有得到任何东西,这是有道理的。
The documentation doesn't mention this explicitly: https://prettier.io/docs/en/options.html#require-pragma文档没有明确提到这一点: https://prettier.io/docs/en/options.html#require-pragma
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.