noExcessiveNestedCallbacks
Summary
Section titled “Summary”- Rule available since:
v2.4.14 - Diagnostic Category:
lint/nursery/noExcessiveNestedCallbacks - This rule doesn’t have a fix.
- The default severity of this rule is warning.
- Sources:
- Same as
max-nested-callbacks
- Same as
How to configure
Section titled “How to configure”{ "linter": { "rules": { "nursery": { "noExcessiveNestedCallbacks": "error" } } }}Description
Section titled “Description”Enforce a maximum depth that callbacks can be nested.
Deeply nested callbacks make asynchronous control flow difficult to read and follow. This rule reports callback functions nested beyond the configured limit.
Examples
Section titled “Examples”Invalid
Section titled “Invalid”foo1(function () { foo2(function () { foo3(function () { foo4(function () { foo5(function () { foo6(function () {}); }); }); }); });});code-block.js:6:26 lint/nursery/noExcessiveNestedCallbacks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This callback is nested too deeply.
4 │ foo4(function () {
5 │ foo5(function () {
> 6 │ foo6(function () {});
│ ^^^^^^^^^^^^^^
7 │ });
8 │ });
ℹ Callbacks nested 6 levels deep are harder to read and maintain. The configured maximum is 5.
ℹ Extract some callbacks into named functions to reduce nesting.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
foo1(handleFoo1);
function handleFoo1() { foo2(handleFoo2);}Options
Section titled “Options”The maximum callback nesting depth allowed (default: 5).
{ "linter": { "rules": { "nursery": { "noExcessiveNestedCallbacks": { "options": { "max": 3 } } } } }}Invalid
Section titled “Invalid”foo1(function () { foo2(function () { foo3(function () { foo4(function () {}); }); });});code-block.js:4:18 lint/nursery/noExcessiveNestedCallbacks ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
⚠ This callback is nested too deeply.
2 │ foo2(function () {
3 │ foo3(function () {
> 4 │ foo4(function () {});
│ ^^^^^^^^^^^^^^
5 │ });
6 │ });
ℹ Callbacks nested 4 levels deep are harder to read and maintain. The configured maximum is 3.
ℹ Extract some callbacks into named functions to reduce nesting.
ℹ This rule belongs to the nursery group, which means it is not yet stable and may change in the future. Visit https://biomejs.dev/linter/#nursery for more information.
foo1(function () { foo2(function () { foo3(function () {}); });});Related links
Section titled “Related links”Copyright (c) 2023-present Biome Developers and Contributors.