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, and this page is available as Markdown at https://rslint.rs/rules/eslint/no-alert.md.
close

no-alert

Added in v0.4.2

Configuration

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:

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:

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

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

Original Documentation