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

accessing styles using bracket notation counts as a failure

Open beeglebug opened this issue 7 years ago • 1 comments

I would expect the following to pass, but it does not.

const styles = StyleSheet.create({
  foo: { /* styles */ }
})

() => {
  const bar = 'foo'
  return <View style={styles[bar]} />
}

beeglebug avatar Dec 07 '17 10:12 beeglebug

hi @beeglebug, in this case it might be possible to inline the key, but for more complex cases where bar is dynamic it will be hard to infer which styles are referenced. In these cases you might want to disable the rule for that specific line

Intellicode avatar Dec 08 '17 22:12 Intellicode