gpt4 book ai didi

javascript - 更漂亮 : prevent Prettier of removing parentheses

转载 作者:行者123 更新时间:2023-12-05 00:25:32 26 4
gpt4 key购买 nike

我在 react 原生项目的 VSCode 中使用 prettier,它删除了混合运算符中的括号或使用括号声明 var 时。如何防止 prettier 这样做
示例 1:

 const foo = (a && b) || c;

After:

const foo = a && b || c;
示例2
const c = (a.toString()).toUpperCase();

After:

const c = a.toString().toUpperCase();
我知道在大多数情况下它不会改变逻辑,但我想禁用此功能。

最佳答案

您可以使用“prettier-ignore”注释来忽略部分文件。
喜欢//更漂亮 - 忽略
这里有一个文档链接:https://prettier.io/docs/en/ignore.html

关于javascript - 更漂亮 : prevent Prettier of removing parentheses,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68587819/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com