fix(template-no-nested-interactive): More useful error message#2772
Merged
NullVoxPopuli merged 3 commits intoember-cli:masterfrom Apr 30, 2026
Merged
Conversation
… error message The error said "Do not nest interactive element <button> inside <div>." which hides why the rule fired — authors had to inspect the rule source to find that role/contenteditable/tabindex on the parent or child was the trigger. Now the message names the disambiguating attribute when the bare tag would be uninformative: Do not nest interactive element <button> inside <div role="menu">. Do not nest interactive element <input> inside <div contenteditable>. Do not nest interactive element <div tabindex="1"> inside <button>. Self-explanatory native interactive tags (button, input, a, etc.) keep their bare-tag form to avoid redundant noise. Applied symmetrically to both parent and child sides.
NullVoxPopuli
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The current
template-no-nested-interactiveerror message gives only the bare tag of each side:When the parent is a
<div>(or<span>, etc.) the message hides why it was classified as interactive — authors have to inspect the rule source or work backwards fromINTERACTIVE_ROLES/isHtmlInteractiveContentto figure out thatrole,contenteditable, ortabindextriggered the rule.This PR makes the message name the disambiguating attribute when the bare tag would be uninformative:
Self-explanatory native interactive tags (
button,input,a,label,select,textarea,details,summary,embed,iframe,audio[controls],video[controls],img[usemap],canvas,object[usemap]) keep their bare-tag form, since the tag itself already conveys interactivity. Applied symmetrically on both the parent and child sides.The change is purely diagnostic — no rule firing/non-firing decisions are altered.
Implementation
describeInteractive(node)helper at module scope. Surfaces:role="X"whenXis inINTERACTIVE_ROLEScontenteditable(andcontenteditable="plaintext-only"when that exact spec keyword is used;''/'true'/ bare attribute collapse tocontenteditable)tabindex="X"when interactivity comes from tabindex on a tag that isn't otherwise interactivedescribeon eachinteractiveStackentry at push time, used asdata.parent.data.child.Test impact
<button><div tabindex="1"></div></button>→ child now says<div tabindex="1">instead of<div>).role="menu"parent (regression test for the original report),contenteditableparent,contenteditable="plaintext-only"parent, androle="button"child enrichment.Test plan
pnpm exec vitest run tests/lib/rules/template-no-nested-interactive.js— 99/99 pass<ul role="menu"><li role="presentation"><a role="menuitem" href>) still passes the rule<li role="menuitem"><button>correctly fires with the new message naming the parent's role