n/no-exports-assign
April 30, 2026 ยท View on GitHub
๐ Disallow the assignment to exports.
๐ผ This rule is enabled in the following configs: ๐ข recommended-module, โ
recommended-script.
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 n/exports-style rule's allowBatchAssign option.
๐ Examples of correct code for this rule:
/*eslint n/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 n/no-exports-assign: error */
exports = {}