---
title: "lint/functions/no-unused-closure-use"
pagination: false
---

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

<RuleId id="lint/functions/no-unused-closure-use" />

In the [`dead-code`](/docs/rules/sets/dead-code) set. Safe fix.

## What it does

Lambda must not import variables it doesn't use.

## Configuration

```toml title="pun.toml"
[lint.rules]
"functions/no-unused-closure-use" = "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

- [`lambda_not_used_import`](https://cs.symfony.com/doc/rules/function_notation/lambda_not_used_import.html) (php-cs-fixer)
- [`RemoveUnusedClosureVariableUse`](https://getrector.com/rule-detail/remove-unused-closure-variable-use-rector) (rector)
- [`UnusedClosureUsesRule`](https://phpstan.org/error-identifiers/closure.unusedUse) (phpstan-classes)
- [`no-unused-closure-capture`](https://mago.carthage.software/1.61.0/en/tools/linter/rules/#no-unused-closure-capture) (mago-linter)
- [`closure.unusedUse`](https://phpstan.org/error-identifiers/closure.unusedUse) (phpstan)
- [`closure.unusedUseFlow`](https://phpstan.org/error-identifiers/closure.unusedUseFlow) (phpstan)

## Merged rules

These old IDs are now this rule. A config that still names one stops with an error. See [merged rules](/docs/migrate/merged-rules).

- `lint/functions/no-unused-closure-variable`

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