jsx-eslint/eslint-plugin-react

[Bug]: [react/prop-types] False positive when using `FC`-derived custom type for Functional Components

Open

#3,873 opened on Jan 7, 2025

View on GitHub
 (3 comments) (0 reactions) (0 assignees)JavaScript (2,797 forks)batch import
enhancementhelp wanted

Repository metrics

Stars
 (8,630 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

Is there an existing issue for this?

  • I have searched the existing issues and my issue is unique
  • My issue appears in the command-line and not only in the text editor

Description Overview

Creating a type alias for a functional component will result in false positive for rule react/prop-types

Minimal Reproduction

import { FC } from "react";

type XFC = FC<{ user: string }>;

export const MyComponent: XFC = ({ user }) => {  // ERROR: react/prop-types
    // ...
};
import { FC } from "react";

export const MyComponent: FC<{ user: string }> = ({ user }) => {  // OK
    // ...
};

Expected Behavior

There should be no ESLint error

eslint-plugin-react version

v7.37.3

eslint version

v9.17.0

node version

v22.12.0

Contributor guide