eslint-plugin-react-native icon indicating copy to clipboard operation
eslint-plugin-react-native copied to clipboard

[no-inline-styles] ternary style gets mistakenly reported

Open uloco opened this issue 3 years ago • 3 comments

I get a warning on this inline style:

<View
  style={[
    styles.safeAreaTransparent,
    { height: props.insetsTop ? insets.top : 0, },  // <---- eslint(react-native/no-inline-styles)
  ]}
/>

Does this behaviour work as expected? If so, how should we change these?

I think it should not report as a warning though ...

uloco avatar May 13 '22 09:05 uloco

Yeah, all conditional expressions by default are considered invalid here. I think plugin should accept some pattern config to apply only certain validations and skip others.

nobi1007 avatar May 30 '22 06:05 nobi1007

I think it should be configureable, so that if there are variables in it, it should not report at all. Because it makes the code much more complicated with little benefit. If I am already using an inline style because of a conditional, I don't want to goo to the style definition and look up what style will be applied in the else case for example. But it totally makes sense for disabling inline styles in general for other cases

uloco avatar Jun 01 '22 07:06 uloco

I think the plugin should accept conditional expressions etc.

ridvanaltun avatar Oct 04 '22 10:10 ridvanaltun