![](/img/trans.png)
[英]Prettier breaks line in function definition when it has the type of returned function
[英]Is there a config in prettier to keep line breaks?
在 VS Code 中使用更漂亮的擴展有問題,當我寫這個時:
const result = await pool
.request()
.query('select NumberPlate, ID, TimeStamp from RESULTS order by ID');
並保存文件,它變成了這樣的一行:
const result = await pool.request().query('select NumberPlate, ID, TimeStamp from RESULTS order by ID');
使用更漂亮的以下配置:
{
"git.confirmSync": false,
"editor.minimap.enabled": false,
"window.zoomLevel": 0,
"liveServer.settings.donotShowInfoMsg": true,
"workbench.startupEditor": "newUntitledFile",
"terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
"editor.formatOnSave": true,
"prettier.printWidth": 200,
"prettier.singleQuote": true,
"prettier.arrowParens": "always",
"editor.tabSize": 2,
"editor.tabCompletion": "on"
}
有沒有辦法避免這種情況發生?
謝謝!
根據this Github issue並查看文檔,似乎無法將其配置為保持換行符。
但是,您可以設置一個非常短的printWidth
或在代碼上方放置// prettier-ignore
printWidth
// prettier-ignore
注釋。
沒有找到配置。 作為黑客,您可能希望在要中斷的第一行中包含注釋:
return ternaryExpression //
? trueResult
: falseResult;
您可以在此問題上表示支持-https: //github.com/prettier/prettier/issues/2550
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.