jsx-eslint / eslint-plugin-react

React-specific linting rules for ESLint
MIT License
8.99k stars 2.77k forks source link

react/function-component-definition false positives on uncapitalized functions #3495

Open Janpot opened 1 year ago

Janpot commented 1 year ago

v7.31.10 => v7.31.11: upgrade results in a several false positives where uncapitalized functions that have a property assigned of either propTypes or defaultProps are detected as React components. (https://app.circleci.com/pipelines/github/mui/material-ui/85664/workflows/ddd6c2d7-00bc-4faf-bd09-f870eb96be44/jobs/452797) This is new behavior. Not sure if intended?

example:

// Function component is not a function declaration
const fn = () => 'foo'
fn.propTypes = {}
ljharb commented 1 year ago

Other than the identifier not being capitalized, that’s a react component, and the propTypes makes it a certainty. Why would anything that’s not a React component have propTypes??