Skip to content

VBC-080: browser-alert

error

Category: clean-code
Analysis: Regex (line by line)
File types: .js, .ts, .tsx, .astro
Scope: source code only, ignoring anything inside strings and comments
Tags: ux

What it reports

Avoid using alert() at line {line}. Use a modern UI notification system.

Flagged

js
alert("saved");
js
alert(message);
js
alert(ok ? "saved" : "failed");
js
alert({ tone: "warning" });

Not flagged

js
showToast("saved");
js
alert(text: string): void {
js
alert(text?: string): void {

Pattern

regex
\balert\((?!\s*\w+\s*\??:\s*\w)

Released under the MIT License.