{"record":{"id":"96ebb7e4fe6db014","repo":"oxc-project/oxc","slug":"do-not-assign-to-the-variable-module","errorCode":null,"errorMessage":"Do not assign to the variable `module`.","messagePattern":"Do not assign to the variable `module`\\.","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"warning","filePath":"crates/oxc_linter/src/rules/nextjs/no_assign_module_variable.rs","lineNumber":9,"sourceCode":"use oxc_ast::{AstKind, ast::BindingPattern};\nuse oxc_diagnostics::OxcDiagnostic;\nuse oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{AstNode, context::LintContext, rule::Rule};\n\nfn no_assign_module_variable_diagnostic(span: Span) -> OxcDiagnostic {\n    OxcDiagnostic::warn(\"Do not assign to the variable `module`.\")\n        .with_help(\"See https://nextjs.org/docs/messages/no-assign-module-variable\")\n        .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct NoAssignModuleVariable;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// Prevents the assignment or declaration of variables named `module` in Next.js applications.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// The variable name `module` is reserved in Next.js for internal use and module system\n    /// functionality. Declaring your own `module` variable can conflict with Next.js's internal\n    /// module system, lead to unexpected behavior in your application, and cause issues with code\n    /// splitting and hot module replacement.","sourceCodeStart":1,"sourceCodeEnd":27,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/nextjs/no_assign_module_variable.rs#L1-L27","documentation":"Warning from oxlint rule `nextjs/no-assign-module-variable`. Next.js bundles code with webpack, which supplies every CommonJS module with a free `module` variable (`module.exports`). Declaring or assigning your own `module` shadows that built-in and breaks module evaluation during the build. The rule flags any binding or assignment target named exactly `module`.","triggerScenarios":"Any declaration (`var`/`let`/`const`/`function`/`class`), import binding, or assignment such as `module = ...` that introduces or writes a variable named `module`.","commonSituations":"Porting Node-style code that wraps modules (`const module = { exports: {} }`); test helpers reusing the name; generated code that inlines a module object.","solutions":["Rename the variable to something like `appModule` or `mod`.","If you are wrapping CommonJS output, keep that code in a `.cjs` or server-side file outside the Next.js client lint scope.","Re-run oxlint to confirm no `module` binding remains."],"exampleFix":"// before\nconst module = { exports: {} };\n\n// after\nconst moduleWrapper = { exports: {} };","handlingStrategy":"validation","validationCode":"// catch module bindings early:\n// rg -n '(const|let|var|function|class)\\s+module\\b|^\\s*module\\s*=' src","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reserve `module` as an untouchable name in Next.js code review checklists.","When porting CommonJS wrappers, rename `module`/`exports` immediately during the port.","Enable the nextjs oxlint plugin in CI to catch the binding before webpack fails the build."],"tags":["nextjs","webpack","naming","lint"],"backgroundTag":"reserved-identifier-shadowing","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"}