{"record":{"id":"accaece1133c40d7","repo":"oxc-project/oxc","slug":"this-kind-default-export-is-missing-a-name","errorCode":null,"errorMessage":"This {kind} default export is missing a name","messagePattern":"This (.+?) default export is missing a name","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/unicorn/no_anonymous_default_export.rs","lineNumber":17,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{AssignmentExpression, AssignmentTarget, ExportDefaultDeclarationKind, Expression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, ast_util, context::LintContext, rule::Rule};\n\nfn no_anonymous_default_export_diagnostic(span: Span, kind: ErrorNodeKind) -> OxcDiagnostic {\n    let kind = match kind {\n        ErrorNodeKind::Function => \"function\",\n        ErrorNodeKind::Class => \"class\",\n    };\n\n    OxcDiagnostic::warn(format!(\"This {kind} default export is missing a name\"))\n        // TODO: suggest a name. https://github.com/sindresorhus/eslint-plugin-unicorn/blob/d3e4b805da31c6ed7275e2e2e770b6b0fbcf11c2/rules/no-anonymous-default-export.js#L41\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoAnonymousDefaultExport;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Disallows anonymous functions and classes as default exports.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// Naming default exports improves searchability and ensures consistent\n    /// identifiers for a module’s default export in both declaration and import.\n    ///\n    /// ### Examples","sourceCodeStart":1,"sourceCodeEnd":35,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/unicorn/no_anonymous_default_export.rs#L1-L35","documentation":"Raised by unicorn/no-anonymous-default-export when the default export is an anonymous function or class (inline `export default function() {}` or `class {}`). The helper maps the node kind to 'function'/'class' for the message; the faulting input is the anonymous default export declaration at the labeled span.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/unicorn/no_anonymous_default_export.rs:17 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Give the function or class a name: `export default function myFunction() {}`","Assign the anonymous value to a named variable/const and export that 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-14T00:17:10.932Z"}