{"record":{"id":"0c3bc2a7e3e877dc","repo":"oxc-project/oxc","slug":"reexporting-default-export-is-restricted","errorCode":null,"errorMessage":"Reexporting 'default' export is restricted.","messagePattern":"Reexporting 'default' export 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 `defaultFrom` branch of `no-restricted-exports`. It fires when the config sets `restrictedDefaultExports.defaultFrom` and the module re-exports another module's default export as its own default: `export { default } from '...'`. The help text tells you to use a named export instead.","triggerScenarios":"`\"no-restricted-exports\": [\"error\", { \"restrictedDefaultExports\": { \"defaultFrom\": true } }]` combined with code like `export { default } from './legacy';` or `export { default as default } from './mod';`.","commonSituations":"Library style guides that ban default exports to enforce consistent named imports; barrel/index files that blindly forward defaults from wrapped modules.","solutions":["Re-export under a name: `export { default as Legacy } from './legacy';`.","Expose a wrapper: `import Legacy from './legacy'; export { Legacy };`.","If the restriction is unwanted, remove `defaultFrom` from `restrictedDefaultExports` in .oxlintrc.","Delete the re-export if the default should not leak through the barrel at all."],"exampleFix":"// before\nexport { default } from './legacy';\n\n// after\nexport { default as Legacy } from './legacy';","handlingStrategy":"validation","validationCode":"// Guard barrel files: fail if they forward another module's default\nconst src = require('node:fs').readFileSync(file, 'utf8');\nif (/export\\s*\\{\\s*default\\s*(?:as\\s+default\\s*)?\\}\\s*from/.test(src)) {\n  console.error('default-export forwarding is banned by convention');\n  process.exitCode = 1;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Codify the named-export policy once in .oxlintrc (`restrictedDefaultExports`) instead of reviewing it manually.","Generate barrel files with a tool that only emits named re-exports.","Add an ESLint/oxlint CI step so violations block the PR that introduces them."],"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-14T05:17:10.506Z"}