oxc-project/oxc · warning · OxcDiagnostic

Reexporting 'default' export is restricted.

Error message

Reexporting 'default' export is restricted.

What it means

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.

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 under a name: `export { default as Legacy } from './legacy';`.
  2. Expose a wrapper: `import Legacy from './legacy'; export { Legacy };`.
  3. If the restriction is unwanted, remove `defaultFrom` from `restrictedDefaultExports` in .oxlintrc.
  4. Delete the re-export if the default should not leak through the barrel at all.

Example fix

// before
export { default } from './legacy';

// after
export { default as Legacy } from './legacy';
Defensive patterns

Strategy: validation

Validate before calling

// Guard barrel files: fail if they forward another module's default
const src = require('node:fs').readFileSync(file, 'utf8');
if (/export\s*\{\s*default\s*(?:as\s+default\s*)?\}\s*from/.test(src)) {
  console.error('default-export forwarding is banned by convention');
  process.exitCode = 1;
}

Prevention

When it happens

Trigger: `"no-restricted-exports": ["error", { "restrictedDefaultExports": { "defaultFrom": true } }]` combined with code like `export { default } from './legacy';` or `export { default as default } from './mod';`.

Common situations: Library style guides that ban default exports to enforce consistent named imports; barrel/index files that blindly forward defaults from wrapped modules.

Related errors


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