oxc-project/oxc · error · OxcDiagnostic
Prefer re-exporting directly from the source module.
Error message
Prefer re-exporting directly from the source module.
What it means
Diagnostic from the unicorn/prefer-export-from lint rule. It fires when a module imports bindings and then immediately re-exports them in separate statements; a combined `export { x } from 'source'` (or `export * from 'source'`) re-exports directly without introducing local bindings. The diagnostic labels both the import statement and the re-export it makes redundant. It is a lint suggestion, not a runtime error.
Source
Thrown at crates/oxc_linter/src/rules/unicorn/prefer_export_from.rs:30
Program, Statement, VariableDeclarationKind, VariableDeclarator, WithClause,
WithClauseKeyword,
},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_semantic::{NodeId, SymbolId};
use oxc_span::{GetSpan, Span};
use crate::{
AstNode,
context::LintContext,
fixer::{RuleFix, RuleFixer},
rule::{DefaultRuleConfig, Rule},
utils::default_true,
};
fn prefer_export_from_diagnostic(import_span: Span, export_span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Prefer re-exporting directly from the source module.")
.with_labels([import_span.label("Imported here."), export_span.label("Re-exported here.")])
}
#[derive(Debug, Clone, JsonSchema, Deserialize)]
#[serde(rename_all = "camelCase", default, deny_unknown_fields)]
pub struct PreferExportFrom {
/// When false, if any import binding is used somewhere other than a re-export, all variables in the import declaration are ignored.
#[serde(default = "default_true")]
check_used_variables: bool,
}
impl Default for PreferExportFrom {
fn default() -> Self {
Self { check_used_variables: true }
}
}
declare_oxc_lint!(View on GitHub (pinned to e1e7af627c)
Solutions
- Merge the import/export pair into `export { name } from 'source'`
- Use `export * from 'source'` when re-exporting everything
- Apply the rule's auto-fix, which collapses the two statements
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/unicorn/prefer_export_from.rs:30 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/8f843091dcce4911.
Report an issue: GitHub.