{"record":{"id":"98d5ead6b68c06d6","repo":"oxc-project/oxc","slug":"name-is-restricted-from-being-used-as-an-expor","errorCode":null,"errorMessage":"'{name}' is restricted from being used as an exported name.","messagePattern":"'(.+?)' is restricted from being used as an exported name\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/eslint/no_restricted_exports.rs","lineNumber":51,"sourceCode":"}\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    ///\n    /// ```ts\n    /// export const foo = 1;\n    /// ```\n    ///","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/eslint/no_restricted_exports.rs#L33-L69","documentation":"The named-export branch of `no-restricted-exports`. It fires for every exported name listed under `restrictedNamedExports`, regardless of how the export is written (declaration, `export { }` list, or `as` alias). The help text says to rename the export.","triggerScenarios":"`\"restrictedNamedExports\": [\"fetch\", \"dispose\"]` in .oxlintrc combined with `export function fetch() {}`, `const a = 1; export { a as dispose };`, or `export { cloneNode } from './dom';` when the name is on the list.","commonSituations":"Public API allowlists that freeze a library's exported surface; preventing exports of internal helpers; banning names that collide with DOM/Node built-ins in public entry points.","solutions":["Rename the export to an allowed name and update importers.","If the binding should stay internal, remove the `export` keyword.","Remove the name from `restrictedNamedExports` if the restriction is outdated."],"exampleFix":"// before\nexport function fetch(url) { /* ... */ }\n\n// after\nexport function request(url) { /* ... */ }","handlingStrategy":"validation","validationCode":"// Verify a module's exported names against a public-API allowlist\nconst exportedNames = new Set(\n  [...src.matchAll(/export\\s+(?:const|let|var|function|class)\\s+([A-Za-z_$][\\w$]*)/g)].map(m => m[1])\n    .concat([...src.matchAll(/export\\s*\\{([^}]*)\\}/g)].flatMap(m =>\n      m[1].split(',').map(s => s.trim().split(/\\s+as\\s+/).pop())\n    ))\n);\nconst ALLOWED = new Set(['request', 'configure']);\nfor (const name of exportedNames) if (!ALLOWED.has(name)) console.error(`unexpected export: ${name}`);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Maintain `restrictedNamedExports` alongside the library's public API docs so both stay in sync.","Review new `export` keywords in PR diffs for entry-point files.","Consider API extractor tools (ts-api-extractor) to freeze the exported surface."],"tags":["lint","eslint","no-restricted-exports","es-modules","configuration","api-surface"],"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"}