简体   繁体   English

`[react/jsx-max-props-per-line]` eslint 规则,复合设置

[英]`[react/jsx-max-props-per-line]` eslint rule, compound settings

I'm looking at adding [react/jsx-max-props-per-line] to my config based on a request from the devs and I'm trying to find out...我正在考虑根据开发人员的请求将[react/jsx-max-props-per-line]到我的配置中,我试图找出...

Is there a way to have a rule that applies on when: multiline and another on when: always ?有没有办法让规则适用于when: multiline和另一个适用于when: always

I'm wanting a maximum of five when we are within the always and a max of one on the multiline.当我们在always内时,我maximum需要五个,而在多行中最多需要one

No there is currently no way to use the rule the way you want.不,目前无法以您想要的方式使用规则。 This feature request is being tracked in the following issue:正在以下问题中跟踪此功能请求:

https://github.com/yannickcr/eslint-plugin-react/issues/2735https://github.com/yannickcr/eslint-plugin-react/issues/2735

But for your specific case you can try using prettier .但是对于您的特定情况,您可以尝试使用prettier It enforces maximum 1 prop per line in case of multi-line tags.在多行标签的情况下,每行最多强制执行 1 个道具。 And with its printWidth property you may get similar effect to around 5 props.使用它的printWidth属性,您可以获得与大约 5 个道具类似的效果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM