{"record":{"id":"5cae602f11e29c99","repo":"oxc-project/oxc","slug":"element-is-forbidden","errorCode":null,"errorMessage":"<{element}> is forbidden.","messagePattern":"<(.+?)> is forbidden\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/forbid_elements.rs","lineNumber":23,"sourceCode":"use oxc_str::CompactStr;\nuse rustc_hash::FxHashMap;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::{DefaultRuleConfig, Rule},\n    utils::{get_element_type, is_react_function_call},\n};\n\nfn forbid_elements_diagnostic(\n    element: &str,\n    help: Option<&CompactStr>,\n    span: Span,\n) -> OxcDiagnostic {\n    if let Some(help) = help {\n        return OxcDiagnostic::warn(format!(\"<{element}> is forbidden.\"))\n            .with_help(help.to_string())\n            .with_label(span);\n    }\n\n    OxcDiagnostic::warn(format!(\"<{element}> is forbidden.\")).with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize, JsonSchema)]\n#[serde(from = \"ForbidElementsConfig\")]\npub struct ForbidElements {\n    // Map from element name to optional message for diagnostics.\n    forbid: Box<FxHashMap<CompactStr, Option<CompactStr>>>,\n}\n\nimpl From<ForbidElementsConfig> for ForbidElements {\n    fn from(config: ForbidElementsConfig) -> Self {\n        // Convert Vec to FxHashMap.\n        // Later entries will override earlier ones for duplicates.","sourceCodeStart":5,"sourceCodeEnd":41,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/forbid_elements.rs#L5-L41","documentation":"Raised by react/forbid_elements when a JSX element or React.createElement tag name matches the rule's `forbid` configuration. At the throw site the element is one the project disallows (e.g. `<h1>`, `<img>`, or a component enforcing alternatives). The optional per-entry `message` from config becomes the help text; forbid_elements_diagnostic builds this message with the offending element name and is invoked from add_diagnostic_if_invalid_element during element traversal.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/forbid_elements.rs:23 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace the forbidden element with an allowed alternative (often suggested by the configured help message).","Remove the element from the forbid list if it should be permitted."],"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"}