{"record":{"id":"7e281132fc84bf6d","repo":"oxc-project/oxc","slug":"unnecessary-closing-tag","errorCode":null,"errorMessage":"Unnecessary closing tag","messagePattern":"Unnecessary closing tag","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/self_closing_comp.rs","lineNumber":19,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{JSXChild, JSXElementName},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse schemars::JsonSchema;\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    globals::HTML_TAG,\n    rule::{DefaultRuleConfig, Rule},\n};\n\nfn self_closing_comp_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Unnecessary closing tag\")\n        .with_help(\"Make the component self closing\")\n        .with_label(span)\n}\n\n#[derive(Debug, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct SelfClosingComp {\n    /// Whether to enforce self-closing for custom components.\n    component: bool,\n    /// Whether to enforce self-closing for native HTML elements.\n    html: bool,\n}\n\nimpl Default for SelfClosingComp {\n    fn default() -> Self {\n        Self { component: true, html: true }\n    }\n}","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/self_closing_comp.rs#L1-L37","documentation":"Raised by react/self_closing_comp when a JSX element with no children is written with explicit open and close tags (e.g. `<Component></Component>`) rather than self-closing. At the throw site the closing tag is pure noise — the two forms are semantically identical — and the project enforces the terser self-closing form. self_closing_comp_diagnostic fires from run() for elements whose children list is empty, pointing at the closing tag span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/self_closing_comp.rs:19 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Use the self-closing form: <div /> instead of <div></div>."],"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"}