# How to Configure the arrow-body-style Rule for Object Literals in Airbnb ESLint

> Learn how to configure the arrow-body-style rule for object literals in Airbnb ESLint. Override the default settings to enforce explicit return statements for better code clarity and control.

- Repository: [Airbnb/javascript](https://github.com/airbnb/javascript)
- Tags: how-to-guide
- Published: 2026-02-24

---

**The Airbnb ESLint configuration enforces `arrow-body-style` with `requireReturnForObjectLiteral` set to `false` by default in [`packages/eslint-config-airbnb-base/rules/es6.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb-base/rules/es6.js), allowing implicit returns for object literals, but you can override this to require explicit `return` statements.**

The `airbnb/javascript` repository provides one of the most widely adopted ESLint configurations in the JavaScript ecosystem. When working with arrow functions that return object literals, understanding how to configure the `arrow-body-style` rule ensures your code meets specific team readability standards while maintaining compatibility with the base style guide.

## Default Configuration in Airbnb ESLint

The base configuration ships with a specific setting for arrow function bodies that prioritizes concise syntax. According to the source code in the `airbnb/javascript` repository, the rule is defined to minimize unnecessary braces while permitting implicit object returns.

### Source File Location

In [`packages/eslint-config-airbnb-base/rules/es6.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb-base/rules/es6.js), lines 18–20 define the default behavior:

```javascript
'arrow-body-style': ['error', 'as-needed', {
  requireReturnForObjectLiteral: false,
}],

```

This configuration enforces two key behaviors:

- **`'as-needed'`** – ESLint requires braces only when the arrow function body contains multiple statements or complex logic that cannot be expressed in a single expression.
- **`requireReturnForObjectLiteral: false`** – Arrow functions can return object literals using implicit return syntax, such as `() => ({ key: value })`, without triggering a linting error.

## Overriding the Rule for Object Literals

If your project requires explicit `return` statements for object literals to avoid ambiguity between block statements and object expressions, you must override the default configuration in your local ESLint setup.

### Enabling requireReturnForObjectLiteral

To enforce explicit returns for object literals, extend the Airbnb base configuration and redefine the rule option:

1. Install the required dependencies:

```bash
npm install --save-dev eslint-config-airbnb-base eslint

```

2. Update your [`.eslintrc.json`](https://github.com/airbnb/javascript/blob/main/.eslintrc.json) or [`.eslintrc.js`](https://github.com/airbnb/javascript/blob/main/.eslintrc.js) to override the rule:

```json
{
  "extends": "airbnb-base",
  "rules": {
    "arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]
  }
}

```

Setting `requireReturnForObjectLiteral` to `true` forces developers to use block bodies with explicit `return` statements when returning object literals. This eliminates the parsing ambiguity where `{}` could be interpreted as a code block rather than an object literal, improving code clarity in large codebases.

## Code Examples and Behavior

The following examples demonstrate how the configuration affects linting results for arrow functions returning objects.

### Airbnb Default (requireReturnForObjectLiteral: false)

With the default configuration, implicit returns for object literals are permitted:

```javascript
// ✅ Passes - implicit return with parentheses
const getConfig = () => ({ debug: true, env: 'production' });

// ✅ Also passes - explicit return is optional
const getUser = () => ({ name: 'Alice', id: 1 });

```

### Strict Configuration (requireReturnForObjectLiteral: true)

When overriding the rule to require explicit returns, the implicit syntax triggers an error:

```javascript
// ❌ Fails - ESLint requires explicit return for object literal
const getConfig = () => ({ debug: true });

// ✅ Passes - explicit return statement required
const getConfig = () => {
  return { debug: true };
};

```

## Summary

- The Airbnb ESLint config sets `arrow-body-style` to `['error', 'as-needed', { requireReturnForObjectLiteral: false }]` in [`packages/eslint-config-airbnb-base/rules/es6.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb-base/rules/es6.js), allowing concise object returns without explicit `return` statements.
- The `requireReturnForObjectLiteral` option controls whether arrow functions returning objects must use explicit `return` statements (`true`) or can use implicit returns (`false`).
- Override the rule in your [`.eslintrc.json`](https://github.com/airbnb/javascript/blob/main/.eslintrc.json) by setting `"arrow-body-style": ["error", "as-needed", { "requireReturnForObjectLiteral": true }]` to enforce stricter object literal syntax.
- Explicit returns improve code clarity by removing ambiguity between object literals and block statements in arrow function bodies.

## Frequently Asked Questions

### How do I find the arrow-body-style configuration in the Airbnb ESLint source code?

The configuration resides in [`packages/eslint-config-airbnb-base/rules/es6.js`](https://github.com/airbnb/javascript/blob/main/packages/eslint-config-airbnb-base/rules/es6.js) at lines 18–20. This file contains the base rules for ES6 features, where `'arrow-body-style'` is set to `['error', 'as-needed', { requireReturnForObjectLiteral: false }]`.

### What is the difference between requireReturnForObjectLiteral true and false?

When set to `false` (the Airbnb default), arrow functions can return object literals using implicit return syntax like `() => ({})`. When set to `true`, ESLint requires block bodies with explicit `return` statements, forcing `() => { return {}; }` to prevent ambiguity between code blocks and object literals.

### Can I use arrow-body-style with the full airbnb config instead of airbnb-base?

Yes. The `eslint-config-airbnb` package extends `eslint-config-airbnb-base`, so the same `arrow-body-style` configuration applies. Override the rule in your [`.eslintrc.json`](https://github.com/airbnb/javascript/blob/main/.eslintrc.json) using `"extends": "airbnb"` followed by the same rules configuration to modify the object literal behavior.

### Why does Airbnb set requireReturnForObjectLiteral to false by default?

The default setting prioritizes concise syntax for simple data transformations and mapping operations. The Airbnb style guide permits implicit returns for object literals to reduce boilerplate in functional programming patterns, though teams can override this if they prefer explicit returns for readability.