@next/next/no-assign-module-variable

Disallow declaring a variable named module

Also called nextjs/no-assign-module-variable

The bundler gives every file a module object, and the code Next.js adds for hot reloading uses it. If you declare a variable named module, it hides that object, which can break the build or hot reloading.

The rule reports var, let, const and using declarations of module, anywhere in the file. It doesn't report parameters, destructuring, or an assignment to the existing module.

Configure#

Off by default. To turn it on:

bunfig.toml
[lint.rules]
"@next/next/no-assign-module-variable" = "error" # or "warn"

Examples#

example.js1 problem
const module = await import("./charts.js");
module.render();
example.jsNo problems
const charts = await import("./charts.js");
charts.render();
example.jsNo problems
module.exports = { reactStrictMode: true };

function describe(module) {
  return module.id;
}