{"record":{"id":"8f1abc5bbec0b326","repo":"oxc-project/oxc","slug":"exporting-named-value-as-default-is-restricted","errorCode":null,"errorMessage":"Exporting named value as default is restricted.","messagePattern":"Exporting named value as default is restricted\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_restricted_exports.rs","lineNumber":47,"sourceCode":"    Named,\n    DefaultFrom,\n    NamedFrom,\n    NamespaceFrom,\n}\n\nfn no_restricted_default_exports_diagnostic(\n    span: Span,\n    export_type: DefaultExportType,\n) -> OxcDiagnostic {\n    let warn = match export_type {\n        DefaultExportType::DefaultFrom => \"Reexporting 'default' export is restricted.\",\n        DefaultExportType::Direct => \"Exporting 'default' is restricted.\",\n        DefaultExportType::Named => \"Exporting named value as default is restricted.\",\n        DefaultExportType::NamedFrom => \"Reexporting named export as default is restricted.\",\n        DefaultExportType::NamespaceFrom => \"Reexporting namespace as default is restricted.\",\n    };\n\n    OxcDiagnostic::warn(warn).with_help(\"Use named export instead.\").with_label(span)\n}\n\nfn no_restricted_named_exports_diagnostic(span: Span, name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"'{name}' is restricted from being used as an exported name.\"))\n        .with_help(\"Rename this export.\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone, Deserialize)]\npub struct NoRestrictedExports(Box<NoRestrictedExportsConfig>);\n\n#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]\n#[serde(rename_all = \"camelCase\", default, deny_unknown_fields)]\npub struct NoRestrictedExportsConfig {\n    /// An array of strings, where each string is a name to be restricted.\n    ///\n    /// Example of **incorrect** code for `\"restrictedNamedExports\": [\"foo\"]`:\n    ///","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_restricted_exports.rs#L29-L65","documentation":"The `Named` branch of `no-restricted-exports`. It fires when the config sets `restrictedDefaultExports.named` and the module aliases a local binding to the default export name: `export { foo as default };`.","triggerScenarios":"`restrictedDefaultExports: { \"named\": true }` in .oxlintrc plus code like `const foo = 1; export { foo as default };`.","commonSituations":"Codemods that mechanically rename default exports to `as default` aliases; refactoring halfway between default and named export styles.","solutions":["Export the binding under its own name: `export { foo };`.","Alternatively declare it named from the start: `export const foo = 1;`.","Remove `named` from `restrictedDefaultExports` if this shape is allowed."],"exampleFix":"// before\nconst foo = 1;\nexport { foo as default };\n\n// after\nexport const foo = 1;","handlingStrategy":"validation","validationCode":"// Detect `export { x as default };` aliases\nconst src = require('node:fs').readFileSync(file, 'utf8');\nif (/export\\s*\\{[^}]*\\bas\\s+default\\s*\\}/.test(src)) {\n  console.error('aliasing a named binding to default is banned');\n  process.exitCode = 1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Declare exports as `export const/function` directly instead of aliasing at the bottom of the file.","Enable `restrictedDefaultExports.named` so tooling, not memory, enforces the rule."],"tags":["lint","eslint","no-restricted-exports","es-modules","configuration"],"backgroundTag":"restricted-export-config","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"}