-
-
Notifications
You must be signed in to change notification settings - Fork 923
Labels
Description
Summary
The react/display-name rule with checkContextObjects: true fails to detect a missing displayName on a createContext call when a TypeScript interface or type in the same file shares the exact same name as the context variable.
Reproduction
Detected (different names):
import { createContext } from "react";
interface PostHogGroupContextValue {
value: string;
}
const PostHogGroupContext = createContext<PostHogGroupContextValue | null>(null);
// ^ eslint-plugin-react(display-name): Context definition is missing display name. ✅Not detected (same name):
import { createContext } from "react";
interface PostHogGroupContext {
value: string;
}
const PostHogGroupContext = createContext<PostHogGroupContext | null>(null);
// ^ No error reported ❌Expected behavior
The rule should report a missing displayName regardless of whether a same-named TypeScript interface/type exists. TypeScript interfaces exist in the type namespace and have no relation to React's runtime displayName property.
Config
{
"plugins": ["react"],
"rules": {
"react/display-name": ["error", { "checkContextObjects": true }]
}
}Environment
- oxlint v1.47.0
- macOS
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Fields
Give feedbackPriority
None yet
Effort
None yet