---
title: "lint/dead-code/no-always-true-instanceof"
pagination: false
---

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

<RuleId id="lint/dead-code/no-always-true-instanceof" />

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

## What it does

Remove instanceof checks and assert(instanceof) calls that are always true for the known type.

## Configuration

```toml title="pun.toml"
[lint.rules]
"dead-code/no-always-true-instanceof" = "error"
```

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

## Options

| Name | Type | Allowed values | Default | Upstream name |
| --- | --- | --- | --- | --- |
| `checks` | `list` | `assert`, `if` | `["assert", "if"]` | None (Pun's own) |

## Replaces

- [`RemoveDeadInstanceOf`](https://getrector.com/rule-detail/remove-dead-instance-of-rector) (rector)
- [`RemoveDeadInstanceOfAssert`](https://getrector.com/rule-detail/remove-dead-instance-of-assert-rector) (rector)
- [`instanceof.alwaysTrue`](https://phpstan.org/error-identifiers/instanceof.alwaysTrue) (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/dead-code/no-always-true-instanceof-assert`

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