VS Code 格式更漂亮(参数前的新行) [英] Prettier in VS Code formatting (new lines before arguments)

查看:45
本文介绍了VS Code 格式更漂亮(参数前的新行)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 John Papa 的 Angular Essentials - 特别是, Tslint 和 Prettier.出于某种原因,它转换了这段代码

I'm using Angular Essentials by John Papa - in particular, Tslint and Prettier. For some reason, it transforms this code

this.rM.hA = this.rM.startHA + 2 * diffX * 360 / size;
this.rM.vA = Math.max(Math.min(this.rM.startVA + 2 * diffY * 180 / size, 90), -90);

进入这个

this.rM.hA =
  this.rM.startHA + 2 * diffX * 360 / size;
this.rM.vA = Math.max(
  Math.min(
    this.rM.startVA + 2 * diffY * 180 / size,
    90
  ),
  -90
);

我怎样才能避免它?我尝试使用 tslint.json 设置:

How can i avoid it? I've tried to play with tslint.json settings:

"max-line-length": [true, 165]

"max-line-length": [true, 165]

但这一点对我来说没有影响.

But that one does not affect in my case.

如下类似问题我试图同时设置 "prettier.printWidth""editor.wordWrap",但它们都没有帮助.正如@ConnorsFan 所建议的,我已经删除了 max-line-length,并且我当前的工作区设置(应该覆盖用户设置,对吗?)是

as following the similar issue I've tried to set both "prettier.printWidth" and "editor.wordWrap", but none of them helped. I've removed max-line-length, as suggested by @ConnorsFan, and my current Workspace Settings (which should override Users Settings, right?) is

{
"prettier.printWidth": 180,
"editor.wordWrap": "有界",
editor.wordWrapColumn":180}

{
"prettier.printWidth": 180,
"editor.wordWrap": "bounded",
"editor.wordWrapColumn": 180 }

看来,问题是由 Prettier 扩展引起的(作为 Angular Essentials 的依赖项).现在问题缩小了,为什么 "prettier.printWidth": 180 不起作用.我打开了一个问题 https://github.com/prettier/prettier/issues/3228

it appears, problem is caused by Prettier extension (comes as dependency for Angular Essentials). Now the problem is narrowed to realize, why "prettier.printWidth": 180 is not working. I've opened an issue https://github.com/prettier/prettier/issues/3228

PS:名称已更改以保护无辜者.(c)

PS: The names have been changed to protect the innocent. (c)

推荐答案

"prettier.printWidth": 120 为我工作,只有两个 javascript 格式扩展 'Prettier' &我的 vscode 中的ESlint".

"prettier.printWidth": 120 worked for me with only having two javascript format extensions 'Prettier' & 'ESlint' in my vscode.

这篇关于VS Code 格式更漂亮(参数前的新行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆