oxc-project/oxc · warning · OxcDiagnostic

Reexporting namespace as default is restricted.

Error message

Reexporting namespace as default is restricted.

What it means

The `NamespaceFrom` branch of `no-restricted-exports`. It fires when the config sets `restrictedDefaultExports.namespaceFrom` and the module re-exports an entire namespace as default: `export * as default from 'mod';`.

Source

Thrown at crates/oxc_linter/src/rules/eslint/no_restricted_exports.rs:47

    Named,
    DefaultFrom,
    NamedFrom,
    NamespaceFrom,
}

fn no_restricted_default_exports_diagnostic(
    span: Span,
    export_type: DefaultExportType,
) -> OxcDiagnostic {
    let warn = match export_type {
        DefaultExportType::DefaultFrom => "Reexporting 'default' export is restricted.",
        DefaultExportType::Direct => "Exporting 'default' is restricted.",
        DefaultExportType::Named => "Exporting named value as default is restricted.",
        DefaultExportType::NamedFrom => "Reexporting named export as default is restricted.",
        DefaultExportType::NamespaceFrom => "Reexporting namespace as default is restricted.",
    };

    OxcDiagnostic::warn(warn).with_help("Use named export instead.").with_label(span)
}

fn no_restricted_named_exports_diagnostic(span: Span, name: &str) -> OxcDiagnostic {
    OxcDiagnostic::warn(format!("'{name}' is restricted from being used as an exported name."))
        .with_help("Rename this export.")
        .with_label(span)
}

#[derive(Debug, Default, Clone, Deserialize)]
pub struct NoRestrictedExports(Box<NoRestrictedExportsConfig>);

#[derive(Debug, Default, Clone, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct NoRestrictedExportsConfig {
    /// An array of strings, where each string is a name to be restricted.
    ///
    /// Example of **incorrect** code for `"restrictedNamedExports": ["foo"]`:
    ///

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Re-export the namespace under a name: `export * as api from './api';`.
  2. Or forward specific members: `export { getUsers } from './api';`.
  3. Remove `namespaceFrom` from the config if the pattern is deliberate.

Example fix

// before
export * as default from './api';

// after
export * as api from './api';
Defensive patterns

Strategy: validation

Validate before calling

// Detect `export * as default from '...'`
const src = require('node:fs').readFileSync(file, 'utf8');
if (/export\s*\*\s*as\s+default\s*from/.test(src)) {
  console.error('namespace-as-default re-export is banned');
  process.exitCode = 1;
}

Prevention

When it happens

Trigger: `restrictedDefaultExports: { "namespaceFrom": true }` in .oxlintrc plus `export * as default from './api';`.

Common situations: Aggregator entry points that forward a whole module as default; style guides banning all default-export shapes.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/fcc8a80e3d0df03c. Report an issue: GitHub.