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.
Examples
Section titled “Examples”alert("Hello, world!");
if (!confirm("Are you sure?")) { return;}
const name = prompt("What's your name?");
console.log("Hello, world!");
if (!(await myCustomModal("Are you sure?"))) { return;}
const name = await myCustomInput("What's your name?");
Options
Section titled “Options”This rule is not configurable.
When Not To Use It
Section titled “When Not To Use It”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.
Further Reading
Section titled “Further Reading”Equivalents in Other Linters
Section titled “Equivalents in Other Linters”- Biome:
noAlert
- ESLint:
no-alert
- Oxlint:
eslint/no-alert
Made with ❤️🔥 in Boston by
Josh Goldberg and contributors.