---
title: "lint/style/prefer-arrow-function"
pagination: false
---

{/* Generated by scripts/gen-rule-docs.py. Edit mapping.toml, not this file. */}

<RuleId id="lint/style/prefer-arrow-function" />

In the [`modernize`](/docs/rules/sets/modernize) set. Unsafe fix: it can change behaviour.

## What it does

Anonymous functions with return as the only statement must use arrow functions.

## Configuration

```toml title="pun.toml"
[lint.rules]
"style/prefer-arrow-function" = "error"
```

To skip it in some files, add an [override](/docs/configuration/pun-toml#lint) or a [`@pun-ignore-file`](/docs/configuration/ignore-comments) comment.

## Replaces

- [`use_arrow_functions`](https://cs.symfony.com/doc/rules/function_notation/use_arrow_functions.html) (php-cs-fixer, risky)
- [`prefer-arrow-function`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#prefer-arrow-function) (mago-linter)

[More lint/style rules](/docs/rules/lint/style) · [Edit this page](https://github.com/shipfastlabs/pun/edit/main/crates/pun-config/rules/mapping.toml)
