alert, confirm or prompt opens a dialog that blocks the page

tx0/ts:blocking-dialogstrictwarningsmell

What it finds

alert, confirm and prompt stop the page until the user answers a dialog that the page cannot style, and browsers suppress them in some contexts. They are usually left over from debugging or stand in for a proper dialog.

Reported are calls of these functions on window or as global names not declared in the file.

From the rule's source, blocking_dialog.rs.

Example from the rule's tests
export function ask() {  alert("Saved");tx0 reports: alert blocks the page  const sure = window.confirm("Sure?");tx0 reports: confirm blocks the page  return sure && dialog.prompt("x");}declare const dialog: { prompt(s: string): boolean };
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:blocking-dialog" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:blocking-dialog] reason="..."

tx0 explain tx0/ts:blocking-dialog shows the same in the terminal. Found a false positive? Report it.