n/no-callback-literal
eslint-plugin-n
No autofix
eslint.config.js
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/no-callback-literal": "error",
},
},
];Enforce Node.js-style error-first callback pattern is followed
cb('this is an error string');
cb({ a: 1 });
callback(0);cb(undefined);
cb(null, 5);
callback(new Error('some error'));
callback(someVariable);Examples from the ESLint documentation.
n/no-callback-literal
eslint-plugin-n
import n from "eslint-plugin-n";
export default [
{
plugins: { n },
rules: {
"n/no-callback-literal": "error",
},
},
];Oxlint does not have this rule.
Biome does not have this rule.
Disallow require calls to be mixed with regular variable declarations
Require require() calls to be placed at top-level module scope
Enforce the style of file extensions in import declarations