> For AI agents: the complete documentation index is available at https://rslint.rs/llms.txt, the full documentation bundle is available at https://rslint.rs/llms-full.txt.

# no-alert

[Added in v0.4.2](https://github.com/web-infra-dev/rslint/releases/tag/v0.4.2)
## Configuration


```ts title=rslint.config.ts
import { defineConfig, js } from '@rslint/core';

export default defineConfig([
  js.configs.recommended,
  {
    rules: {
      'no-alert': 'error',
    },
  },
]);
```

## Rule Details

Disallow the use of `alert`, `confirm`, and `prompt`.

JavaScript's `alert`, `confirm`, and `prompt` functions are widely considered to be obtrusive as UI elements and should be replaced by a more appropriate custom UI implementation. Furthermore, `alert` is often used while debugging code, which should be removed before deployment to production.

Examples of **incorrect** code for this rule:

```javascript
alert('here!');
confirm('Are you sure?');
prompt("What's your name?", 'John Doe');

window.alert('here!');
globalThis.confirm('Are you sure?');
this.prompt("What's your name?");
```

Examples of **correct** code for this rule:

```javascript
customAlert('Something happened!');
customConfirm('Are you sure?');
customPrompt('Who are you?');

function foo() {
  var alert = myCustomLib.customAlert;
  alert();
}
```

## Original Documentation

- [ESLint: no-alert](https://eslint.org/docs/latest/rules/no-alert)
- [Source code](https://github.com/eslint/eslint/blob/v10.8.1/lib/rules/no-alert.js)
