Skip to main content

no-use-event-handler-attr

Warn when specifying the event handler attribute.

❌ Examples of incorrect code for this rule

<div onclick="() => doSomething()">Click</div>

✅ Examples of correct code for this rule

<div id="foo">Click</div>

<script>
document.getElementById('foo').addEventListener('click', () => doSomething());
</script>

Interface

{
"no-use-event-handler-attr": boolean
}

Options

{
"no-use-event-handler-attr": {
"options": {
"ignore"?: string | string[]
}
}
}
PropertyTypeDefault ValueDescription
ignorestring | string[]undefinedSpecify the event handler to ignore as string or string array. It accepts even in a regex format.

Default Severity

warning