{"record":{"id":"eae90bbad7e41229","repo":"oxc-project/oxc","slug":"multiple-commonjs-exports-consolidate-all-exports","errorCode":null,"errorMessage":"Multiple CommonJS exports; consolidate all exports into a single assignment to `module.exports`","messagePattern":"Multiple CommonJS exports; consolidate all exports into a single assignment to `module\\.exports`","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/import/group_exports.rs","lineNumber":15,"sourceCode":"use oxc_ast::{\n    AstKind,\n    ast::{ImportOrExportKind, MemberExpression},\n};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\nuse rustc_hash::FxHashMap;\n\nuse crate::{context::LintContext, rule::Rule};\n\nfn group_exports_diagnostic(span: Span, is_commonjs: bool) -> OxcDiagnostic {\n    let (msg, help) = if is_commonjs {\n        (\n            \"Multiple CommonJS exports; consolidate all exports into a single assignment to `module.exports`\",\n            \"Combine multiple assignments into a single `module.exports = { ... }` statement\",\n        )\n    } else {\n        (\n            \"Multiple named export declarations; consolidate all named exports into a single export declaration\",\n            \"Use a single export declaration with multiple specifiers: `export { spec1, spec2 }`\",\n        )\n    };\n    OxcDiagnostic::warn(msg).with_help(help).with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct GroupExports;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Reports when named exports are not grouped together in a single export declaration","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/import/group_exports.rs#L1-L33","documentation":"Fires from import/group-exports when a CommonJS module assigns to module.exports (or exports.*) more than once. The rule tracks repeated assignments in run_once and reports the span of the offending assignment with guidance to merge them into a single module.exports object literal.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/import/group_exports.rs:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Combine all assignments into a single `module.exports = { ... }` statement","Move additional properties into the one object literal instead of mutating exports later"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}