n/exports-style
eslint-plugin-n
Safe autofix
eslint.config.js
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/exports-style": "error",
},
},
];exports.foo = 1
exports.bar = 2module.exports = {
foo: 1,
bar: 2
}
module.exports.baz = 3module.exports = {
foo: 1,
bar: 2
}
module.exports.baz = 3exports.foo = 1
exports.bar = 2// Allow `module.exports` in the same assignment expression as `exports`.
module.exports = exports = function foo() {
// do something.
}
exports.bar = 1Examples from the ESLint documentation.
n/exports-style
eslint-plugin-n
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/exports-style": "error",
},
},
];node/exports-style
node plugin · style
{
"plugins": [
"node"
],
"rules": {
"node/exports-style": "error"
}
}Biome does not have this rule.
Require require() calls to be placed at top-level module scope
Disallow require calls to be mixed with regular variable declarations
Enforce the style of file extensions in import declarations
Enforce using process.getBuiltinModule() to load Node.js built-in modules