Functions are nested inside each other deeper than the configured maximum
What it finds
Functions nested in functions nested in functions, as in a pyramid of callbacks, keep every enclosing scope in play and push the code to the right. Named functions at a shallower level, or async and await, usually read better.
The level of a function is the number of functions around it plus one, so a function at the top of a file is at level one. Class bodies do not count as a level of their own; their methods are functions. The function that first goes past the limit is reported, and functions inside it are not. The limit is the parameter max (5 by default).
From the rule's source, deep_function_nesting.rs.
function level1() { return () => { return function level3() { return { level4() { return () => { return () => 6;tx0 reports: this function is nested inside 5 other functions }; }, }; }; };} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/ts:deep-function-nesting" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/ts:deep-function-nesting] reason="..."tx0 explain tx0/ts:deep-function-nesting shows the same in the terminal. Found a false positive? Report it.