Skip to content

Latest commit

History

History
45 lines (31 loc) 路 1.05 KB

File metadata and controls

45 lines (31 loc) 路 1.05 KB

node/no-exports-assign

disallow the assignment to exports

  • 猸愶笍 This rule is included in plugin:node/recommended preset.

To assign to exports variable would not work as expected.

// This assigned object is not exported.
// You need to use `module.exports = { ... }`.
exports = {
    foo: 1
}

馃摉 Rule Details

This rule is aimed at disallowing exports = {}, but allows module.exports = exports = {} to avoid conflict with node/exports-style rule's allowBatchAssign option.

馃憤 Examples of correct code for this rule:

/*eslint node/no-exports-assign: error */

module.exports.foo = 1
exports.bar = 2

module.exports = {}

// allows `exports = {}` if along with `module.exports =`
module.exports = exports = {}
exports = module.exports = {}

馃憥 Examples of incorrect code for this rule:

/*eslint node/no-exports-assign: error */

exports = {}

馃攷 Implementation