oxc-project/oxc · error · OxcDiagnostic
Multiple named export declarations; consolidate all named ex
Error message
Multiple named export declarations; consolidate all named exports into a single export declaration
What it means
Fires from import/group-exports when an ES module contains multiple separate named export declarations for the same kind. The helper selects this message (vs the CommonJS variant) when is_commonjs is false, labeling the span of the redundant export declaration.
Source
Thrown at crates/oxc_linter/src/rules/import/group_exports.rs:20
AstKind,
ast::{ImportOrExportKind, MemberExpression},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use rustc_hash::FxHashMap;
use crate::{context::LintContext, rule::Rule};
fn group_exports_diagnostic(span: Span, is_commonjs: bool) -> OxcDiagnostic {
let (msg, help) = if is_commonjs {
(
"Multiple CommonJS exports; consolidate all exports into a single assignment to `module.exports`",
"Combine multiple assignments into a single `module.exports = { ... }` statement",
)
} else {
(
"Multiple named export declarations; consolidate all named exports into a single export declaration",
"Use a single export declaration with multiple specifiers: `export { spec1, spec2 }`",
)
};
OxcDiagnostic::warn(msg).with_help(help).with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct GroupExports;
declare_oxc_lint!(
/// ### What it does
///
/// Reports when named exports are not grouped together in a single export declaration
/// or when multiple assignments to CommonJS module.exports
/// or exports object are present in a single file.
///
/// ### Why is this bad?
///View on GitHub (pinned to e1e7af627c)
Solutions
- Consolidate the named exports into a single `export { ... }` or `export const ...` declaration
- Merge multiple export statements covering the same bindings
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/import/group_exports.rs:20 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/00aa97bf8ab11f96.
Report an issue: GitHub.