# no-alert

> Disallow `alert`, `confirm`, and `prompt`

`alert`, `confirm` and `prompt` stop all JavaScript on the page until the user answers, and you can't style the box they show. They're often left over from debugging.

{/* Generated by src/codegen/lint-rule-docs.ts. Do not edit this section. */}

## Configure

Off by default. To turn it on:

```toml bunfig.toml
[lint.rules]
"no-alert" = "error" # or "warn"
```

{/* End of the generated section. */}

## Examples

Reported:

{/* bad {"count": 2} */}
```js
alert("Saved");

if (window.confirm("Delete this file?")) {
  remove(file);
}
```

Not reported:

{/* good */}
```js
showToast("Saved");

if (await dialog.confirm("Delete this file?")) {
  remove(file);
}
```

Your own function with one of these names is fine:

{/* good */}
```js
import { alert } from "./ui/dialogs.js";

alert("Saved");
```

## When not to use it

In Bun, `alert`, `confirm` and `prompt` work in the terminal, which makes them a quick way to ask a question in a command-line script. Turn the rule off for those scripts.
