Extract rule: template-no-yield-block-params-to-else-inverse#2595
Conversation
NullVoxPopuli-ai-agent
left a comment
There was a problem hiding this comment.
Review: template-no-yield-block-params-to-else-inverse (PR #2595)
Comparison with ember-template-lint no-yield-block-params-to-else-inverse.js
General correctness:
-
Good: The rule correctly checks
GlimmerMustacheStatementwherenode.path.original === 'yield', has params, and has atohash pair with value'else'or'inverse'. This matches the original logic. -
Minor difference in hash.pairs access: The original accesses
node.hash.pairswithout a guard (ember-template-lint guaranteesnode.hash.pairsalways exists as an array). The PR addsnode.hash && node.hash.pairsguard, which is fine — defensive coding. -
Error message uses inline string instead of
messages: TheERROR_MESSAGEconstant is used viacontext.report({ message: ERROR_MESSAGE })but themessagesobject inmetais empty (messages: {}). This works but is inconsistent — typically you'd either usemessageIdwith a populatedmessagesobject, or use inlinemessage. Sincemessagesis empty, consider either removing the emptymessages: {}or populating it and usingmessageIdconsistently. Not a blocker. -
Tests look comprehensive: Both gjs
<template>and hbs modes are tested. Valid cases includeyieldwithout params +to="else"(correctly valid), andnot-yieldwith params (correctly valid).
Scope analysis (gjs/gts):
The rule checks node.path.original === 'yield'. yield is a Glimmer keyword, not a component/helper that can be imported or shadowed by JS variables. No scope analysis needed.
Overall: Clean migration. Looks good.
🤖 Automated review comparing with ember-template-lint source
Split from #2371.