max-nested-callbacks
Configuration
Rule Details
This rule enforces a maximum depth that callbacks can be nested to improve code readability. A common anti-pattern is "callback hell" — deeply nested callbacks that grow rightward and become hard to follow.
A function expression or arrow function counts toward the nesting depth only
when it is passed directly to a call (as a call argument or as the callee of
an immediately-invoked call). Function-likes assigned to variables, object or
class properties, array elements, JSX attributes, default parameter values,
or used as new arguments / tagged-template arguments do not increase the
counter.
Examples of incorrect code for this rule with the default { "max": 10 }
option:
Examples of correct code for this rule with the default { "max": 10 }
option:
Options
This rule accepts a number, or an object with the following properties:
max(default10): the maximum nesting depth allowed.maximum: deprecated alias formax. When both keys are present andmaximumis truthy,maximumwins (matching ESLint'soption.maximum || option.maxcoercion).
max
Examples of incorrect code for this rule with { "max": 3 }:
Examples of correct code for this rule with { "max": 3 }:
Arrow functions are counted the same as function expressions: