![](/img/trans.png)
[英]How to prevent Prettier from breaking test code from 1 line to multiple lines
[英]How do you stop prettier or beautify breaking JS objects onto multiple lines?
我需要這個:
var short_sleeve = {
type: "Short Sleeve",
id: this.item.epos_code,
};
看起來像這樣:
var short_sleeve = { type: "Short Sleeve", id: this.item.epos_code, };
這是我的 prettierrc.json:
{
"bracketSpacing": false,
"endOfLine": "auto",
"printWidth": 300,
"proseWrap": "never",
"tabWidth": 4,
"trailingComma": "all",
"useTabs": true
}
這是我的 vs 代碼設置。json
{
"prettier.singleQuote": true,
"prettier.tabWidth": 4,
"editor.defaultFormatter": "esbenp.prettier-vscode",
"prettier.printWidth": 300,
"editor.formatOnSave": true,
"files.trimTrailingWhitespace": true,
"diffEditor.ignoreTrimWhitespace": false,
"prettier.proseWrap": "never",
"materialTheme.accent": "Acid Lime",
"twig-language.wrap": 100
}
我在這里嘗試過解決方案: Prettier from convert single line object declarations into multi line in Visual Studio Code? . 沒有什么
這與解決方案無關,因為 HTML 工作正常: 如何在 VS 代碼拆分屬性中停止 Prettier 到多行?
我玩過 printWidth,將其設置為 1000。沒什么。 我檢查過沒有安裝和運行其他格式化程序。 依然沒有。
不知道為什么它不會將較小的對象壓縮到一條線上。
這可能是因為您的printWidth
值非常大( "printWidth": 300
)
printWidth
指定打印機將換行的行長。 嘗試將值減小到類似"printWidth": 160
的值(默認值實際上是 80)
您可以在更漂亮的文檔選項頁面上閱讀更多相關信息
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.