close

max-nested-calls

Unreleased

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.