{"action":"closed","issue":{"url":"https://api.github.com/repos/Intellicode/eslint-plugin-react-native/issues/15","repository_url":"https://api.github.com/repos/Intellicode/eslint-plugin-react-native","labels_url":"https://api.github.com/repos/Intellicode/eslint-plugin-react-native/issues/15/labels{/name}","comments_url":"https://api.github.com/repos/Intellicode/eslint-plugin-react-native/issues/15/comments","events_url":"https://api.github.com/repos/Intellicode/eslint-plugin-react-native/issues/15/events","html_url":"https://github.com/Intellicode/eslint-plugin-react-native/issues/15","id":144641141,"number":15,"title":"no-unused-styles doesn't work with functions and vars","user":{"login":"yelled3","id":818124,"avatar_url":"https://avatars.githubusercontent.com/u/818124?v=3","gravatar_id":"","url":"https://api.github.com/users/yelled3","html_url":"https://github.com/yelled3","followers_url":"https://api.github.com/users/yelled3/followers","following_url":"https://api.github.com/users/yelled3/following{/other_user}","gists_url":"https://api.github.com/users/yelled3/gists{/gist_id}","starred_url":"https://api.github.com/users/yelled3/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yelled3/subscriptions","organizations_url":"https://api.github.com/users/yelled3/orgs","repos_url":"https://api.github.com/users/yelled3/repos","events_url":"https://api.github.com/users/yelled3/events{/privacy}","received_events_url":"https://api.github.com/users/yelled3/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2016-03-30T16:12:53Z","updated_at":"2016-11-26T18:41:38Z","closed_at":"2016-11-26T18:41:38Z","body":"when I added the rule for `no-unused-styles` to my project I got many errors.\nmost of them were due to styles dynamically loaded from functions or vars.\n\nconsider the following use cases:\n\n``` js\nclass MyView extends Component {\n\n  static propTypes = {\n    isActive: React.PropTypes.bool,\n    type: React.PropTypes.oneOf(['typeA', 'typeB'])\n  };\n\n  get myActiveStyle() {\n     return this.props.isActive ? style.active : {}\n  }\n\n render() {\n    var typeStyle = styles[this.props.type];\n    return (\n      <View style={[this.activeStyle, typeStyle]} / >\n    );\n  }\n\n}\n\n// All 3 styles will be marked as unused\nconst styles = StyleSheet.create({\n   active: {...},\n   typeA: {...},\n   typeB: {...},\n})\n```\n\nmy current solution is to wrap the erroring code with:\n\n``` js\n/*eslint-disable react-native/no-unused-styles */\n const styles = StyleSheet.create({...});\n/*eslint-enable react-native/no-unused-styles */\n```\n\nThoughts?\n"}}
{"actor":{"display_login":"Intellicode"}}