gpt4 book ai didi

javascript - Prettier - HTML 和 JS 的配置

转载 作者:行者123 更新时间:2023-12-03 08:18:29 25 4
gpt4 key购买 nike

我想在一个配置文件 .prettierrc 中指定 HTML 和 JS 的字符串长度。

 module.exports = {
singleQuote: true,
printWidth: 80,
[HTML]: {
printWidth: 150,
},
};

但在日志中我得到:

ReferenceError: HTML is not defined

最佳答案

您应该使用 .prettierrc 格式,当您使用此格式时,Visual Studio Code 还将提供智能感知。

您收到错误的原因是:

  • 文件需要采用 JSON 格式,
  • 任何覆盖都需要在 overrides JSON 键下指定

在您的情况下,文件应如下所示:

.prettierrc

{
"singleQuote": true,
"printWidth": 80,
"overrides": [
{
"files": ["**/*.html"],
"options": {
"printWidth": 150
}
}
]
}

关于javascript - Prettier - HTML 和 JS 的配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68611031/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com