{"record":{"id":"b555b0fe76a2ebd2","repo":"oxc-project/oxc","slug":"components-should-use-createreactclass-instead-o","errorCode":null,"errorMessage":"Components should use `createReactClass` instead of an ES2015 class.","messagePattern":"Components should use `createReactClass` instead of an ES2015 class\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/react/prefer_es6_class.rs","lineNumber":15,"sourceCode":"use oxc_ast::AstKind;\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\nuse serde::Deserialize;\n\nuse crate::{\n    AstNode,\n    context::{ContextHost, LintContext},\n    rule::{DefaultRuleConfig, Rule},\n    utils::{AlwaysNever, is_es5_component, is_es6_component},\n};\n\nfn unexpected_es6_class_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Components should use `createReactClass` instead of an ES2015 class.\")\n        .with_label(span)\n}\n\nfn expected_es6_class_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Components should use an ES2015 class instead of `createReactClass`.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct PreferEs6Class(AlwaysNever);\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// React offers you two ways to create traditional components: using the\n    /// `create-react-class` package or the newer ES2015 class system.\n    ///\n    /// Note that function components are preferred over class components in modern React,","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/react/prefer_es6_class.rs#L1-L33","documentation":"Raised by react/prefer_es6_class when configured with `never` and a component is defined via `React.createClass`/`createReactClass` instead of an ES2015 class. At the throw site the legacy factory API is deprecated (removed from React core) and the project mandates class components; unexpected_es6_class_diagnostic fires from run() when a createReactClass call is detected that constitutes a component definition, telling authors to convert it to `class X extends React.Component`.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/react/prefer_es6_class.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Convert the class component to createReactClass if the legacy pattern is required by the codebase.","Change the rule option to 'never' to enforce ES classes instead."],"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"}