Extract rule: template-require-media-caption#2610
Extract rule: template-require-media-caption#2610NullVoxPopuli wants to merge 1 commit intoember-cli:masterfrom
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-require-media-caption (PR #2610)
Comparison with ember-template-lint source
General correctness:
-
Error message difference: The original ETL rule uses a single error message:
"Media elements such as <audio> and <video> must have a <track> for captions."The ESLint version uses a parameterizedmissingTrackmessage with{{tag}}. This is fine and arguably better, but worth noting the divergence. -
Muted attribute handling: The original ETL checks
['MustacheStatement', 'BlockStatement'].includes(mutedAttribute.value.type)to allow dynamic muted values, and separately checks![false, 'false'].includes(mutedAttribute.value.chars). The ESLint version handles this differently with explicit type checks. The logic appears equivalent, but there's a subtle difference: the ETL code treatsmuted="false"(string) as NOT muted and falls through, which is correctly replicated. However, the ETL code does NOT check forBooleanLiteral(false)specifically — it relies onMustacheStatementtype check to pass through any mustache expression. The ESLint version adds special handling formuted={{false}}(GlimmerBooleanLiteral false), which is a good enhancement. -
Missing
hasChildrencheck: The original ETL checks!AstNodeInfo.hasChildren(node)before checking for tracks, meaning an element with no children at all is also flagged. The ESLint version'snode.children?.some(...)returnsfalse/undefinedfor empty children, which correctly produces the same result — elements with no children are flagged. Good. -
Track kind check with dynamic values: The ESLint version only checks
kindAttr.value?.type === 'GlimmerTextNode'for thekindattribute on<track>. This means<track kind={{captionType}} />would NOT be recognized as valid. The original ETL similarly only checkskindAttribute.value.chars, so this matches the original behavior.
Scope analysis (gjs/gts):
Not applicable. This rule only checks HTML element tags (audio, video, track) and attribute values — no helper/component name matching by string is involved. No scope analysis needed.
Tests: Good coverage of both gjs and hbs modes, including muted attribute edge cases.
Overall, this looks like a solid migration. No blocking issues found.
🤖 Automated review comparing with ember-template-lint source
Split from #2371.