Skip to content

prop-types validation doesn't run for every stateless component #1046

@prithsharma

Description

@prithsharma

Test case -
If a function is of the form

() => {
  return <some_jsx />;
}

the prop-types rule is checked as expected.

But if the function is of the form

() => {
  const returnValue = <some_jsx />;
  return returnValue;
}

it seems the the prop-types rule is not checked and no lint errors are thrown if there are no propType validations.

Possible reason - Referring to this comment, I think the plugin identifies a function as a React component if it returns some JSX. In the case above, the plugin somehow fails to identify it as returning some JSX.

Activity

added 2 commits that reference this issue on Feb 3, 2022
5989a99
1cca82f

35 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ljharb@prithsharma

        Issue actions

          prop-types validation doesn't run for every stateless component · Issue #1046 · jsx-eslint/eslint-plugin-react