Intellicode / eslint-plugin-react-native

React Native plugin for ESLint
MIT License
722 stars 130 forks source link

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

Open uloco opened 2 years ago

uloco commented 2 years ago

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 ...

nobi1007 commented 2 years ago

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.

uloco commented 2 years ago

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

ridvanaltun commented 2 years ago

I think the plugin should accept conditional expressions etc.