操作员换行规则上的英语和漂亮冲突 [英] Eslint and prettier conflict on operator-linebreak rule
问题描述
我有一些附带和漂亮的配置.当我按ctrl + s保存我的代码时,我的eslint试图像这样格式化代码:
(errors.password&&(errors.password.type ==='minLength'||errors.password.type ==='maxLength')&&(< Styled.Error className ="invalidForm">密码必须大于6且小于32位数字</Styled.Error>))||(errors.password&&(< Styled.Error className ="invalidForm">密码是必需的</Styled.Error>))
并且在此之后还立即将代码格式化为:
(errors.password&(errors.password.type ==='minLength'||errors.password.type ==='maxLength')&&(< Styled.Error className ="invalidForm">密码必须大于6且小于32位数字</Styled.Error>))||(errors.password&&(< Styled.Error className ="invalidForm">密码是必需的</Styled.Error>))
我不想更改eslint规则,也不想禁用更漂亮的格式.如何更改用于放置逻辑运算符的更漂亮的规则?
根据更漂亮的 doc:
由于历史原因,更漂亮有一些选择.但是我们不想要更多. Prettier并非会尝试以您希望的任何方式打印您的代码的厨房水槽代码格式化程序.它是
被修饰的.
引用为什么更漂亮?页:到目前为止,采用Prettier的最大原因是停止所有有关样式的持续辩论.
Prettier附带了几种格式选项,其中一些是:>
- 标签宽度
- 标签
- 分号
- 行情
- 报价道具
- JSX报价
- 尾随逗号
但是这些选项不包括您要查找的内容.
I have some eslint and prettier config. When I hit ctrl + s to save my code my eslint is trying to format the code like this :
(errors.password
&& (errors.password.type === 'minLength'
|| errors.password.type === 'maxLength') && (
<Styled.Error className="invalidForm">
Password must be more than 6 and less then 32 digits
</Styled.Error>
))
|| (errors.password && (
<Styled.Error className="invalidForm">
Password is required
</Styled.Error>
))
and instantly after that prettier also format code to that:
(errors.password &&
(errors.password.type === 'minLength' ||
errors.password.type === 'maxLength') && (
<Styled.Error className="invalidForm">
Password must be more than 6 and less then 32 digits
</Styled.Error>
)) ||
(errors.password && (
<Styled.Error className="invalidForm">
Password is required
</Styled.Error>
))
I don't want to chage eslint rule, and I don't want to disable prettier format. How could I change the prettier rule for placing logic operators?
According to prettier doc:
Prettier has a few options because of history. But we don’t want more of them. Prettier is not a kitchen-sink code formatter that attempts to print your code in any way you wish. It is opinionated.
Quoting the Why Prettier? page: By far the biggest reason for adopting Prettier is to stop all the on-going debates over styles.
Prettier ships with a handful of format options, some of them are:
- Tab Width
- Tabs
- Semicolons
- Quotes
- Quote Props
- JSX Quotes
- Trailing Commas
But these options doesn't include what you are looking for.
这篇关于操作员换行规则上的英语和漂亮冲突的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!