[英]Import statement automatically converted to multi-line in VSCODE
My VSCode editor automatically wraps import statements into new lines on save or format document:我的 VSCode 编辑器在保存或格式化文档时自动将导入语句包装到新行中:
After:后:
I don't want this behaviour.我不想要这种行为。 How to disable this rule?
如何禁用此规则?
I am programming in Angular 7 typescript and following extension is installed on it:我正在使用 Angular 7 打字稿进行编程,并在其上安装了以下扩展:
Please, help me to remove this rule or behavior.请帮助我删除此规则或行为。
Thank you.谢谢你。
You cannot disable prettier.printWidth, but you can increase the line-length until it so that it stops wrapping your imports.您不能禁用 prettier.printWidth,但您可以增加 line-length 直到它停止包装您的导入。
You can do this by opening (or creating) a file called prettier.rc in the root dir (one above /src in an Angular project) and adding the property:您可以通过在根目录(Angular 项目中 /src 上方的一个)中打开(或创建)一个名为 prettier.rc 的文件并添加属性来完成此操作:
"printWidth": 250
or whatever number is required.或任何需要的数字。
A word of warning: As the printWidth is a central theme of Prettier - as an opinionated formatter, what you are trying to do may not be the best option in the long-term.警告:由于 printWidth 是 Prettier 的中心主题 - 作为一个固执的格式化程序,从长远来看,您尝试做的事情可能不是最佳选择。
For Angular project, as opposed to using Prettier consider adding new rules to tslint or even creating custom rules where required.对于 Angular 项目,与使用 Prettier 不同,请考虑向 tslint 添加新规则,甚至在需要时创建自定义规则。
This is caused by Prettier. 这是由Prettier引起的。
I don't think you can disable this on its own (short of using a // prettier-ignore
comment above the import) but you can try increasing the line length at which prettier starts wrapping with the prettier.printWidth
setting 我不认为你可以自己禁用它(在导入之上使用
// prettier-ignore
注释)但你可以尝试使用prettier.printWidth
设置增加更漂亮的开始包装的行长度
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.