---
title: pun lint
description: Report code issues and apply fixes with --fix.
---

`pun lint` reports `[lint]` problems without editing files. `--fix` applies the available fixes. Lint doesn't format the result. [`pun check --fix`](/docs/commands/check) runs both.

```bash
pun lint
pun lint --fix
```

## Configure rules

A rule takes a level, or a table with a level, a fix setting, and options:

```toml pun.toml
[lint]
sets = ["dead-code", "modernize"]

[lint.rules]
"style/require-final-class" = "error"
"types/no-loose-comparison" = { level = "warn", fix = "off" }
"style/no-short-ternary" = "off"
```

| Value | Meaning |
| --- | --- |
| `"error"` | Report, and fail the run |
| `"warn"` | Report |
| `"off"` | Disable |
| `{ fix = "off" }` | Report, never fix, even with `--fix` |

Only errors fail the run, unless you set a warning limit. Path overrides take levels only. See [rule selection](/docs/configuration/pun-toml#lint) and the [rule reference](/docs/rules/lint).

## Levels on the command line

```bash
pun lint -A lint/style
pun lint -W security/no-global
pun lint -D lint/security -A security/no-eval
pun lint --deny-warnings
pun lint --max-warnings 10
```

| Flag | What it does |
| --- | --- |
| `-A`, `--allow <rule>` | Turn a rule or group off. |
| `-W`, `--warn <rule>` | Turn a rule or group on as a warning. |
| `-D`, `--deny <rule>` | Turn a rule or group on as an error. |
| `--deny-warnings` | Fail on any warning. |
| `--max-warnings N` | Fail on more than `N` warnings. |

`-A`, `-W`, and `-D` apply after `pun.toml` and path overrides, in command-line order. The last match wins. A group selects only implemented rules. Naming an unimplemented rule directly is a configuration error.

Lint also takes [`pun format`'s file-selection and output flags](/docs/commands/format#pints-flags), such as `--dirty`, `--diff`, `--staged`, `--format`, and `--stdin`.

`-q` prints nothing, as PHP-CS-Fixer's `fix -q` does, and the exit code reports the result. `pun format -q` and `pun check -q` keep Pint's stderr line per file.

Lint reuses each unchanged file's result from the last run, through the [result cache](/docs/commands/format#cache). `--no-cache` checks every file.

## Output

`--concise` prints one line per problem. `--format` takes `json`, `txt`, `checkstyle`, `junit`, `xml`, `gitlab`, `github`, or `agent`.

## Files

Lint skips Blade templates, `vendor/`, `bootstrap/cache`, `build`, `node_modules`, and `storage`. [`pun list-files --command lint`](/docs/commands/list-files) shows the selected files.

The `types/*` rules find classes in every file lint selects and in Composer's autoload. An overriding method gets a return type only when both classes are in `vendor/`, or both are outside it.

## Ignore comments

```php
$x = eval($code); // @pun-ignore lint/security/no-eval -- legacy plugin loader
```

PHP-CS-Fixer rules support only `@pun-ignore-file`. Other lint rules also support line and region ignores. An ignore without a rule ID is an error. See [ignore comments](/docs/configuration/ignore-comments).

## Exit codes

| Code | Meaning |
| --- | --- |
| 0 | No remaining errors and no warning limit exceeded |
| 1 | Remaining errors or a warning limit exceeded |
| 2 | Pun could not run |
