# no-array-callback-reference

Rule `unicorn/no-array-callback-reference`. Prevent passing a function reference directly to iterator methods.

- Source: unicorn
- Technologies: JavaScript
- Kind: suspicious
- Needs type information: no
- Autofix: yes, in at least one linter
- Reach: 9.9M weekly downloads of presets that enable it
- Trend: +28.3% last quarter
- Rank: #1015 by reach, #1270 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `unicorn/no-array-callback-reference` | no | suggestion | package `eslint-plugin-unicorn` | [docs](https://github.com/sindresorhus/eslint-plugin-unicorn/blob/v80.0.0/docs/rules/no-array-callback-reference.md) |
| Oxlint | `unicorn/no-array-callback-reference` | no | no | plugin `unicorn`, category pedantic | [docs](https://oxc.rs/docs/guide/usage/linter/rules/unicorn/no-array-callback-reference.html) |

## Code examples

### Incorrect: the rule reports this

```js
const foo = array.map(callback);
```

```js
array.forEach(callback);
```

```js
const foo = array.every(callback);
```

### Correct: the rule accepts this

```js
const foo = array.map(element => callback(element));
```

```js
const foo = array.map(Boolean);
```

```js
array.forEach(element => {
  callback(element);
});
```

Examples from the ESLint documentation.

## Enable it

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

```js
import unicorn from "eslint-plugin-unicorn";

export default [
  {
    plugins: { unicorn },
    rules: {
      "unicorn/no-array-callback-reference": "error",
    },
  },
];
```

### Oxlint: `.oxlintrc.json`

```json
{
  "rules": {
    "unicorn/no-array-callback-reference": "error"
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Unicorn recommended](https://lintradar.dev/presets/unicorn-recommended.md) | ESLint | `eslint-plugin-unicorn` | 340 | 9.5M | +30.3% |
| [XO](https://lintradar.dev/presets/xo.md) | ESLint | `eslint-config-xo` | 618 | 413K | −5.0% |

## Related rules

- [unicorn/max-nested-calls](https://lintradar.dev/rules/unicorn/max-nested-calls.md): Limit the depth of nested calls.
- [unicorn/consistent-boolean-name](https://lintradar.dev/rules/unicorn/consistent-boolean-name.md): Enforce consistent naming for boolean names.
- [unicorn/no-null](https://lintradar.dev/rules/unicorn/no-null.md): Disallow the use of the `null` literal.
- [unicorn/consistent-json-file-read](https://lintradar.dev/rules/unicorn/consistent-json-file-read.md): Enforce consistent JSON file reads before `JSON.parse()`.
- [unicorn/no-nested-ternary](https://lintradar.dev/rules/unicorn/no-nested-ternary.md): Disallow nested ternary expressions.
- [unicorn/consistent-tuple-labels](https://lintradar.dev/rules/unicorn/consistent-tuple-labels.md): Enforce consistent labels on tuple type elements.

---

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