Enforce a maximum depth that callbacks can be nested
Many JavaScript libraries use the callback pattern to manage asynchronous operations. A program of any complexity will most likely need to manage several asynchronous operations at various levels of concurrency. A common pitfall that is easy to fall into is nesting callbacks, which makes code more difficult to read the deeper the callbacks are nested.
This rule enforces a maximum depth that callbacks can be nested to increase code clarity.
This rule has a number or object option:
"max"
(default 10
) enforces a maximum depth that callbacks can be nestedDeprecated: The object property maximum
is deprecated; please use the object property max
instead.
Examples of incorrect code for this rule with the { "max": 3 }
option:
Examples of correct code for this rule with the { "max": 3 }
option:
This rule was introduced in ESLint v0.2.0.
© OpenJS Foundation and other contributors
Licensed under the MIT License.
https://eslint.org/docs/latest/rules/max-nested-callbacks