Skip to content

VBC-023: notification-permission-eager

error

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

What it reports

Notification.requestPermission() detected at line {line}. Requesting browser notification permissions immediately on page load is hostile UX that causes most users to click "Block" by default. Only request permissions in direct response to an explicit user action that requires notifications.

Flagged

js
Notification.requestPermission();

Not flagged

js
button.addEventListener("click", askForNotifications);

Pattern

regex
Notification\.requestPermission\(

Released under the MIT License.