Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
uloco opened this issue May 13, 2022 · 3 comments
Open

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

uloco opened this issue May 13, 2022 · 3 comments

Comments

@uloco
Copy link

uloco commented May 13, 2022

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
Copy link

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
Copy link
Author

uloco commented Jun 1, 2022

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
Copy link

I think the plugin should accept conditional expressions etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants