Skip to content

alerts

Reports uses of the global alert/confirm/prompt dialog APIs.

✅ This rule is included in the browser logical preset.

The legacy browser dialog APIs alert, confirm, and prompt are synchronous, blocking, and provide a poor user experience in modern web applications. They should be avoided in production code in favor of non-blocking UI patterns (for example, custom modals) or other mechanisms for collecting user input or showing messages.

alert("Hello, world!");
if (!confirm("Are you sure?")) {
return;
}
const name = prompt("What's your name?");

This rule is not configurable.

If you’re writing quick temporary debugging snippets that never ship to users, or an internal-only page where the user experience does not matter, you might accept using alert/confirm/prompt locally. For production code and libraries, prefer non-blocking alternatives.

Made with ❤️‍🔥 in Boston by Josh Goldberg and contributors.