# array-callback-without-return

Rule `sonarjs/array-callback-without-return`. Callbacks of array methods should have return statements

- Source: sonarjs
- Technologies: JavaScript
- Kind: correctness
- Needs type information: yes
- Autofix: no
- Reach: 6.2M weekly downloads of presets that enable it
- Trend: +62.1% last quarter
- Rank: #1165 by reach, #466 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `sonarjs/array-callback-without-return` | yes | no | package `eslint-plugin-sonarjs` | [docs](https://rules.sonarsource.com/javascript/RSPEC-3796/) |

## Code examples

### Incorrect: the rule reports this

```js
let arr = ["a", "b", "c"];
let merged = arr.reduce(function(a, b) {
  a.concat(b);
}); // Noncompliant: No return statement, will result in TypeError
```

### Correct: the rule accepts this

```js
let arr = ["a", "b", "c"];
let merged = arr.reduce(function(a, b) {
  return a.concat(b);
}); // merged === "abc"
```

Examples from the ESLint documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
export default [
  {
    rules: {
      "sonarjs/array-callback-without-return": "error",
    },
  },
];
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [SonarJS recommended](https://lintradar.dev/presets/sonarjs-recommended.md) | ESLint | `eslint-plugin-sonarjs` | 230 | 6.2M | +62.1% |

## Related rules

- [sonarjs/arguments-order](https://lintradar.dev/rules/sonarjs/arguments-order.md): Parameters should be passed in the correct order
- [sonarjs/assertions-in-test-cases](https://lintradar.dev/rules/sonarjs/assertions-in-test-cases.md): Assertions should be placed inside test cases or hooks
- [sonarjs/argument-type](https://lintradar.dev/rules/sonarjs/argument-type.md): Arguments to built-in functions should match documented types
- [sonarjs/assertions-in-tests](https://lintradar.dev/rules/sonarjs/assertions-in-tests.md): Tests should include assertions
- [sonarjs/anchor-precedence](https://lintradar.dev/rules/sonarjs/anchor-precedence.md): Alternatives in regular expressions should be grouped when used with anchors
- [sonarjs/async-test-assertions](https://lintradar.dev/rules/sonarjs/async-test-assertions.md): Async test assertions should be awaited or returned

---

Web page: https://lintradar.dev/rules/sonarjs/array-callback-without-return. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
