# n/no-exports-assign

> Disallow assigning to `exports`

In a CommonJS file, `exports` is a local variable that starts out as `module.exports`. Assigning to it only changes the variable. The module still exports the old `module.exports`, so `require()` gets an empty object.

An assignment that sets `module.exports` in the same statement is allowed, because both then hold the same value.

`--fix` rewrites `exports = ..` to `module.exports = ..`.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"n/no-exports-assign" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad */}
```js
exports = {
  parse,
  stringify,
};
```

Not reported:

{/* good */}
```js
module.exports = {
  parse,
  stringify,
};
```

{/* good */}
```js
exports.parse = parse;
exports.stringify = stringify;
```

{/* good */}
```js
module.exports = exports = { parse };
exports.stringify = stringify;
```
