{"action":"created","issue":{"url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/855","repository_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react","labels_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/855/labels{/name}","comments_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/855/comments","events_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/855/events","html_url":"https://github.com/yannickcr/eslint-plugin-react/issues/855","id":178065605,"number":855,"title":"[no-unused-prop-types] False warning when used in external function","user":{"login":"tleunen","id":1972567,"avatar_url":"https://avatars.githubusercontent.com/u/1972567?v=3","gravatar_id":"","url":"https://api.github.com/users/tleunen","html_url":"https://github.com/tleunen","followers_url":"https://api.github.com/users/tleunen/followers","following_url":"https://api.github.com/users/tleunen/following{/other_user}","gists_url":"https://api.github.com/users/tleunen/gists{/gist_id}","starred_url":"https://api.github.com/users/tleunen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tleunen/subscriptions","organizations_url":"https://api.github.com/users/tleunen/orgs","repos_url":"https://api.github.com/users/tleunen/repos","events_url":"https://api.github.com/users/tleunen/events{/privacy}","received_events_url":"https://api.github.com/users/tleunen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-09-20T13:51:01Z","updated_at":"2016-09-30T22:50:33Z","closed_at":null,"body":"When a prop is not directly use in the class, but outside of it in an external function, the linter shows a warning.\r\n\r\nHere's an example:\r\n\r\n```jsx\r\nconst propTypes = {\r\n    testProp: PropTypes.string,\r\n    content: PropTypes.string,\r\n};\r\n\r\nfunction initState(props) {\r\n    return {\r\n        className: `yolo-${props.testProp}`,\r\n    };\r\n}\r\n\r\nexport default class Test extends React.PureComponent {\r\n    constructor(props) {\r\n        super(props);\r\n        this.state = initState(props);\r\n    }\r\n\r\n    render() {\r\n        return <div className={this.state.className}>{this.props.content}</div>;\r\n    }\r\n\r\n}\r\nTest.propTypes = propTypes;\r\n```"},"comment":{"url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/comments/250870028","html_url":"https://github.com/yannickcr/eslint-plugin-react/issues/855#issuecomment-250870028","issue_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/855","id":250870028,"user":{"login":"EvNaverniouk","id":226640,"avatar_url":"https://avatars.githubusercontent.com/u/226640?v=3","gravatar_id":"","url":"https://api.github.com/users/EvNaverniouk","html_url":"https://github.com/EvNaverniouk","followers_url":"https://api.github.com/users/EvNaverniouk/followers","following_url":"https://api.github.com/users/EvNaverniouk/following{/other_user}","gists_url":"https://api.github.com/users/EvNaverniouk/gists{/gist_id}","starred_url":"https://api.github.com/users/EvNaverniouk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/EvNaverniouk/subscriptions","organizations_url":"https://api.github.com/users/EvNaverniouk/orgs","repos_url":"https://api.github.com/users/EvNaverniouk/repos","events_url":"https://api.github.com/users/EvNaverniouk/events{/privacy}","received_events_url":"https://api.github.com/users/EvNaverniouk/received_events","type":"User","site_admin":false},"created_at":"2016-09-30T22:50:33Z","updated_at":"2016-09-30T22:50:33Z","body":"Before I look into fixing this, out of curiosity, why are you using this pattern for PropType declaration? Why a separate `propTypes` constant? It's only used in once place.\r\n\r\nI worry about how deep we'll have to scan for props variable re-declarations to properly account for this. For example, you could also theoretically write this code:\r\n\r\n```\r\nconst propTypes = {something: PropTypes.string);\r\nconst nestedPropTypes = propTypes;\r\nMyComponent.propTypes = nestedPropTypes;\r\n```\r\n\r\nChecking for this would require making several hops across multiple variables to detect where the prop types are actually defined."}}
{"actor":{"display_login":"EvNaverniouk"}}