Skip to content

Files

Latest commit

 

History

History
33 lines (24 loc) · 530 Bytes

no-exports-assign.md

File metadata and controls

33 lines (24 loc) · 530 Bytes

Pattern: Direct exports assignment

Issue: -

Description

Assigning directly to exports (exports = {}) can break module exports by replacing the exports object. Use module.exports or add properties to exports instead.

Examples

Example of incorrect code:

exports = {
  foo: 1,
  bar: 2
};

exports = function() {};

Example of correct code:

module.exports = {
  foo: 1,
  bar: 2
};

exports.foo = 1;
exports.bar = 2;

// Allowed when used together
module.exports = exports = {};