Extract rule: template-require-valid-form-groups#2615
Extract rule: template-require-valid-form-groups#2615NullVoxPopuli wants to merge 2 commits intoember-cli:masterfrom
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-require-valid-form-groups (PR #2615)
Comparison with ember-template-lint source
General correctness:
-
Parent traversal mechanism: The original ETL uses
path.parents()to walk up the ancestor chain, checking allElementNodeancestors. The ESLint version usesnode.parentand manually walks up. This depends on whether the Glimmer ESLint parser sets.parenton nodes. If it does, this works equivalently. If not,hasValidGroupingAncestorwould always return false, causing false positives. -
legendtag handling differs: The original ETL checks['legend', 'fieldset'].includes(node.tag)— meaning a<legend>tag itself is treated as a valid form group ancestor. The ESLint version does the same inisValidFormGroup. However,<legend>alone doesn't group form controls — it's<fieldset>that does the grouping, with<legend>as its label. Including<legend>as a valid grouping ancestor is technically wrong in both versions, but at least they match. -
hasMultipleFormElementsInParentScoperelies onnode.parent: The function checksnode.parentand requires it to be aGlimmerElementNode. If the parent is the template root (e.g.,GlimmerTemplate), this returns false, meaning form elements directly under the template root would never be flagged. The original ETL checkspath.parent.node.type === 'ElementNode'— same behavior. -
Only checks
inputelements: Both versions only check<input>elements viaFORM_ELEMENTS. Other form elements like<select>,<textarea>are not checked. This matches the original.
Scope analysis (gjs/gts):
Not applicable. This rule checks HTML element tags (input, fieldset, legend) and attributes (role, aria-labelledby). No helper/component name matching.
Tests: Test coverage matches the original ETL tests. Both gjs and hbs modes tested.
Summary: Faithful migration. The main concern is whether node.parent is reliably set by the Glimmer ESLint parser — if so, this is correct.
🤖 Automated review comparing with ember-template-lint source
a7fc196 to
0f01f92
Compare
Split from #2371.