max-nested-callbacks
eslint
No autofix
eslint.config.js
export default [
{
rules: {
"max-nested-callbacks": "error",
},
},
];foo1(function() {
foo2(function() {
foo3(function() {
foo4(function() {
// Do something
});
});
});
});setTimeout(() => {
new Promise(function nested() {});
});foo1(handleFoo1);
function handleFoo1() {
foo2(handleFoo2);
}
function handleFoo2() {
foo3(handleFoo3);
}
function handleFoo3() {
foo4(handleFoo4);
}
function handleFoo4() {
foo5();
}function handler() {
new Promise(() => {});
}
setTimeout(handler);Examples from the ESLint documentation.
max-nested-callbacks
eslint
export default [
{
rules: {
"max-nested-callbacks": "error",
},
},
];max-nested-callbacks
eslint plugin · pedantic
{
"rules": {
"max-nested-callbacks": "error"
}
}complexity/noExcessiveNestedCallbacks
complexity · since 2.4.14
{
"linter": {
"rules": {
"complexity": {
"noExcessiveNestedCallbacks": "error"
}
}
}
}Enforce a maximum cyclomatic complexity allowed in a program
Disallow calls to the Object constructor without an argument
Enforce the use of u or v flag on regular expressions
Disallow use of Object.prototype.hasOwnProperty.call() and prefer use of Object.hasOwn()
Disallow equal signs explicitly at the beginning of regular expressions
Disallow declarations in the global scope