Skip to content

Extract rule: template-require-media-caption#2610

Open
NullVoxPopuli wants to merge 1 commit intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-require-media-caption
Open

Extract rule: template-require-media-caption#2610
NullVoxPopuli wants to merge 1 commit intoember-cli:masterfrom
NullVoxPopuli:nvp/template-lint-extract-rule-template-require-media-caption

Conversation

@NullVoxPopuli
Copy link
Contributor

Split from #2371.

Copy link

@NullVoxPopuli-ai-agent NullVoxPopuli-ai-agent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review: template-require-media-caption (PR #2610)

Comparison with ember-template-lint source

General correctness:

  1. 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 parameterized missingTrack message with {{tag}}. This is fine and arguably better, but worth noting the divergence.

  2. 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 treats muted="false" (string) as NOT muted and falls through, which is correctly replicated. However, the ETL code does NOT check for BooleanLiteral(false) specifically — it relies on MustacheStatement type check to pass through any mustache expression. The ESLint version adds special handling for muted={{false}} (GlimmerBooleanLiteral false), which is a good enhancement.

  3. Missing hasChildren check: 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's node.children?.some(...) returns false/undefined for empty children, which correctly produces the same result — elements with no children are flagged. Good.

  4. Track kind check with dynamic values: The ESLint version only checks kindAttr.value?.type === 'GlimmerTextNode' for the kind attribute on <track>. This means <track kind={{captionType}} /> would NOT be recognized as valid. The original ETL similarly only checks kindAttribute.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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants