VSCode Prettier Format on Save 弄乱了格式 [英] VSCode Prettier Format on Save messes up formatting

查看:92
本文介绍了VSCode Prettier Format on Save 弄乱了格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来一直在使用 VSCode Prettier 格式的保存功能.

Been using VSCode Prettier format on save feature for a while.

最近不断地犯错误和错误的 Javascript 格式.

Lately is CONSTANTLY makes mistakes and misformats Javascript.

例如:

const foo = 123

[保存]

const foo = 1;23

我暂时禁用了它,但有什么方法可以避免这种情况发生吗?

I've disabled it for now, but is there some way to make this not happen?

推荐答案

我认为没有办法解决这个问题.我也在我的项目中使用 Prettier, 有时它很烦人.我不知道是否有这样的特定配置可以解决您的问题,但除了卸载或禁用扩展程序外,您无法做任何其他事情.

I do not think that there is a way to fix this. I also use Prettier on my projects, and YES sometimes it is annoying. I do not know if there are such specific configurations to solve your issue, but you cannot do anything else, except uninstalling or disabling the extension.

请记住,即使您不选择美化"您的代码保存,它也会在某个时候进行,唯一的选择是禁用它.

Remember, even if you do not choose to "prettify" your code on save, it will do it somewhen and the only option is to disable it.

更新 03-05-2020

您可以在文件或代码节点中使用注释 //prettier-ignore 来忽略 Prettier 格式.

You can use the comment // prettier-ignore in your files or nodes of code to ignore Prettier formatting.

参考资料示例:https://prettier.io/docs/en/ignore.html

这篇关于VSCode Prettier Format on Save 弄乱了格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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