{"record":{"id":"000015630f7d1e99","repo":"oxc-project/oxc","slug":"unexpected-default-export-of-anonymous-class","errorCode":null,"errorMessage":"Unexpected default export of anonymous class","messagePattern":"Unexpected default export of anonymous class","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs","lineNumber":149,"sourceCode":"    fn run<'a>(&self, node: &AstNode<'a>, ctx: &LintContext<'a>) {\n        let AstKind::ExportDefaultDeclaration(export_decl) = node.kind() else {\n            return;\n        };\n        match &export_decl.declaration {\n            ExportDefaultDeclarationKind::FunctionDeclaration(func_decl)\n                if !self.allow_anonymous_function && func_decl.id.is_none() =>\n            {\n                ctx.diagnostic(no_anonymous_default_export_diagnostic(\n                    export_decl.span,\n                    \"Unexpected default export of anonymous function\",\n                ));\n            }\n            ExportDefaultDeclarationKind::ClassDeclaration(class_decl)\n                if !self.allow_anonymous_class && class_decl.id.is_none() =>\n            {\n                ctx.diagnostic(no_anonymous_default_export_diagnostic(\n                    export_decl.span,\n                    \"Unexpected default export of anonymous class\",\n                ));\n            }\n            ExportDefaultDeclarationKind::ArrowFunctionExpression(_)\n                if !self.allow_arrow_function =>\n            {\n                ctx.diagnostic(no_anonymous_default_export_diagnostic(\n                    export_decl.span,\n                    \"Assign arrow function to a variable before exporting as module default\",\n                ));\n            }\n            ExportDefaultDeclarationKind::ObjectExpression(_) if !self.allow_object => {\n                ctx.diagnostic(no_anonymous_default_export_diagnostic(\n                    export_decl.span,\n                    \"Assign object to a variable before exporting as module default\",\n                ));\n            }\n            ExportDefaultDeclarationKind::CallExpression(_) if !self.allow_call_expression => {\n                ctx.diagnostic(no_anonymous_default_export_diagnostic(","sourceCodeStart":131,"sourceCodeEnd":167,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs#L131-L167","documentation":"Fires from import/no-anonymous-default-export when the default export is a class declaration with no name and allowAnonymousClass is false. Emitted from the ClassDeclaration match arm in run, labeling the export span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs:149 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Name the class before default-exporting it: `export default class MyComponent {}`","Enable `allowAnonymousClass` if anonymous classes are acceptable"],"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"}