{"action":"created","issue":{"url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/976","repository_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react","labels_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/976/labels{/name}","comments_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/976/comments","events_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/976/events","html_url":"https://github.com/yannickcr/eslint-plugin-react/issues/976","id":191738324,"number":976,"title":"Consider deprecating `no-unused-prop-types` rule ","user":{"login":"EvNaverniouk","id":226640,"avatar_url":"https://avatars0.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},"labels":[{"id":157842412,"url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/labels/question","name":"question","color":"cc317c","default":true}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-11-25T16:43:46Z","updated_at":"2017-06-23T21:31:19Z","closed_at":"2017-02-07T20:53:55Z","body":"I wrote the `no-unused-prop-types` rule which was merged into `eslint-plugin-react` in `v6.2.0`. Thanks for accepting it and letting me contribute to this project. I've been using this rule for many different projects with some success. However, after some more careful analysis, I am now fairly convinced that we should remove it.\r\n\r\nAlthough it's very useful and can definitely help detect dead code, it's highly prone to false positives as seen via: #628, #811, #816, #819, #833, #879, #880, #884, #885, #944, #974 and many more.\r\n\r\nI've taken a stab last week to improve the rule to fix the false positives, but it ultimately led me to the realization that in order to truly fix them, we would need to update the rule to fully track the use of props across all functions in the file. This is an incredibly difficult task given the plethora of ways that arguments can be passed into functions. Consider this worst case scenario:\r\n\r\n```javascript\r\nclass MyComponent extends Component {\r\n    static propTypes = {\r\n        // This is the prop that we want to make sure is tracked\r\n        myProp: PropTypes.string\r\n    }\r\n\r\n    constructor (props) {\r\n        super(props);\r\n\r\n        // All props are passed to some class function. Technically `myProp`\r\n        // isn't considered used yet. It's also not calling the function directly\r\n        // but using `bind()` instead for extra complexity.\r\n        this.doSomething.bind(this, props);\r\n    }\r\n    \r\n    doSomething (props) {\r\n        // This class function doesn't use `myProp` directly either, and also passes\r\n        // `props` to some external function.\r\n        doAnotherThing(props);\r\n    }\r\n}\r\n\r\n// This function isn't even part of the component anymore\r\n// and uses object destructuring to break up the props\r\nconst doAnotherThing = ({myProp}) => {\r\n    // Finally the prop is used\r\n    console.log(myProp);\r\n};\r\n```\r\n\r\nIn order to properly mark `myProp` as used in this case, I need to track the movement of `props` all the way from the `constructor`, into `doSomething` (via `bind`), then into `doAnotherThing` while being destructured (and outside the original component), and finally then I can check if a specific prop is used.\r\n\r\nNow you have to do this for every prop in every component of your code. The ESLint rule that would support this tracking is hugely complicated and super slow. I don't think it's worth the benefits of us going down this path.\r\n\r\nBut unless we venture down this road and do it right, we will always have false positives reported.\r\n\r\n@yannickcr @lencioni @ljharb Thoughts?"},"comment":{"url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/comments/310777766","html_url":"https://github.com/yannickcr/eslint-plugin-react/issues/976#issuecomment-310777766","issue_url":"https://api.github.com/repos/yannickcr/eslint-plugin-react/issues/976","id":310777766,"user":{"login":"TrevorSayre","id":421548,"avatar_url":"https://avatars2.githubusercontent.com/u/421548?v=3","gravatar_id":"","url":"https://api.github.com/users/TrevorSayre","html_url":"https://github.com/TrevorSayre","followers_url":"https://api.github.com/users/TrevorSayre/followers","following_url":"https://api.github.com/users/TrevorSayre/following{/other_user}","gists_url":"https://api.github.com/users/TrevorSayre/gists{/gist_id}","starred_url":"https://api.github.com/users/TrevorSayre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TrevorSayre/subscriptions","organizations_url":"https://api.github.com/users/TrevorSayre/orgs","repos_url":"https://api.github.com/users/TrevorSayre/repos","events_url":"https://api.github.com/users/TrevorSayre/events{/privacy}","received_events_url":"https://api.github.com/users/TrevorSayre/received_events","type":"User","site_admin":false},"created_at":"2017-06-23T21:31:19Z","updated_at":"2017-06-23T21:31:19Z","body":"```jsx\r\nexport default class Users extends Component {\r\n\r\n  static propTypes = {\r\n    ...\r\n    onLoad: PropTypes.func.isRequired,\r\n  };\r\n\r\n  async componentWillMount() {\r\n    await Promise.all([\r\n      this.props.onLoad(),\r\n      this.onSearch(),\r\n    ]);\r\n    ...\r\n  }\r\n\r\n  ...\r\n\r\n}\r\n```\r\n\r\n`'onLoad' PropType is defined but prop is never used (react/no-unused-prop-types)`"}}
{"actor":{"display_login":"TrevorSayre"}}