New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disallow assignment to exports
(node/no-exports-assign)
#1400
Comments
I'm not sure how this rule is not a subset of exports-style. {
"node/exports-style": [
"error",
"module.exports" // isn't this `no-exports-assign`?
{
"allowBatchAssign": false
}
]
} |
This rule specifically catches the mistake of writing e.g. exports = {}
exports.foo = 42 and expecting that This is because node.js implicitly does something like this at the top of each module: // implicitly
var module = {}
var exports = module.exports = {} And then it uses whatever is on |
Thank you for the explanation. That part I understand. The part that seems unclear regarding the |
In which case this seems like a good idea. Of course, |
Deciding whether to forbid Haven't tested it with |
exports
exports
(node/no-exports-assign)
0% ecosystem failure. This will ship in standard 16! |
https://github.com/mysticatea/eslint-plugin-node/blob/master/docs/rules/no-exports-assign.md
Assigning to the
exports
variable does not work as expected.This rule is aimed at disallowing
exports = {}
, but allowsmodule.exports = exports = {}
to avoid conflict with node/exports-style rule'sallowBatchAssign
option.👍 Examples of correct code for this rule:
👎 Examples of incorrect code for this rule:
I don't expect this to be controversial
The text was updated successfully, but these errors were encountered: