---
title: "lint/types/prefer-instanceof"
pagination: false
---

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

<RuleId id="lint/types/prefer-instanceof" />

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

## What it does

Use instanceof instead of is_a(), null checks or truthiness checks on nullable objects.

## Configuration

```toml title="pun.toml"
[lint.rules]
"types/prefer-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).

## Replaces

- [`InlineIsAInstanceOf`](https://getrector.com/rule-detail/inline-is-a-instance-of-rector) (rector)

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