![](/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.