{"record":{"id":"cb23b61fcb5f1061","repo":"oxc-project/oxc","slug":"standard-form-for-react-fragments-is-preferred","errorCode":null,"errorMessage":"Standard form for React fragments is preferred.","messagePattern":"Standard form for React fragments is preferred\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/jsx_fragments.rs","lineNumber":27,"sourceCode":"use crate::{\n    AstNode,\n    context::LintContext,\n    rule::{DefaultRuleConfig, Rule},\n    utils::is_jsx_fragment,\n};\n\nfn jsx_fragments_diagnostic(span: Span, mode: FragmentMode) -> OxcDiagnostic {\n    let msg = if mode == FragmentMode::Element {\n        \"Standard form for React fragments is preferred.\"\n    } else {\n        \"Shorthand form for React fragments is preferred.\"\n    };\n    let help = if mode == FragmentMode::Element {\n        \"Use `<React.Fragment></React.Fragment>` instead of `<></>`.\"\n    } else {\n        \"Use `<></>` instead of `<React.Fragment></React.Fragment>`.\"\n    };\n    OxcDiagnostic::warn(msg).with_help(help).with_label(span)\n}\n\n// Generally we should prefer the string-only syntax for compatibility with the original ESLint rule,\n// but we originally implemented the rule with only the object syntax, so we support both now.\n#[derive(Debug, Clone, JsonSchema, Deserialize)]\n#[serde(untagged)]\npub enum JsxFragments {\n    Mode(FragmentMode),\n    Object { mode: FragmentMode },\n}\n\nimpl Default for JsxFragments {\n    fn default() -> Self {\n        JsxFragments::Mode(FragmentMode::Syntax)\n    }\n}\n\nimpl JsxFragments {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/jsx_fragments.rs#L9-L45","documentation":"Raised by react/jsx_fragments when the rule is configured to prefer the element form (`FragmentMode::Element`) and shorthand fragment syntax `<></>` is encountered. At the throw site the fragment could not carry a `key` prop and the project style mandates explicit `<React.Fragment>` elements. jsx_fragments_diagnostic selects this message/help pair based on the configured mode and is called from run() on each JSX fragment node.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/jsx_fragments.rs:27 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace <></> with <React.Fragment></React.Fragment>.","Switch the rule mode to 'syntax' if shorthand is preferred."],"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-14T00:17:10.932Z"}