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

no-unused-styles doesn't support conditional styles

Open robcalcroft opened this issue 8 years ago • 1 comments

I often add conditional styles to my components and no-unused-styles doesn't see that the style is actually used in the code.

const styles = StyleSheet.create({
  container: {
    padding: 1,
  },
  'container--critical': {
    backgroundColor: MY_RED_CONST,
  },
});

const Component = ({ shouldBeRed }) => (
  <View style={[styles.container].concat(shouldBeRed ? styles['container--critical'] : [])}>
    <Text>This is some text</Text>
  </View>
);

robcalcroft avatar Feb 14 '17 14:02 robcalcroft

Thanks for reporting, feel free to open a PR or wait until I have time to look into it :)

Intellicode avatar Feb 15 '17 20:02 Intellicode