Skip to content

Latest commit

Β 

History

History
43 lines (29 loc) Β· 1.02 KB

File metadata and controls

43 lines (29 loc) Β· 1.02 KB

max-nested-calls

πŸ“ Limit the depth of nested calls.

πŸ’ΌπŸš« This rule is enabled in the βœ… recommended config. This rule is disabled in the β˜‘οΈ unopinionated config.

Deeply nested calls make code hard to read. Extract intermediate results to named variables instead.

This rule counts calls and constructor calls passed into other calls or constructors. Fluent receiver chains and JSX wrappers are ignored.

Examples

// ❌
foo(bar(baz(qux())));

// βœ…
const value = baz(qux());
foo(bar(value));
// βœ…
query().filter().map().toArray();

Options

max

Type: integer
Default: 3

The maximum allowed nested call depth.

/* eslint unicorn/max-nested-calls: ["error", {"max": 4}] */
// βœ…
foo(bar(baz(qux())));