src/content/docs/linter/rules/no-alert.mdx
import { Tabs, TabItem } from '@astrojs/starlight/components';
<Tabs> <TabItem label="JavaScript (and super languages)" icon="seti:javascript"> ## Summary - Rule available since: `v2.1.0` - Diagnostic Category: [`lint/suspicious/noAlert`](/reference/diagnostics#diagnostic-category) - This rule isn't recommended, so you need to enable it. - This rule doesn't have a fix. - The default severity of this rule is [**information**](/reference/diagnostics#information). - Sources: - Same as [`no-alert`](https://eslint.org/docs/latest/rules/no-alert){
"linter": {
"rules": {
"suspicious": {
"noAlert": "error"
}
}
}
}
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.
alert("here!");
confirm("Are you sure?");
prompt("What's your name?", "John Doe");
customAlert("Something happened!");
customConfirm("Are you sure?");
customPrompt("Who are you?");
function foo() {
const alert = myCustomLib.customAlert;
alert();
}