n/callback-return
eslint-plugin-n
No autofix
eslint.config.js
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/callback-return": "error",
},
},
];function foo(err, callback) {
if (err) {
callback(err);
}
callback();
}function foo(err, done) {
if (err) {
done(err);
}
done();
}
function bar(err, send) {
if (err) {
send.error(err);
}
send.success();
}function foo(err, callback) {
if (err) {
callback(err); // this is fine, but WILL warn
} else {
callback(); // this is fine, but WILL warn
}
}function foo(err, callback) {
if (err) {
return callback(err);
}
callback();
}function foo(err, done) {
if (err) {
return done(err);
}
done();
}
function bar(err, send) {
if (err) {
return send.error(err);
}
send.success();
}function foo(err, callback) {
if (err) {
setTimeout(callback, 0); // this is bad, but WILL NOT warn
}
callback();
}Examples from the ESLint documentation.
n/callback-return
eslint-plugin-n
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/callback-return": "error",
},
},
];node/callback-return
node plugin · style
{
"plugins": [
"node"
],
"rules": {
"node/callback-return": "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