{"record":{"id":"c5bcc0ff86daa14e","repo":"oxc-project/oxc","slug":"context-definition-is-missing-display-name","errorCode":null,"errorMessage":"Context definition is missing display name.","messagePattern":"Context definition is missing display name\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/display_name.rs","lineNumber":36,"sourceCode":"use crate::{\n    ast_util::iter_outer_expressions,\n    config::ReactVersion,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::{\n        InnermostFunction, arrow_function_returns, expression_returns,\n        find_innermost_function_with_jsx, function_returns, is_hoc_call, is_react_component_name,\n    },\n};\n\nfn component_display_name_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Component definition is missing display name.\")\n        .with_help(\"Add a `displayName` property to the component.\")\n        .with_label(span)\n}\n\nfn context_display_name_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Context definition is missing display name.\")\n        .with_help(\"Add a `displayName` property to the context.\")\n        .with_label(span)\n}\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Enforces that React components have a `displayName` property.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// React DevTools uses `displayName` to show component names in the component tree.\n    /// Without `displayName`, components will show up as \"Unknown\" in DevTools.\n    ///\n    /// ### Examples\n    ///\n    /// Examples of **incorrect** code for this rule:\n    /// ```jsx","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/display_name.rs#L18-L54","documentation":"Raised by react/display-name when a React context created via React.createContext is assigned without a displayName property. Contexts lack an inferred name, making them hard to identify in React DevTools.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/display_name.rs:36 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set MyContext.displayName = \"MyContext\" after creation.","Assign the context to a named variable so DevTools can infer the name, or add the displayName property."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}