diff --git a/crates/oxc_linter/src/rules/unicorn/prefer_add_event_listener.rs b/crates/oxc_linter/src/rules/unicorn/prefer_add_event_listener.rs index dc4769a3e3a2d..18382d3a63348 100644 --- a/crates/oxc_linter/src/rules/unicorn/prefer_add_event_listener.rs +++ b/crates/oxc_linter/src/rules/unicorn/prefer_add_event_listener.rs @@ -71,6 +71,14 @@ impl Rule for PreferAddEventListener { } } +// Can refer to the following sources for the list of event handler names, compare +// this array against any new `onx` functions introduced in browsers: +// - https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Global_attributes#list_of_global_event_handler_attributes +// - https://github.com/mdn/browser-compat-data/blob/d5d5f2e21ef3f798784d1f5f75bde7c7f10f250e/api/Element.json +// - https://github.com/microsoft/TypeScript-DOM-lib-generator/blob/f915ac0c987300d75af41bfe4a34bb29a0fb941f/baselines/dom.generated.d.ts +// +// Please avoid adding new events that are not implemented in at least two major browser engines! +// Last updated: Nov 2025 const DOM_EVENT_TYPE_NAMES: phf::Set<&'static str> = phf::phf_set![ "AnimationEnd", "AnimationIteration", @@ -104,9 +112,10 @@ const DOM_EVENT_TYPE_NAMES: phf::Set<&'static str> = phf::phf_set![ "activate", "afterblur", "afterprint", - "animationEnd", - "animationStart", + "animationcancel", + "animationend", "animationiteration", + "animationstart", "appinstalled", "auxclick", "beforeblur", @@ -114,8 +123,10 @@ const DOM_EVENT_TYPE_NAMES: phf::Set<&'static str> = phf::phf_set![ "beforecut", "beforeinput", "beforeinstallprompt", + "beforematch", "beforepaste", "beforeprint", + "beforetoggle", "beforeunload", "blur", "cancel", @@ -129,9 +140,12 @@ const DOM_EVENT_TYPE_NAMES: phf::Set<&'static str> = phf::phf_set![ "compositionupdate", "connect", "consolemessage", + "contextlost", "contextmenu", + "contextrestored", "controllerchange", "copy", + "cuechange", "cut", "dblclick", "deactivate", @@ -157,6 +171,7 @@ const DOM_EVENT_TYPE_NAMES: phf::Set<&'static str> = phf::phf_set![ "focusin", "focusout", "foreignfetch", + "formdata", "fullscreenchange", "gotpointercapture", "hashchange", @@ -208,6 +223,7 @@ const DOM_EVENT_TYPE_NAMES: phf::Set<&'static str> = phf::phf_set![ "pointermove", "pointerout", "pointerover", + "pointerrawupdate", "pointerup", "popstate", "progress", @@ -219,7 +235,9 @@ const DOM_EVENT_TYPE_NAMES: phf::Set<&'static str> = phf::phf_set![ "responsive", "rightclick", "scroll", + "scrollend", "search", + "securitypolicyviolation", "seeked", "seeking", "select", @@ -227,6 +245,7 @@ const DOM_EVENT_TYPE_NAMES: phf::Set<&'static str> = phf::phf_set![ "selectstart", "show", "sizechanged", + "slotchange", "sourceclosed", "sourceended", "sourceopen", @@ -236,15 +255,18 @@ const DOM_EVENT_TYPE_NAMES: phf::Set<&'static str> = phf::phf_set![ "submit", "suspend", "text", - "textInput", "textinput", + "textInput", "timeupdate", "toggle", "touchcancel", "touchend", "touchmove", "touchstart", + "transitioncancel", "transitionend", + "transitionrun", + "transitionstart", "unload", "unresponsive", "update",