From 591d81085d3099f265189611cbb8abe8d8d5047b Mon Sep 17 00:00:00 2001 From: NullVoxPopuli <199018+NullVoxPopuli@users.noreply.github.com> Date: Mon, 23 Feb 2026 15:14:32 -0500 Subject: [PATCH] Extract rule: template-no-inline-event-handlers --- README.md | 1 + .../template-no-inline-event-handlers.md | 72 +++++++++++++++++++ .../template-no-inline-event-handlers.js | 58 +++++++++++++++ .../template-no-inline-event-handlers.js | 71 ++++++++++++++++++ 4 files changed, 202 insertions(+) create mode 100644 docs/rules/template-no-inline-event-handlers.md create mode 100644 lib/rules/template-no-inline-event-handlers.js create mode 100644 tests/lib/rules/template-no-inline-event-handlers.js diff --git a/README.md b/README.md index ac4e88593a..1ad0042ccb 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,7 @@ rules in templates can be disabled with eslint directives with mustache or html | [template-no-chained-this](docs/rules/template-no-chained-this.md) | disallow redundant `this.this` in templates | | 🔧 | | | [template-no-debugger](docs/rules/template-no-debugger.md) | disallow {{debugger}} in templates | | | | | [template-no-element-event-actions](docs/rules/template-no-element-event-actions.md) | disallow element event actions (use {{on}} modifier instead) | | | | +| [template-no-inline-event-handlers](docs/rules/template-no-inline-event-handlers.md) | disallow DOM event handler attributes | | | | | [template-no-inline-styles](docs/rules/template-no-inline-styles.md) | disallow inline styles | | | | | [template-no-input-placeholder](docs/rules/template-no-input-placeholder.md) | disallow placeholder attribute on input elements | | | | | [template-no-input-tagname](docs/rules/template-no-input-tagname.md) | disallow tagName attribute on {{input}} helper | | | | diff --git a/docs/rules/template-no-inline-event-handlers.md b/docs/rules/template-no-inline-event-handlers.md new file mode 100644 index 0000000000..09f203506f --- /dev/null +++ b/docs/rules/template-no-inline-event-handlers.md @@ -0,0 +1,72 @@ +# ember/template-no-inline-event-handlers + + + +Disallows DOM event handler attributes in templates. + +Inline event handlers like `onclick="..."` are an older pattern that should be replaced with the `{{on}}` modifier for better Ember integration and testability. + +## Rule Details + +This rule disallows the use of inline DOM event handler attributes like `onclick`, `onsubmit`, etc. + +## Examples + +Examples of **incorrect** code for this rule: + +```gjs + +``` + +```gjs + +``` + +```gjs + +``` + +Examples of **correct** code for this rule: + +```gjs + +``` + +```gjs + +``` + +```gjs + +``` + +## Migration + +Replace: + +```gjs +