[英]Prettier : prevent Prettier of removing parentheses
I'm using prettier in VSCode on a react native project and it removes parentheses in mixed operators or when declaring a var with a parenthesis.我在一个 React Native 项目的 VSCode 中使用了 prettier,它删除了混合运算符中的括号,或者在用括号声明 var 时删除了括号。 How to prevent prettier from doing that
如何防止 prettier 这样做
example1:示例 1:
const foo = (a && b) || c;
After:
const foo = a && b || c;
example2例子2
const c = (a.toString()).toUpperCase();
After:
const c = a.toString().toUpperCase();
I know that in most cases it doesn't change the logic but I want to disable this feature.我知道在大多数情况下它不会改变逻辑,但我想禁用此功能。
You can use “prettier-ignore” comments to ignore parts of files.您可以使用“prettier-ignore”注释来忽略部分文件。 Like // prettier-ignore
喜欢//更漂亮-忽略
Here you have a link to documentation: https://prettier.io/docs/en/ignore.html这里有文档链接: https://prettier.io/docs/en/ignore.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.