Skip to content

Files

Latest commit

 

History

History
29 lines (22 loc) · 768 Bytes

no-alert.md

File metadata and controls

29 lines (22 loc) · 768 Bytes

Pattern: Use of alert, confirm, or prompt

Issue: -

Description

The built-in alert, confirm, and prompt functions create obtrusive UI elements that interrupt the user experience. They should be replaced with custom UI components that match the application's design. Additionally, alert is often used for debugging and should be removed before deployment.

Examples

Example of incorrect code:

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

Example of correct code:

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

// Using custom implementation
function foo() {
  const alert = myCustomLib.customAlert;
  alert();
}