{"record":{"id":"2b6ad0038cdb333b","repo":"oxc-project/oxc","slug":"unexpected-default-export-of-anonymous-function","errorCode":null,"errorMessage":"Unexpected default export of anonymous function","messagePattern":"Unexpected default export of anonymous function","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs","lineNumber":141,"sourceCode":"    short_description = \"Disallow anonymous default exports in modules.\",\n);\n\nimpl Rule for NoAnonymousDefaultExport {\n    fn from_configuration(value: Value) -> Result<Self, serde_json::error::Error> {\n        DefaultRuleConfig::<Self>::from_value(value).map(DefaultRuleConfig::into_inner)\n    }\n\n    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            }","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs#L123-L159","documentation":"Fires from import/no-anonymous-default-export when a module's default export is a function declaration with no name and the allowAnonymousFunction option is false. The run match arm labels the export declaration span and passes this specific message to the shared diagnostic helper.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/import/no_anonymous_default_export.rs:141 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Name the function before default-exporting it: `export default function myFn() {}`","Enable `allowAnonymousFunction` if anonymous functions 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-14T05:17:10.506Z"}