no-window-confirm
window.confirm() should use a confirmation dialog.
| Severity | Dimension | Files |
|---|---|---|
| Error | Consistency | .tsx .jsx .ts |
What it flags
A line like this:
if (window.confirm('Delete this preset?')) remove(id)
is reported as:
window.confirm() — use a ConfirmDialog component instead
How to fix it
Replace with a design system confirmation dialog.
preset AI suggests a fix: Replace window.confirm() with ConfirmDialog. Browser confirm dialogs block the UI and cannot be styled. Use a Dialog component with confirm/cancel actions.
Before:
if (window.confirm('Delete this preset?')) remove(id)
After:
// Use a confirmation dialog component
const confirmed = await showConfirmDialog({
title: "Are you sure?",
confirmText: "Confirm",
});
Related
- All rules: every built-in rule, by dimension.
- Set up enforcement: connect an AI tool and make validation required.
Last reviewed by @jschuyler