For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt, and this page is available as Markdown at https://rslint.rs/rules/unicorn/max-nested-calls.md.
close

max-nested-calls

Added in v0.9.5

Configuration

PresetConfigured Value
✅ unicornPlugin.configs.recommended"error"
rslint.config.ts
import { defineConfig, unicornPlugin } from '@rslint/core';

export default defineConfig([
  unicornPlugin.configs.recommended,
  {
    rules: {
      'unicorn/max-nested-calls': 'error',
    },
  },
]);

Limit the depth of nested calls and constructor calls passed as arguments to other calls.

Deep call nesting is harder to read and can usually be clarified by extracting an intermediate result.

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

// Correct
const value = baz(qux());
foo(bar(value));

Fluent receiver chains such as query().filter().map().toArray() do not increase the nesting depth. Function, class, JSX, and static-block boundaries reset the depth.

Options

max

Type: integer Default: 3

Sets the maximum allowed nested call depth.

{
  'unicorn/max-nested-calls': ['error', { max: 4 }]
}

This port follows eslint-plugin-unicorn v75.0.0.