{"record":{"id":"bfc87ac2124e23af","repo":"oxc-project/oxc","slug":"use-an-object-instead-of-a-class-with-only-stat","errorCode":null,"errorMessage":"Use an object instead of a `class` with only `static` members.","messagePattern":"Use an object instead of a `class` with only `static` members\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_static_only_class.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::ClassElement};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::{GetSpan, Span};\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_static_only_class_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Use an object instead of a `class` with only `static` members.\")\n        .with_help(\"Convert to an object instead of a class with only static members.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoStaticOnlyClass;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallow `class` declarations that exclusively contain `static` members.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// A `class` with only `static` members should just be defined as an object instead.\n    ///\n    /// ### Examples\n    ///","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_static_only_class.rs#L1-L27","documentation":"Raised by unicorn/no-static-only-class when a `class` declaration contains only static members (no instance state or prototype methods), making the class a namespace. The faulting input is the static-only class declaration at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_static_only_class.rs:9 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Convert the class to a plain object with the members as properties","Use named exports of individual functions/constants instead of a container class"],"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"}